Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • briar/briar
  • goapunk/briar
  • johndoe4221/briar
  • thomas/briar
4 results
Show changes
Commits on Source (1)
......@@ -129,6 +129,7 @@ class AndroidBluetoothPlugin extends BluetoothPlugin<BluetoothServerSocket> {
@Nullable
String getBluetoothAddress() {
String address = AndroidUtils.getBluetoothAddress(appContext, adapter);
LOG.info("Bluetooth address:" + address);
return address.isEmpty() ? null : address;
}
......
......@@ -6,6 +6,7 @@ import android.os.Build;
import android.provider.Settings;
import java.io.File;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
......@@ -41,6 +42,18 @@ public class AndroidUtils {
address = Settings.Secure.getString(ctx.getContentResolver(),
"bluetooth_address");
if (isValidBluetoothAddress(address)) return address;
try {
final Field mServiceField;
mServiceField = BluetoothAdapter.class.getDeclaredField("mService");
mServiceField.setAccessible(true);
final Object mService = mServiceField.get(adapter);
if (mService == null)
return "";
address = (String) mService.getClass().getMethod("getAddress").invoke(mService);
if (isValidBluetoothAddress(address)) return address;
} catch (Exception e) {
// Nothing we can do about it.
}
// Let the caller know we can't find the address
return "";
}
......