summaryrefslogtreecommitdiff
path: root/service/java/com/android/server/bluetooth/BluetoothManagerService.java
diff options
context:
space:
mode:
Diffstat (limited to 'service/java/com/android/server/bluetooth/BluetoothManagerService.java')
-rw-r--r--service/java/com/android/server/bluetooth/BluetoothManagerService.java26
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