summaryrefslogtreecommitdiff
path: root/service/java/com/android/server/bluetooth/BluetoothManagerService.java
diff options
context:
space:
mode:
authorjonerlin <jonerlin@google.com>2022-03-21 18:04:47 +0800
committerjonerlin <jonerlin@google.com>2022-03-21 18:19:44 +0800
commitc1d74f61dee3092e472124d913ac2d7b75b179c3 (patch)
treee210760e0b2f48c21e4fb5d2cf3ca4568e00cb39 /service/java/com/android/server/bluetooth/BluetoothManagerService.java
parentdcdc839adfa40a546d473aad1858c916e6824340 (diff)
Handle SHUTDOWN Intent in BluetoothManagerService
Tag: #feature Bug: 207521630 Test: reboot device and check log Ignore-AOSP-First: Conflict with internal Change-Id: Ib30a5000ff1be24c276e673d096f67acb64136d6
Diffstat (limited to 'service/java/com/android/server/bluetooth/BluetoothManagerService.java')
-rw-r--r--service/java/com/android/server/bluetooth/BluetoothManagerService.java17
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 5e27ee66d9..fb99e1cd08 100644
--- a/service/java/com/android/server/bluetooth/BluetoothManagerService.java
+++ b/service/java/com/android/server/bluetooth/BluetoothManagerService.java
@@ -484,6 +484,22 @@ public class BluetoothManagerService extends IBluetoothManager.Stub {
Log.i(TAG, "Device disconnected, reactivating pending flag changes");
onInitFlagsChanged();
}
+ } else if (action.equals(Intent.ACTION_SHUTDOWN)) {
+ Log.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) {
+ Log.e(TAG, "Unable to shutdown Bluetooth", e);
+ } finally {
+ mBluetoothLock.readLock().unlock();
+ }
}
}
};
@@ -540,6 +556,7 @@ public 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);