From c3a9eff96bd0ce80cb158012224451c42a4d7796 Mon Sep 17 00:00:00 2001 From: akwizgran Date: Thu, 22 Dec 2022 17:46:12 +0000 Subject: [PATCH] Always check Bluetooth permission when trying to get own address. --- .../briarproject/bramble/util/AndroidUtils.java | 3 +++ .../android/reporting/BriarReportCollector.java | 14 ++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/bramble-android/src/main/java/org/briarproject/bramble/util/AndroidUtils.java b/bramble-android/src/main/java/org/briarproject/bramble/util/AndroidUtils.java index a3a64fa9d..5783e150e 100644 --- a/bramble-android/src/main/java/org/briarproject/bramble/util/AndroidUtils.java +++ b/bramble-android/src/main/java/org/briarproject/bramble/util/AndroidUtils.java @@ -65,6 +65,9 @@ public class AndroidUtils { public static Pair getBluetoothAddressAndMethod(Context ctx, BluetoothAdapter adapter) { + // If we don't have permission to access the adapter's address, let + // the caller know we can't find it + if (!hasBtConnectPermission(ctx)) return new Pair<>("", ""); // Return the adapter's address if it's valid and not fake @SuppressLint("HardwareIds") String address = adapter.getAddress(); diff --git a/briar-android/src/main/java/org/briarproject/briar/android/reporting/BriarReportCollector.java b/briar-android/src/main/java/org/briarproject/briar/android/reporting/BriarReportCollector.java index 89b128045..db3752d77 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/reporting/BriarReportCollector.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/reporting/BriarReportCollector.java @@ -310,14 +310,12 @@ class BriarReportCollector { btLeAdvertise); } - if (hasBtConnectPermission(ctx)) { - Pair p = getBluetoothAddressAndMethod(ctx, bt); - String address = p.getFirst(); - String method = p.getSecond(); - connectivityInfo.add("BluetoothAddress", - scrubMacAddress(address)); - connectivityInfo.add("BluetoothAddressMethod", method); - } + Pair p = getBluetoothAddressAndMethod(ctx, bt); + String address = p.getFirst(); + String method = p.getSecond(); + connectivityInfo.add("BluetoothAddress", + scrubMacAddress(address)); + connectivityInfo.add("BluetoothAddressMethod", method); } return new ReportItem("Connectivity", R.string.dev_report_connectivity, connectivityInfo);