From c1d74f61dee3092e472124d913ac2d7b75b179c3 Mon Sep 17 00:00:00 2001 From: jonerlin Date: Mon, 21 Mar 2022 18:04:47 +0800 Subject: Handle SHUTDOWN Intent in BluetoothManagerService Tag: #feature Bug: 207521630 Test: reboot device and check log Ignore-AOSP-First: Conflict with internal Change-Id: Ib30a5000ff1be24c276e673d096f67acb64136d6 --- .../server/bluetooth/BluetoothManagerService.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'service/java/com/android/server/bluetooth/BluetoothManagerService.java') 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); -- cgit v1.2.3 From bfa86649dfa21bd80d719ea4e57749e59216b20f Mon Sep 17 00:00:00 2001 From: jonerlin Date: Mon, 21 Mar 2022 18:28:01 +0800 Subject: Do not allow Bluetooth enabling during device shutting down Tag: #feature Bug: 207521630 Test: reboot device in BLE_ON state, check log Ignore-AOSP-First: Conflict with internal Change-Id: I6330d2f94fe7a5ca582df83c9fa32c5c6cba5186 --- .../java/com/android/server/bluetooth/BluetoothManagerService.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'service/java/com/android/server/bluetooth/BluetoothManagerService.java') diff --git a/service/java/com/android/server/bluetooth/BluetoothManagerService.java b/service/java/com/android/server/bluetooth/BluetoothManagerService.java index fb99e1cd08..d1ae0fce31 100644 --- a/service/java/com/android/server/bluetooth/BluetoothManagerService.java +++ b/service/java/com/android/server/bluetooth/BluetoothManagerService.java @@ -226,6 +226,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); @@ -486,6 +487,7 @@ public class BluetoothManagerService extends IBluetoothManager.Stub { } } else if (action.equals(Intent.ACTION_SHUTDOWN)) { Log.i(TAG, "Device is shutting down."); + mShutdownInProgress = true; mBluetoothLock.readLock().lock(); try { mEnable = false; @@ -1921,6 +1923,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)) { // We are handling enable or disable right now, wait for it. -- cgit v1.2.3 From fef9c6b3979eee12c80e619f13014140592dc4bd Mon Sep 17 00:00:00 2001 From: Roopa Sattiraju Date: Fri, 18 Mar 2022 17:14:37 -0700 Subject: Changing apk name in the manifest and the corresponding packages. BUG: 226403247 Test: TH Change-Id: I060dd05cf722a4185f85f4f1e231b63ae1508cb4 --- service/java/com/android/server/bluetooth/BluetoothManagerService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'service/java/com/android/server/bluetooth/BluetoothManagerService.java') diff --git a/service/java/com/android/server/bluetooth/BluetoothManagerService.java b/service/java/com/android/server/bluetooth/BluetoothManagerService.java index d1ae0fce31..a1ea210609 100644 --- a/service/java/com/android/server/bluetooth/BluetoothManagerService.java +++ b/service/java/com/android/server/bluetooth/BluetoothManagerService.java @@ -2846,7 +2846,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 -- cgit v1.2.3