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

Commit 0c6d13c9 authored by Hemant Gupta's avatar Hemant Gupta Committed by Myles Watson
Browse files

SAP: Prevent leak during turn off BT

Use Case:
1. Initiate SAP connection and disconnection from Remote Device.
2. Do this for 3-4 times
3. Do BT off, and check logs.

Error leak:
JHwRemoteBinder: BinderProxy is being destroyed but the application did not call unlinkToDeath to
   unlink all of its death recipients beforehand.  Releasing leaked death recipient:
   com.android.bluetooth.sap.SapRilReceiver$SapProxyDeathRecipient
BluetoothAdapterService: handleMessage() - Message: 1
BluetoothAdapterService: handleMessage() - MESSAGE_PROFILE_SERVICE_STATE_CHANGED
BluetoothAdapterService: processProfileServiceStateChanged() - serviceName=com.android.bluetooth.
 sap.SapService isTurningOn=false isTurningOff=true isBleTurningOn=false isBleTurningOff=false

Failure:
"Observed SAP Binder related leaks in log cat logs".

Fix:
Unlink previously linked death notification to avoid leak
in profile

Test: Checked after the above usecase to see if no memory leak error is seen in logs.

Bug: 62412151
Change-Id: Ic2a4d96c0a30c45eca08a65921693b386a193d69
parent 43356c73
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -242,6 +242,14 @@ public class SapRilReceiver {

    public void resetSapProxy() {
        synchronized (mSapProxyLock) {
            if (DEBUG) Log.d(TAG, "resetSapProxy :" + mSapProxy);
            try {
                if (mSapProxy != null) {
                    mSapProxy.unlinkToDeath(mSapProxyDeathRecipient);
                }
            } catch (RemoteException | RuntimeException e) {
                Log.e(TAG, "resetSapProxy: exception: " + e);
            }
            mSapProxy = null;
        }
    }