Use namespaced strings for Transport IDs

This commit is contained in:
Torsten Grote
2016-11-17 17:06:26 -02:00
parent 37e61c97ea
commit e32313c30b
16 changed files with 71 additions and 32 deletions

View File

@@ -29,6 +29,9 @@ import org.briarproject.android.forum.ForumListFragment;
import org.briarproject.android.fragment.BaseFragment.BaseFragmentListener;
import org.briarproject.android.privategroup.list.GroupListFragment;
import org.briarproject.api.TransportId;
import org.briarproject.api.plugins.BluetoothConstants;
import org.briarproject.api.plugins.LanTcpConstants;
import org.briarproject.api.plugins.TorConstants;
import java.util.ArrayList;
import java.util.List;
@@ -230,21 +233,21 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
transports = new ArrayList<>(3);
Transport tor = new Transport();
tor.id = new TransportId("tor");
tor.id = TorConstants.ID;
tor.enabled = controller.isTransportRunning(tor.id);
tor.iconId = R.drawable.transport_tor;
tor.textId = R.string.transport_tor;
transports.add(tor);
Transport bt = new Transport();
bt.id = new TransportId("bt");
bt.id = BluetoothConstants.ID;
bt.enabled = controller.isTransportRunning(bt.id);
bt.iconId = R.drawable.transport_bt;
bt.textId = R.string.transport_bt;
transports.add(bt);
Transport lan = new Transport();
lan.id = new TransportId("lan");
lan.id = LanTcpConstants.ID;
lan.enabled = controller.isTransportRunning(lan.id);
lan.iconId = R.drawable.transport_lan;
lan.textId = R.string.transport_lan;

View File

@@ -65,26 +65,23 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING;
import static org.briarproject.api.keyagreement.KeyAgreementConstants.TRANSPORT_ID_BLUETOOTH;
import static org.briarproject.api.plugins.BluetoothConstants.ID;
import static org.briarproject.api.plugins.BluetoothConstants.PROP_ADDRESS;
import static org.briarproject.api.plugins.BluetoothConstants.PROP_UUID;
import static org.briarproject.api.plugins.BluetoothConstants.UUID_BYTES;
import static org.briarproject.util.PrivacyUtils.scrubMacAddress;
@MethodsNotNullByDefault
@ParametersNotNullByDefault
class DroidtoothPlugin implements DuplexPlugin {
// Share an ID with the J2SE Bluetooth plugin
static final TransportId ID = new TransportId("bt");
private static final Logger LOG =
Logger.getLogger(DroidtoothPlugin.class.getName());
private static final int UUID_BYTES = 16;
private static final String FOUND =
"android.bluetooth.device.action.FOUND";
private static final String DISCOVERY_FINISHED =
"android.bluetooth.adapter.action.DISCOVERY_FINISHED";
private static final String PROP_ADDRESS = "address";
private static final String PROP_UUID = "uuid";
private final Executor ioExecutor;
private final AndroidExecutor androidExecutor;
private final Context appContext;
@@ -315,6 +312,7 @@ class DroidtoothPlugin implements DuplexPlugin {
}
}
@Nullable
private BluetoothSocket connect(String address, String uuid) {
// Validate the address
if (!BluetoothAdapter.checkBluetoothAddress(address)) {
@@ -646,7 +644,7 @@ class DroidtoothPlugin implements DuplexPlugin {
private final BluetoothServerSocket ss;
BluetoothKeyAgreementListener(BdfList descriptor,
private BluetoothKeyAgreementListener(BdfList descriptor,
BluetoothServerSocket ss) {
super(descriptor);
this.ss = ss;