Skip to content

Commit

Permalink
Fix crash when determining Bluetooth MAC via reflection on Pixel 2.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Schildbach committed Oct 19, 2017
1 parent 42be4a1 commit 08d1f81
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions wallet/src/de/schildbach/wallet/util/Bluetooth.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@
package de.schildbach.wallet.util;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.UUID;

import javax.annotation.Nullable;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import android.bluetooth.BluetoothAdapter;
import android.os.Build;

Expand All @@ -42,6 +46,8 @@ public class Bluetooth {
/** Android 6 uses this MAC address instead of the real one. */
private static final String MARSHMELLOW_FAKE_MAC = "02:00:00:00:00:00";

private static final Logger log = LoggerFactory.getLogger(Bluetooth.class);

public static boolean canListen(final BluetoothAdapter adapter) {
if (adapter == null)
return false;
Expand All @@ -67,6 +73,9 @@ public static boolean canListen(final BluetoothAdapter adapter) {
if (mService == null)
return null;
return (String) mService.getClass().getMethod("getAddress").invoke(mService);
} catch (final InvocationTargetException x) {
log.info("Problem determining Bluetooth MAC via reflection", x);
return null;
} catch (final Exception x) {
throw new RuntimeException(x);
}
Expand Down

0 comments on commit 08d1f81

Please sign in to comment.