Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 71bdb54d authored by Christine Hallstrom's avatar Christine Hallstrom Committed by Gerrit Code Review
Browse files

Merge "Update profiles to consider null identity address" into main

parents baa8020f ded2cf89
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -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());
    }
+6 −1
Original line number Diff line number Diff line
@@ -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;

@@ -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();
+6 −1
Original line number Diff line number Diff line
@@ -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;

@@ -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.
+6 −1
Original line number Diff line number Diff line
@@ -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;

@@ -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 =
+7 −1
Original line number Diff line number Diff line
@@ -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;

@@ -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