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

Commit 7a4d9034 authored by Himanshu Rawat's avatar Himanshu Rawat
Browse files

Renaming some local variables for readability

Test: mmm packages/modules/Bluetooth
Bug: 322360482
Flag: EXEMPT no logical changes
Change-Id: I8692eeb502dc58f53a59f984837218ab109f98f3
parent 0c027b37
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;