mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 15:19:53 +01:00
Return the empty string instead of the fake address.
This commit is contained in:
@@ -57,19 +57,18 @@ public class AndroidUtils {
|
|||||||
BluetoothAdapter adapter) {
|
BluetoothAdapter adapter) {
|
||||||
// Return the adapter's address if it's valid and not fake
|
// Return the adapter's address if it's valid and not fake
|
||||||
String address = adapter.getAddress();
|
String address = adapter.getAddress();
|
||||||
if (!StringUtils.isNullOrEmpty(address)
|
if (isValidBluetoothAddress(address)) return address;
|
||||||
&& BluetoothAdapter.checkBluetoothAddress(address)
|
// Return the address from settings if it's valid and not fake
|
||||||
&& !address.equals(FAKE_BLUETOOTH_ADDRESS)) {
|
|
||||||
return address;
|
|
||||||
}
|
|
||||||
// Return the address from settings if it's valid
|
|
||||||
address = Settings.Secure.getString(ctx.getContentResolver(),
|
address = Settings.Secure.getString(ctx.getContentResolver(),
|
||||||
"bluetooth_address");
|
"bluetooth_address");
|
||||||
if (!StringUtils.isNullOrEmpty(address)
|
if (isValidBluetoothAddress(address)) return address;
|
||||||
&& BluetoothAdapter.checkBluetoothAddress(address)) {
|
// Let the caller know we can't find the address
|
||||||
return address;
|
return "";
|
||||||
}
|
}
|
||||||
// As a last resort, return a fake but valid address
|
|
||||||
return FAKE_BLUETOOTH_ADDRESS;
|
private static boolean isValidBluetoothAddress(String address) {
|
||||||
|
return !StringUtils.isNullOrEmpty(address)
|
||||||
|
&& BluetoothAdapter.checkBluetoothAddress(address)
|
||||||
|
&& !address.equals(FAKE_BLUETOOTH_ADDRESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,10 +157,12 @@ class DroidtoothPlugin implements DuplexPlugin {
|
|||||||
adapter);
|
adapter);
|
||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO))
|
||||||
LOG.info("Local address " + address);
|
LOG.info("Local address " + address);
|
||||||
// Advertise the Bluetooth address to contacts
|
if (!StringUtils.isNullOrEmpty(address)) {
|
||||||
TransportProperties p = new TransportProperties();
|
// Advertise the Bluetooth address to contacts
|
||||||
p.put("address", address);
|
TransportProperties p = new TransportProperties();
|
||||||
callback.mergeLocalProperties(p);
|
p.put("address", address);
|
||||||
|
callback.mergeLocalProperties(p);
|
||||||
|
}
|
||||||
// Bind a server socket to accept connections from contacts
|
// Bind a server socket to accept connections from contacts
|
||||||
BluetoothServerSocket ss;
|
BluetoothServerSocket ss;
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user