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

Commit 5f4c5cce authored by Hansong Zhang's avatar Hansong Zhang
Browse files

AVRCP, HIDD: Fix crash if stop() is called before start()

Add a check for sInstance != null

Test: toggle airplane mode
Bug: 80193890
Change-Id: I92913858f387015791cfee9818112de81d2a5fb8
parent d9cd008e
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -657,6 +657,11 @@ public class HidDeviceService extends ProfileService {
            Log.d(TAG, "stop()");
            Log.d(TAG, "stop()");
        }
        }


        if (sHidDeviceService == null) {
            Log.w(TAG, "stop() called before start()");
            return true;
        }

        setHidDeviceService(null);
        setHidDeviceService(null);
        if (mNativeAvailable) {
        if (mNativeAvailable) {
            mHidDeviceNativeInterface.cleanup();
            mHidDeviceNativeInterface.cleanup();
+5 −0
Original line number Original line Diff line number Diff line
@@ -169,6 +169,11 @@ public class AvrcpTargetService extends ProfileService {
    protected boolean stop() {
    protected boolean stop() {
        Log.i(TAG, "Stopping the AVRCP Target Service");
        Log.i(TAG, "Stopping the AVRCP Target Service");


        if (sInstance == null) {
            Log.w(TAG, "stop() called before start()");
            return true;
        }

        sInstance = null;
        sInstance = null;
        unregisterReceiver(mReceiver);
        unregisterReceiver(mReceiver);