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

Commit 4d7a7c81 authored by Himanshu Rawat's avatar Himanshu Rawat Committed by Gerrit Code Review
Browse files

Merge "Renaming some local variables for readability" into main

parents e98fd805 7a4d9034
Loading
Loading
Loading
Loading
+34 −27
Original line number Diff line number Diff line
@@ -668,41 +668,48 @@ class AdapterProperties {
        }
    }

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

        for (BluetoothDevice device : mBondedDevices) {
            String address = device.getAddress();
            String brEdrAddress =
        for (BluetoothDevice existingDevice : mBondedDevices) {
            String existingAddress = existingDevice.getAddress();
            String existingIdentityAddress =
                    Flags.identityAddressNullIfUnknown()
                            ? Utils.getBrEdrAddress(device, mService)
                            : mService.getIdentityAddress(address);
            if (currentBrEdrAddress.equals(brEdrAddress) && !currentAddress.equals(address)) {
                if (mService.getNative()
                        .removeBond(Utils.getBytesFromAddress(device.getAddress()))) {
                    mBondedDevices.remove(device);
                    infoLog("Removing old bond record: "
                                    + device
                                    + " for current device: "
                                    + currentDevice);
                            ? Utils.getBrEdrAddress(existingDevice, mService)
                            : mService.getIdentityAddress(existingAddress);

            if (!identityAddress.equals(existingIdentityAddress) || address.equals(
                existingAddress)) {
                continue;
            }

            // Found an existing device with same identity address but different pseudo address
            if (mService.getNative().removeBond(Utils.getBytesFromAddress(existingAddress))) {
                mBondedDevices.remove(existingDevice);
                infoLog(
                    "Removing old bond record: "
                        + existingDevice
                        + " for the device: "
                        + device);
            } else {
                    Log.e(TAG, "Unexpected error while removing old bond record:"
                                    + device
                                    + " for current device: "
                                    + currentDevice);
                Log.e(
                    TAG,
                    "Unexpected error while removing old bond record:"
                        + existingDevice
                        + " for the device: "
                        + device);
            }
            break;
        }
    }
    }

    int getDiscoverableTimeout() {
        return mDiscoverableTimeout;