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

Commit 5b5bd513 authored by jonerlin's avatar jonerlin Committed by Joner Lin
Browse files

Do not allow Bluetooth enabling during device shutting down

Tag: #feature
Bug: 207521630
Test: reboot device in BLE_ON state, check log
Change-Id: Ia51355ae88919d81108a619e789c6d3415962231
Merged-In: I6330d2f94fe7a5ca582df83c9fa32c5c6cba5186
parent 753c7399
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -217,6 +217,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
    // used inside handler thread
    private boolean mQuietEnable = false;
    private boolean mEnable;
    private boolean mShutdownInProgress = false;

    private static CharSequence timeToLog(long timestamp) {
        return android.text.format.DateFormat.format("MM-dd HH:mm:ss", timestamp);
@@ -479,6 +480,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
                }
            } else if (action.equals(Intent.ACTION_SHUTDOWN)) {
                Slog.i(TAG, "Device is shutting down.");
                mShutdownInProgress = true;
                mBluetoothLock.readLock().lock();
                try {
                    mEnable = false;
@@ -1961,6 +1963,11 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
                case MESSAGE_ENABLE:
                    int quietEnable = msg.arg1;
                    int isBle  = msg.arg2;
                    if (mShutdownInProgress) {
                        Slog.i(TAG, "Skip Bluetooth Enable in device shutdown process");
                        break;
                    }

                    if (mHandler.hasMessages(MESSAGE_HANDLE_DISABLE_DELAYED)
                            || mHandler.hasMessages(MESSAGE_HANDLE_ENABLE_DELAYED)) {
                        // We are handling enable or disable right now, wait for it.