diff options
author | jonerlin <jonerlin@google.com> | 2022-03-19 00:31:28 +0800 |
---|---|---|
committer | Joner Lin <jonerlin@google.com> | 2022-03-23 02:20:45 +0000 |
commit | 753c739998ed4a369042cbe4522004e3263df105 (patch) | |
tree | 3f467111cd3027b96f59734a903a81bd2a2c266a /service/java/com/android/server/bluetooth/BluetoothManagerService.java | |
parent | 9f1113cf9409842560867d287ec007826cd83337 (diff) |
Handle SHUTDOWN Intent in BluetoothManagerService
Tag: #feature
Bug: 207521630
Test: reboot device and check log
Change-Id: I9dc8a561fd63545d75a1080402b972cd989c99a6
Merged-In: Ib30a5000ff1be24c276e673d096f67acb64136d6
Diffstat (limited to 'service/java/com/android/server/bluetooth/BluetoothManagerService.java')
-rw-r--r-- | service/java/com/android/server/bluetooth/BluetoothManagerService.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/service/java/com/android/server/bluetooth/BluetoothManagerService.java b/service/java/com/android/server/bluetooth/BluetoothManagerService.java index d6052aae95..8d248ea93c 100644 --- a/service/java/com/android/server/bluetooth/BluetoothManagerService.java +++ b/service/java/com/android/server/bluetooth/BluetoothManagerService.java @@ -477,6 +477,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(); + } } } }; @@ -536,6 +552,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); |