Loading android/app/src/com/android/bluetooth/Utils.java +17 −0 Original line number Diff line number Diff line Loading @@ -189,6 +189,23 @@ public final class Utils { return String.format("XX:XX:XX:XX:%02X:%02X", address[4], address[5]); } /** * Returns the correct device address to be used for connections over BR/EDR transport. * * @param device the device for which to obtain the connection address * @return either identity address or device address as a byte array */ public static byte[] getByteBrEdrAddress(BluetoothDevice device) { final AdapterService service = AdapterService.getAdapterService(); // If dual mode device bonded over BLE first, BR/EDR address will be identity address // Otherwise, BR/EDR address will be same address as in BluetoothDevice#getAddress byte[] address = service.getByteIdentityAddress(device); if (address == null) { address = getByteAddress(device); } return address; } public static byte[] getByteAddress(BluetoothDevice device) { return getBytesFromAddress(device.getAddress()); } Loading android/app/src/com/android/bluetooth/a2dp/A2dpNativeInterface.java +6 −1 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.util.Log; import com.android.bluetooth.Utils; import com.android.bluetooth.btservice.AdapterService; import com.android.bluetooth.flags.Flags; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -173,8 +174,12 @@ public class A2dpNativeInterface { if (device == null) { return Utils.getBytesFromAddress("00:00:00:00:00:00"); } if (Flags.identityAddressNullIfUnknown()) { return Utils.getByteBrEdrAddress(device); } else { return mAdapterService.getByteIdentityAddress(device); } } private void sendMessageToService(A2dpStackEvent event) { A2dpService service = A2dpService.getA2dpService(); Loading android/app/src/com/android/bluetooth/a2dpsink/A2dpSinkNativeInterface.java +6 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.util.Log; import com.android.bluetooth.Utils; import com.android.bluetooth.btservice.AdapterService; import com.android.bluetooth.flags.Flags; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -85,8 +86,12 @@ public class A2dpSinkNativeInterface { } private byte[] getByteAddress(BluetoothDevice device) { if (Flags.identityAddressNullIfUnknown()) { return Utils.getByteBrEdrAddress(device); } else { return mAdapterService.getByteIdentityAddress(device); } } /** * Initiates an A2DP connection to a remote device. Loading android/app/src/com/android/bluetooth/hfp/HeadsetNativeInterface.java +6 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.util.Log; import com.android.bluetooth.Utils; import com.android.bluetooth.btservice.AdapterService; import com.android.bluetooth.flags.Flags; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -91,8 +92,12 @@ public class HeadsetNativeInterface { // Set bt_stack's active device to default if java layer set active device to null return Utils.getBytesFromAddress("00:00:00:00:00:00"); } if (Flags.identityAddressNullIfUnknown()) { return Utils.getByteBrEdrAddress(device); } else { return mAdapterService.getByteIdentityAddress(device); } } void onConnectionStateChanged(int state, byte[] address) { HeadsetStackEvent event = Loading android/app/src/com/android/bluetooth/hfpclient/NativeInterface.java +7 −1 Original line number Diff line number Diff line Loading @@ -23,7 +23,9 @@ package com.android.bluetooth.hfpclient; import android.bluetooth.BluetoothDevice; import android.util.Log; import com.android.bluetooth.Utils; import com.android.bluetooth.btservice.AdapterService; import com.android.bluetooth.flags.Flags; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -339,8 +341,12 @@ public class NativeInterface { } private byte[] getByteAddress(BluetoothDevice device) { if (Flags.identityAddressNullIfUnknown()) { return Utils.getByteBrEdrAddress(device); } else { return mAdapterService.getByteIdentityAddress(device); } } // Callbacks from the native back into the java framework. All callbacks are routed via the // Service which will disambiguate which state machine the message should be routed through. Loading Loading
android/app/src/com/android/bluetooth/Utils.java +17 −0 Original line number Diff line number Diff line Loading @@ -189,6 +189,23 @@ public final class Utils { return String.format("XX:XX:XX:XX:%02X:%02X", address[4], address[5]); } /** * Returns the correct device address to be used for connections over BR/EDR transport. * * @param device the device for which to obtain the connection address * @return either identity address or device address as a byte array */ public static byte[] getByteBrEdrAddress(BluetoothDevice device) { final AdapterService service = AdapterService.getAdapterService(); // If dual mode device bonded over BLE first, BR/EDR address will be identity address // Otherwise, BR/EDR address will be same address as in BluetoothDevice#getAddress byte[] address = service.getByteIdentityAddress(device); if (address == null) { address = getByteAddress(device); } return address; } public static byte[] getByteAddress(BluetoothDevice device) { return getBytesFromAddress(device.getAddress()); } Loading
android/app/src/com/android/bluetooth/a2dp/A2dpNativeInterface.java +6 −1 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.util.Log; import com.android.bluetooth.Utils; import com.android.bluetooth.btservice.AdapterService; import com.android.bluetooth.flags.Flags; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -173,8 +174,12 @@ public class A2dpNativeInterface { if (device == null) { return Utils.getBytesFromAddress("00:00:00:00:00:00"); } if (Flags.identityAddressNullIfUnknown()) { return Utils.getByteBrEdrAddress(device); } else { return mAdapterService.getByteIdentityAddress(device); } } private void sendMessageToService(A2dpStackEvent event) { A2dpService service = A2dpService.getA2dpService(); Loading
android/app/src/com/android/bluetooth/a2dpsink/A2dpSinkNativeInterface.java +6 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.util.Log; import com.android.bluetooth.Utils; import com.android.bluetooth.btservice.AdapterService; import com.android.bluetooth.flags.Flags; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -85,8 +86,12 @@ public class A2dpSinkNativeInterface { } private byte[] getByteAddress(BluetoothDevice device) { if (Flags.identityAddressNullIfUnknown()) { return Utils.getByteBrEdrAddress(device); } else { return mAdapterService.getByteIdentityAddress(device); } } /** * Initiates an A2DP connection to a remote device. Loading
android/app/src/com/android/bluetooth/hfp/HeadsetNativeInterface.java +6 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.util.Log; import com.android.bluetooth.Utils; import com.android.bluetooth.btservice.AdapterService; import com.android.bluetooth.flags.Flags; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -91,8 +92,12 @@ public class HeadsetNativeInterface { // Set bt_stack's active device to default if java layer set active device to null return Utils.getBytesFromAddress("00:00:00:00:00:00"); } if (Flags.identityAddressNullIfUnknown()) { return Utils.getByteBrEdrAddress(device); } else { return mAdapterService.getByteIdentityAddress(device); } } void onConnectionStateChanged(int state, byte[] address) { HeadsetStackEvent event = Loading
android/app/src/com/android/bluetooth/hfpclient/NativeInterface.java +7 −1 Original line number Diff line number Diff line Loading @@ -23,7 +23,9 @@ package com.android.bluetooth.hfpclient; import android.bluetooth.BluetoothDevice; import android.util.Log; import com.android.bluetooth.Utils; import com.android.bluetooth.btservice.AdapterService; import com.android.bluetooth.flags.Flags; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -339,8 +341,12 @@ public class NativeInterface { } private byte[] getByteAddress(BluetoothDevice device) { if (Flags.identityAddressNullIfUnknown()) { return Utils.getByteBrEdrAddress(device); } else { return mAdapterService.getByteIdentityAddress(device); } } // Callbacks from the native back into the java framework. All callbacks are routed via the // Service which will disambiguate which state machine the message should be routed through. Loading