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

Commit efd99d77 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Handle null identity address in BluetoothOppHandoverReceiver and...

Merge "Handle null identity address in BluetoothOppHandoverReceiver and AdapterProperties" into main am: 57450b0b

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/3002559



Change-Id: I0c6159bed6df31dc6d13530988298d9e80d3d432
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 76c86d14 57450b0b
Loading
Loading
Loading
Loading
+26 −9
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ import androidx.annotation.VisibleForTesting;
import com.android.bluetooth.BluetoothStatsLog;
import com.android.bluetooth.Utils;
import com.android.bluetooth.btservice.RemoteDevices.DeviceProperties;
import com.android.bluetooth.flags.Flags;
import com.android.modules.utils.build.SdkLevel;

import com.google.common.collect.EvictingQueue;
@@ -671,16 +672,22 @@ class AdapterProperties {

    void cleanupPrevBondRecordsFor(BluetoothDevice currentDevice) {
        String currentAddress = currentDevice.getAddress();
        String currentIdentityAddress = mService.getIdentityAddress(currentAddress);
        String currentBrEdrAddress =
                Flags.identityAddressNullIfUnknown()
                        ? Utils.getBrEdrAddress(currentDevice)
                        : mService.getIdentityAddress(currentAddress);
        debugLog("cleanupPrevBondRecordsFor: " + currentDevice);
        if (currentIdentityAddress == null) {
        if (currentBrEdrAddress == null) {
            return;
        }

        for (BluetoothDevice device : mBondedDevices) {
            String address = device.getAddress();
            String identityAddress = mService.getIdentityAddress(address);
            if (currentIdentityAddress.equals(identityAddress) && !currentAddress.equals(address)) {
            String brEdrAddress =
                    Flags.identityAddressNullIfUnknown()
                            ? Utils.getBrEdrAddress(device)
                            : mService.getIdentityAddress(address);
            if (currentBrEdrAddress.equals(brEdrAddress) && !currentAddress.equals(address)) {
                if (mService.getNative()
                        .removeBond(Utils.getBytesFromAddress(device.getAddress()))) {
                    mBondedDevices.remove(device);
@@ -1239,15 +1246,25 @@ class AdapterProperties {
        StringBuilder sb = new StringBuilder();
        for (BluetoothDevice device : mBondedDevices) {
            String address = device.getAddress();
            String identityAddress = mService.getIdentityAddress(address);
            if (identityAddress.equals(address)) {
            String brEdrAddress =
                    Flags.identityAddressNullIfUnknown()
                            ? Utils.getBrEdrAddress(device)
                            : mService.getIdentityAddress(address);
            if (brEdrAddress.equals(address)) {
                writer.println("    " + address
                            + " [" + dumpDeviceType(device.getType()) + "] "
                            + Utils.getName(device));
            } else {
                sb.append("    " + address + " => " + identityAddress
                            + " [" + dumpDeviceType(device.getType()) + "] "
                            + Utils.getName(device) + "\n");
                sb.append(
                        "    "
                                + address
                                + " => "
                                + brEdrAddress
                                + " ["
                                + dumpDeviceType(device.getType())
                                + "] "
                                + Utils.getName(device)
                                + "\n");
            }
        }
        writer.println(sb.toString());
+8 −2
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import android.net.Uri;
import android.util.Log;

import com.android.bluetooth.BluetoothMethodProxy;
import com.android.bluetooth.Utils;
import com.android.bluetooth.flags.Flags;

import java.util.ArrayList;

@@ -83,10 +85,14 @@ public class BluetoothOppHandoverReceiver extends BroadcastReceiver {
            if (device == null) {
                return;
            }
            String brEdrAddress =
                    Flags.identityAddressNullIfUnknown()
                            ? Utils.getBrEdrAddress(device)
                            : device.getIdentityAddress();
            if (D) {
                Log.d(TAG, "Adding " + device.getIdentityAddress() + " to acceptlist");
                Log.d(TAG, "Adding " + brEdrAddress + " to acceptlist");
            }
            BluetoothOppManager.getInstance(context).addToAcceptlist(device.getIdentityAddress());
            BluetoothOppManager.getInstance(context).addToAcceptlist(brEdrAddress);
        } else if (action.equals(Constants.ACTION_STOP_HANDOVER)) {
            int id = intent.getIntExtra(Constants.EXTRA_BT_OPP_TRANSFER_ID, -1);
            if (id != -1) {