diff options
author | Rob Seymour <rseymour@google.com> | 2022-04-02 03:52:13 +0000 |
---|---|---|
committer | Rob Seymour <rseymour@google.com> | 2022-04-02 04:01:22 +0000 |
commit | 4c7dc59bef24cc991251f9a7924ceada90c6bd63 (patch) | |
tree | a90550aa3ce1bc5e002ab6444c96954deca81af0 /service/java/com/android/server/bluetooth/BluetoothManagerService.java | |
parent | 6fa2bea006b362a285f744f65f15b5902e55797a (diff) | |
parent | dd4d23c4e1de011f8cd4eb132422172d5e283a73 (diff) |
Merge TP1A.220328.001
Change-Id: I5f07094ba2fb3991da03673f97d2957b1f68018b
Diffstat (limited to 'service/java/com/android/server/bluetooth/BluetoothManagerService.java')
-rw-r--r-- | service/java/com/android/server/bluetooth/BluetoothManagerService.java | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/service/java/com/android/server/bluetooth/BluetoothManagerService.java b/service/java/com/android/server/bluetooth/BluetoothManagerService.java index 6a1c28beb0..f02432679a 100644 --- a/service/java/com/android/server/bluetooth/BluetoothManagerService.java +++ b/service/java/com/android/server/bluetooth/BluetoothManagerService.java @@ -229,6 +229,7 @@ public class BluetoothManagerService extends IBluetoothManager.Stub { // used inside handler thread private boolean mQuietEnable = false; private boolean mEnable; + private boolean mShutdownInProgress = false; private static CharSequence timeToLog(long timestamp) { return android.text.format.DateFormat.format("MM-dd HH:mm:ss", timestamp); @@ -490,6 +491,23 @@ 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."); + mShutdownInProgress = true; + 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(); + } } } }; @@ -547,6 +565,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); @@ -2083,6 +2102,11 @@ public class BluetoothManagerService extends IBluetoothManager.Stub { case MESSAGE_ENABLE: int quietEnable = msg.arg1; int isBle = msg.arg2; + if (mShutdownInProgress) { + Log.d(TAG, "Skip Bluetooth Enable in device shutdown process"); + break; + } + if (mHandler.hasMessages(MESSAGE_HANDLE_DISABLE_DELAYED) || mHandler.hasMessages(MESSAGE_HANDLE_ENABLE_DELAYED)) { if (msg.arg2 == 0) { @@ -3274,7 +3298,7 @@ public class BluetoothManagerService extends IBluetoothManager.Stub { */ private void updateOppLauncherComponentState(UserHandle userHandle, boolean bluetoothSharingDisallowed) { - final ComponentName oppLauncherComponent = new ComponentName("com.android.bluetooth", + final ComponentName oppLauncherComponent = new ComponentName("com.android.bluetooth.services", "com.android.bluetooth.opp.BluetoothOppLauncherActivity"); final int newState = bluetoothSharingDisallowed ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED |