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

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

Merge "Prevent profiles from initiating connection while the device is removed" into main

parents 5109637a e17229ac
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2700,6 +2700,7 @@ public class AdapterService extends Service {
            }
            service.logUserBondResponse(device, false, source);
            service.mBondAttemptCallerInfo.remove(device.getAddress());
            service.mPhonePolicy.onRemoveBondRequest(device);
            deviceProp.setBondingInitiatedLocally(false);

            Message msg = service.mBondStateMachine.obtainMessage(BondStateMachine.REMOVE_BOND);
+26 −0
Original line number Diff line number Diff line
@@ -1148,6 +1148,32 @@ public class PhonePolicy implements AdapterService.BluetoothStateCallback {
        }
    }

    /**
     * Resets the service connection policies for the device. This is called when the {@link
     * BluetoothDevice#removeBond} is requested for the device.
     *
     * @param device is the remote device whose services have been discovered
     */
    void onRemoveBondRequest(BluetoothDevice device) {
        if (!Flags.preventServiceConnectionsOnRemoveBond()) {
            return;
        }

        debugLog("onRemoveBondRequest: Disabling all profiles for " + device);
        // Don't allow any profiles to connect to the device.
        for (int profileId = BluetoothProfile.HEADSET;
                profileId < BluetoothProfile.MAX_PROFILE_ID;
                profileId++) {
            if (mAdapterService.getDatabase().getProfileConnectionPolicy(device, profileId)
                    == BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
                mAdapterService
                        .getDatabase()
                        .setProfileConnectionPolicy(
                                device, profileId, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN);
            }
        }
    }

    private static void debugLog(String msg) {
        Log.d(TAG, msg);
    }
+0 −1
Original line number Diff line number Diff line
@@ -349,7 +349,6 @@ public class DatabaseManager {
     *     BluetoothProfile.CONNECTION_POLICY_FORBIDDEN}, {@link
     *     BluetoothProfile.CONNECTION_POLICY_ALLOWED}
     */
    @VisibleForTesting
    public boolean setProfileConnectionPolicy(
            BluetoothDevice device, int profile, int newConnectionPolicy) {
        if (device == null) {