diff options
| author | 2020-10-13 16:29:15 -0700 | |
|---|---|---|
| committer | 2020-10-15 22:07:13 -0700 | |
| commit | b0bf27e7aeeb520da56e1f5fecf146283a2a128e (patch) | |
| tree | f3ba3393e941f7fc19bd02ec728ff730938d5669 | |
| parent | 543eaedd4de4d1bcc4a1aa6bf5b39a80d00dc571 (diff) | |
BluetoothDeviceConfigListener: Don't restart when connected
Similar to airplane mode change, don't send onInitFlagsChanged to
BluetoothManagerService when A2dp or Hearing aid is connected. Instead,
check after 24 hours.
Test: FrameworksServicesTests
Test: Push bluetooth INIT_ flags
Change-Id: Ib036852aa1cf8e3ddd87af7d17d16ad1c66c820e
| -rw-r--r-- | services/core/java/com/android/server/BluetoothManagerService.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java index cecf690171a8..e57d0f600c47 100644 --- a/services/core/java/com/android/server/BluetoothManagerService.java +++ b/services/core/java/com/android/server/BluetoothManagerService.java @@ -115,6 +115,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub { // Delay for retrying enable and disable in msec private static final int ENABLE_DISABLE_DELAY_MS = 300; private static final int DELAY_BEFORE_RESTART_DUE_TO_INIT_FLAGS_CHANGED_MS = 300; + private static final int DELAY_FOR_RETRY_INIT_FLAG_CHECK_MS = 86400; private static final int MESSAGE_ENABLE = 1; private static final int MESSAGE_DISABLE = 2; @@ -174,6 +175,8 @@ class BluetoothManagerService extends IBluetoothManager.Stub { private int mWaitForEnableRetry; private int mWaitForDisableRetry; + private BluetoothModeChangeHelper mBluetoothModeChangeHelper; + private BluetoothAirplaneModeListener mBluetoothAirplaneModeListener; private BluetoothDeviceConfigListener mBluetoothDeviceConfigListener; @@ -520,7 +523,6 @@ class BluetoothManagerService extends IBluetoothManager.Stub { Slog.w(TAG, "Unable to resolve SystemUI's UID."); } mSystemUiUid = systemUiUid; - mBluetoothDeviceConfigListener = new BluetoothDeviceConfigListener(this); } /** @@ -1350,12 +1352,12 @@ class BluetoothManagerService extends IBluetoothManager.Stub { Message getMsg = mHandler.obtainMessage(MESSAGE_GET_NAME_AND_ADDRESS); mHandler.sendMessage(getMsg); } - BluetoothModeChangeHelper bluetoothModeChangeHelper = - new BluetoothModeChangeHelper(mContext); + mBluetoothModeChangeHelper = new BluetoothModeChangeHelper(mContext); if (mBluetoothAirplaneModeListener != null) { - mBluetoothAirplaneModeListener.start(bluetoothModeChangeHelper); + mBluetoothAirplaneModeListener.start(mBluetoothModeChangeHelper); } + mBluetoothDeviceConfigListener = new BluetoothDeviceConfigListener(this); } /** @@ -2198,6 +2200,12 @@ class BluetoothManagerService extends IBluetoothManager.Stub { Slog.d(TAG, "MESSAGE_INIT_FLAGS_CHANGED"); } mHandler.removeMessages(MESSAGE_INIT_FLAGS_CHANGED); + if (mBluetoothModeChangeHelper.isA2dpOrHearingAidConnected()) { + mHandler.sendEmptyMessageDelayed( + MESSAGE_INIT_FLAGS_CHANGED, + DELAY_FOR_RETRY_INIT_FLAG_CHECK_MS); + break; + } if (mBluetooth != null && isEnabled()) { restartForReason( BluetoothProtoEnums.ENABLE_DISABLE_REASON_INIT_FLAGS_CHANGED); |