diff options
author | jonerlin <jonerlin@google.com> | 2022-03-23 06:34:37 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-03-23 06:34:37 +0000 |
commit | c8f48254d3c9894d38f837424e7e7f8322ec5fb3 (patch) | |
tree | 33e51e4a1523d4e9708191a8c491b1a362fe4bb9 /service/java/com/android/server/bluetooth/BluetoothManagerService.java | |
parent | 174d5aed696842bb3fcecb55c7cb7b309fd43e6f (diff) | |
parent | ce789ee6cfb5dcbdc3578c8a0c5022900f24399c (diff) |
Handle SHUTDOWN Intent in BluetoothManagerService am: 753c739998 am: ce789ee6cf
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2032223
Change-Id: Iba175a3044fa9a0090bc33a4efa818849dee2d66
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 73c35895a3..4786b2d027 100644 --- a/service/java/com/android/server/bluetooth/BluetoothManagerService.java +++ b/service/java/com/android/server/bluetooth/BluetoothManagerService.java @@ -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); |