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

Commit 974a0b43 authored by Manu Viswanadhan's avatar Manu Viswanadhan Committed by Gerrit - the friendly Code Review server
Browse files

Bluetooth: Fix broadcast receiver leak issue

Use Case: Repeated BT ON/OFF

Failure: Broadcast receiver leak is observed with ON/OFF stress
test which leads to broadcast receiver delays.

Steps:
BT ON/OFF.

Root Cause: During every ON-OFF there are brodacst receiver leaks
caused by repeated registering of profile intent receivers.

Fix: Deregister the broadcast receiver before the registering
profile intent receiver.

Change-Id: I5ca4fbaf654ced73e14260b27fbb2bdc4f23d334
CRs-Fixed: 1041552
parent b81e5ee8
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -120,6 +120,12 @@ public final class BluetoothEventManager {
        registerProfileIntentReceiver();
    }

    public void setDefaultReceiverHandler() {
        mContext.unregisterReceiver(mBroadcastReceiver);
        mContext.registerReceiver(mBroadcastReceiver, mAdapterIntentFilter, null, mReceiverHandler);
        registerProfileIntentReceiver();
    }

    /** Register to start receiving callbacks for Bluetooth events. */
    public void registerCallback(BluetoothCallback callback) {
        synchronized (mCallbacks) {
+1 −1
Original line number Diff line number Diff line
@@ -237,7 +237,7 @@ public final class LocalBluetoothProfileManager {
                "Warning: PBAP Client profile was previously added but the UUID is now missing.");
        }

        mEventManager.registerProfileIntentReceiver();
        mEventManager.setDefaultReceiverHandler();

        // There is no local SDP record for HID and Settings app doesn't control PBAP Server.
    }