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

Commit c8f48254 authored by jonerlin's avatar jonerlin Committed by Automerger Merge Worker
Browse files

Handle SHUTDOWN Intent in BluetoothManagerService am: 753c7399 am: ce789ee6

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

Change-Id: Iba175a3044fa9a0090bc33a4efa818849dee2d66
parents 174d5aed ce789ee6
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -473,6 +473,22 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
                    Slog.i(TAG, "Device disconnected, reactivating pending flag changes");
                    onInitFlagsChanged();
                }
            } else if (action.equals(Intent.ACTION_SHUTDOWN)) {
                Slog.i(TAG, "Device is shutting down.");
                mBluetoothLock.readLock().lock();
                try {
                    mEnable = false;
                    mEnableExternal = false;
                    if (mBluetooth != null && (mState == BluetoothAdapter.STATE_BLE_ON)) {
                        synchronousOnBrEdrDown(mContext.getAttributionSource());
                    } else if (mBluetooth != null && (mState == BluetoothAdapter.STATE_ON)) {
                        synchronousDisable(mContext.getAttributionSource());
                    }
                } catch (RemoteException | TimeoutException e) {
                    Slog.e(TAG, "Unable to shutdown Bluetooth", e);
                } finally {
                    mBluetoothLock.readLock().unlock();
                }
            }
        }
    };
@@ -532,6 +548,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
        filter.addAction(Intent.ACTION_SETTING_RESTORED);
        filter.addAction(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED);
        filter.addAction(BluetoothHearingAid.ACTION_CONNECTION_STATE_CHANGED);
        filter.addAction(Intent.ACTION_SHUTDOWN);
        filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
        mContext.registerReceiver(mReceiver, filter);