diff options
| author | 2022-03-22 21:57:37 +0800 | |
|---|---|---|
| committer | 2022-03-25 08:47:46 +0000 | |
| commit | b20910f98972c2a99ed10c733ebdf59e34069f47 (patch) | |
| tree | 6ebcdc1f8fdef0c3278d4b5e2c1f07a269460d3b | |
| parent | c6c53dbf396dac484bbc3d0ccefc0b5bfdf4481a (diff) | |
[DO NOT MERGE] Handle SHUTDOWN Intent in BluetoothManagerService
Bug: 207521630
Test: reboot device and check log
Change-Id: I23f8bfb1c6d5fcf9a09c9baaa1b6555188fe0e2e
| -rw-r--r-- | services/core/java/com/android/server/BluetoothManagerService.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java index ff24c6f16c42..fb5900e7ea85 100644 --- a/services/core/java/com/android/server/BluetoothManagerService.java +++ b/services/core/java/com/android/server/BluetoothManagerService.java @@ -462,6 +462,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)) { + mBluetooth.onBrEdrDown(mContext.getAttributionSource()); + } else if (mBluetooth != null && (mState == BluetoothAdapter.STATE_ON)) { + mBluetooth.disable(mContext.getAttributionSource()); + } + } catch (RemoteException e) { + Slog.e(TAG, "Unable to shutdown Bluetooth", e); + } finally { + mBluetoothLock.readLock().unlock(); + } } } }; @@ -515,6 +531,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); |