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

Commit 57450b0b authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

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

Merge "Handle null identity address in BluetoothOppHandoverReceiver and AdapterProperties" into main
parents c2276030 a349d7a9
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) {