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

Commit 57479e1f authored by Zhihai Xu's avatar Zhihai Xu
Browse files

Bluetooth Application Crash while try to pairing with laptop - IKDVXPSE-345

the handleRegistration will never run after we shutdown the handler thread first,
with this change, we can make sure the mObserver will never be null
when call handleRegistration.
bug:11148404

Change-Id: I93b351915b49cf59a7d2026b7d83a68a7e76dd38
parent 154bcc84
Loading
Loading
Loading
Loading
+12 −9
Original line number Diff line number Diff line
@@ -113,6 +113,18 @@ public class BluetoothMnsObexClient {
    }

    public void disconnect() {
        /* should shutdown handler thread first to make sure
         * handleRegistration won't be called when disconnet
         */
        if (mHandler != null) {
            // Shut down the thread
            mHandler.removeCallbacksAndMessages(null);
            Looper looper = mHandler.getLooper();
            if (looper != null) {
                looper.quit();
            }
            mHandler = null;
        }
        try {
            if (mClientSession != null) {
                mClientSession.disconnect(null);
@@ -150,15 +162,6 @@ public class BluetoothMnsObexClient {
            mObserver.deinit();
            mObserver = null;
        }
        if (mHandler != null) {
            // Shut down the thread
            mHandler.removeCallbacksAndMessages(null);
            Looper looper = mHandler.getLooper();
            if (looper != null) {
                looper.quit();
            }
            mHandler = null;
        }
    }

    private HeaderSet hsConnect = null;