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

Commit 3029fbed authored by Roopa Sattiraju's avatar Roopa Sattiraju Committed by Automerger Merge Worker
Browse files

Merge "Deleting Handler and dropping queued messages to prevent any crash...

Merge "Deleting Handler and dropping queued messages to prevent any crash during stop of state machine/services." into main am: aa3aa48c

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2747196



Change-Id: If171e23d2989821e948e35ebfd7b3e602e9dc52a
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 087c007b aa3aa48c
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -259,6 +259,11 @@ public class A2dpService extends ProfileService {
                // Do not rethrow as we are shutting down anyway
            }
        }
        if (mHandler != null) {
            mHandler.removeCallbacksAndMessages(null);
            mHandler = null;
        }

        // Step 2: Reset maximum number of connected audio devices
        mMaxConnectedAudioDevices = 1;

+11 −3
Original line number Diff line number Diff line
@@ -302,6 +302,10 @@ public class BassClientService extends ProfileService {
        mDatabaseManager = Objects.requireNonNull(mAdapterService.getDatabase(),
                "DatabaseManager cannot be null when BassClientService starts");
        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

        // Setup Handler to handle local broadcast use cases.
        mHandler = new Handler(Looper.getMainLooper());

        mStateMachines.clear();
        mStateMachinesThread = new HandlerThread("BassClientService.StateMachines");
        mStateMachinesThread.start();
@@ -309,9 +313,6 @@ public class BassClientService extends ProfileService {
        mCallbackHandlerThread.start();
        mCallbacks = new Callbacks(mCallbackHandlerThread.getLooper());

        // Setup Handler to handle local broadcast use cases.
        mHandler = new Handler(Looper.getMainLooper());

        IntentFilter filter = new IntentFilter();
        filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
        filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
@@ -349,6 +350,7 @@ public class BassClientService extends ProfileService {
        if (DBG) {
            Log.d(TAG, "stop()");
        }

        synchronized (mStateMachines) {
            for (BassClientStateMachine sm : mStateMachines.values()) {
                BassObjectsFactory.getInstance().destroyStateMachine(sm);
@@ -364,6 +366,12 @@ public class BassClientService extends ProfileService {
            mStateMachinesThread = null;
        }

        // Unregister Handler and stop all queued messages.
        if (mHandler != null) {
            mHandler.removeCallbacksAndMessages(null);
            mHandler = null;
        }

        if (mIntentReceiver != null) {
            unregisterReceiver(mIntentReceiver);
            mIntentReceiver = null;
+7 −0
Original line number Diff line number Diff line
@@ -275,6 +275,13 @@ class AdapterProperties {
    public void cleanup() {
        mRemoteDevices = null;
        mProfileConnectionState.clear();

        // Unregister Handler and stop all queued messages.
        if (mHandler != null) {
            mHandler.removeCallbacksAndMessages(null);
            mHandler = null;
        }

        if (mReceiverRegistered) {
            mService.unregisterReceiver(mReceiver);
            mReceiverRegistered = false;
+5 −0
Original line number Diff line number Diff line
@@ -180,6 +180,11 @@ public class RemoteDevices {
            mSdpTracker.clear();
        }

        // Unregister Handler and stop all queued messages.
        if (mMainHandler != null) {
            mMainHandler.removeCallbacksAndMessages(null);
        }

        synchronized (mDevices) {
            if (mDevices != null) {
                debugLog("reset(): Broadcasting ACL_DISCONNECTED");
+6 −0
Original line number Diff line number Diff line
@@ -214,6 +214,12 @@ public class CsipSetCoordinatorService extends ProfileService {
            }
        }

        // Unregister Handler and stop all queued messages.
        if (mHandler != null) {
            mHandler.removeCallbacksAndMessages(null);
            mHandler = null;
        }

        mDeviceGroupIdRankMap.clear();
        mCallbacks.clear();
        mFoundSetMemberToGroupId.clear();
Loading