summaryrefslogtreecommitdiff
path: root/service/java
diff options
context:
space:
mode:
authorNitin Shivpure <quic_nshivpur@quicinc.com>2022-05-24 11:19:15 +0530
committerNitin Shivpure <quic_nshivpur@quicinc.com>2022-05-30 12:19:55 +0530
commita689ecba8e64e897fd2afa80a1a77bc4b2a23f27 (patch)
treea9d77bafda479f81848ffe059d8cd17ee831d850 /service/java
parent069e285284101391a6c2112620ccd700af8ecd71 (diff)
Bluetooth: Fix BT on failure during BT ON/OFF stress test
RCA: if MESSAGE_ENABLE is received & there is already a pending MESSAGE_ENABLE or MESSAGE_DISABLE in Handler queue, then isBle flag is not properly handled while requeuing the MESSAGE_ENABLE OR MESSAGE_DISABLE, which is causing BT ON failure during BT ON/OFF stress test Fix: - If MESSAGE_ENABLE is received & there is already a pending MESSAGE_ENABLE or MESSAGE_DISABLE in Handler queue, then Handling isBle flag properly while requeuing the MESSAGE_ENABLE or MESSAGE_DISABLE. - If MESSAGE_DISABLE is received & there is already a pending MESSAGE_ENABLE in Handler queue, then isBle value is set based on mExternalEnable while requeuing the MESSAGE_ENABLE. CRs-Fixed: 3201863 Change-Id: I010b01c106a7dbcb0f194557e719c90c67842b25
Diffstat (limited to 'service/java')
-rw-r--r--service/java/com/android/server/bluetooth/BluetoothManagerService.java26
1 files changed, 13 insertions, 13 deletions
diff --git a/service/java/com/android/server/bluetooth/BluetoothManagerService.java b/service/java/com/android/server/bluetooth/BluetoothManagerService.java
index 2ed44cd755..fb19c6f848 100644
--- a/service/java/com/android/server/bluetooth/BluetoothManagerService.java
+++ b/service/java/com/android/server/bluetooth/BluetoothManagerService.java
@@ -2134,7 +2134,9 @@ public class BluetoothManagerService extends IBluetoothManager.Stub {
case MESSAGE_ENABLE:
int quietEnable = msg.arg1;
- int isBle = msg.arg2;
+ int isBle = msg.arg2;
+
+ Log.d(TAG, "MESSAGE_ENABLE: isBle: " + isBle + " msg.obj : " + msg.obj);
if (mShutdownInProgress) {
Log.d(TAG, "Skip Bluetooth Enable in device shutdown process");
break;
@@ -2142,7 +2144,7 @@ public class BluetoothManagerService extends IBluetoothManager.Stub {
if (mHandler.hasMessages(MESSAGE_HANDLE_DISABLE_DELAYED)
|| mHandler.hasMessages(MESSAGE_HANDLE_ENABLE_DELAYED)) {
- if (msg.arg2 == 0) {
+ if (msg.obj == null) {
int delay = ENABLE_DISABLE_DELAY_MS;
if (mHandler.hasMessages(MESSAGE_DISABLE)) {
@@ -2153,26 +2155,26 @@ public class BluetoothManagerService extends IBluetoothManager.Stub {
mHandler.removeMessages(MESSAGE_ENABLE);
// We are handling enable or disable right now, wait for it.
mHandler.sendMessageDelayed(mHandler.obtainMessage(
- MESSAGE_ENABLE, quietEnable, 1), delay);
+ MESSAGE_ENABLE, quietEnable, isBle, 1), delay);
Log.d(TAG, "Queue new MESSAGE_ENABLE");
} else {
mHandler.sendMessageDelayed(mHandler.obtainMessage(
- MESSAGE_ENABLE, quietEnable, isBle), ENABLE_DISABLE_DELAY_MS);
+ MESSAGE_ENABLE, quietEnable, isBle, 1), ENABLE_DISABLE_DELAY_MS);
Log.d(TAG, "Re-Queue previous MESSAGE_ENABLE");
if (mHandler.hasMessages(MESSAGE_DISABLE)) {
// Ensure the original order of just entering the queue
// if MESSAGE_DISABLE present
mHandler.removeMessages(MESSAGE_DISABLE);
mHandler.sendMessageDelayed(mHandler.obtainMessage(
- MESSAGE_DISABLE, 0, isBle), ENABLE_DISABLE_DELAY_MS * 2);
+ MESSAGE_DISABLE, 0, 1), ENABLE_DISABLE_DELAY_MS * 2);
Log.d(TAG, "Re-Queue previous MESSAGE_DISABLE");
}
}
break;
- } else if(msg.arg2 == 0 && mHandler.hasMessages(MESSAGE_DISABLE)) {
+ } else if(msg.obj == null && mHandler.hasMessages(MESSAGE_DISABLE)) {
mHandler.removeMessages(MESSAGE_ENABLE);
mHandler.sendMessageDelayed(mHandler.obtainMessage(
- MESSAGE_ENABLE, quietEnable, isBle), ENABLE_DISABLE_DELAY_MS * 2);
+ MESSAGE_ENABLE, quietEnable, isBle, 1), ENABLE_DISABLE_DELAY_MS * 2);
Log.d(TAG, "MESSAGE_DISABLE exist. Queue new MESSAGE_ENABLE");
break;
}
@@ -2197,9 +2199,7 @@ public class BluetoothManagerService extends IBluetoothManager.Stub {
int state = synchronousGetState();
switch (state) {
case BluetoothAdapter.STATE_BLE_ON:
- if (isBle == 1) {
- Log.i(TAG, "Already at BLE_ON State");
- } else if (isBluetoothPersistedStateOnBluetooth() ||
+ if (isBluetoothPersistedStateOnBluetooth() ||
mEnableExternal) {
Log.w(TAG, "BLE_ON State:Enable from Settings or" +
"BT on persisted, going to ON");
@@ -2211,7 +2211,7 @@ public class BluetoothManagerService extends IBluetoothManager.Stub {
// waive WRITE_SECURE_SETTINGS permission check
long callingIdentity = Binder.clearCallingIdentity();
Binder.restoreCallingIdentity(callingIdentity);
- } else {
+ } else if (isBle == 1) {
Log.w(TAG, "BLE_ON State:Queued enable from ble app," +
" stay in ble on");
}
@@ -2286,8 +2286,8 @@ public class BluetoothManagerService extends IBluetoothManager.Stub {
// if MESSAGE_DISABLE present
mHandler.removeMessages(MESSAGE_ENABLE);
mHandler.sendMessageDelayed(mHandler.obtainMessage(
- MESSAGE_ENABLE, mQuietEnableExternal ? 1: 0, 1),
- ENABLE_DISABLE_DELAY_MS * 2);
+ MESSAGE_ENABLE, mQuietEnableExternal ? 1: 0,
+ mEnableExternal ? 0:1, 1), ENABLE_DISABLE_DELAY_MS * 2);
Log.d(TAG, "Re-Queue previous MESSAGE_ENABLE");
}
}