diff options
author | Umesh Vats <uvats@codeaurora.org> | 2015-03-13 13:56:24 -0700 |
---|---|---|
committer | Umesh Vats <uvats@codeaurora.org> | 2015-03-16 21:52:17 -0700 |
commit | 5ab41c42cf90b30b1d8a70735b0c918eaa2fdc7f (patch) | |
tree | 2e8f45807540f8245900b597a5a47e09bf9ad3c8 | |
parent | 4097edec4cce2b31a649ccff37f402a1bbcd57b3 (diff) | |
download | android_packages_apps_BluetoothExt-5ab41c42cf90b30b1d8a70735b0c918eaa2fdc7f.tar.gz android_packages_apps_BluetoothExt-5ab41c42cf90b30b1d8a70735b0c918eaa2fdc7f.tar.bz2 android_packages_apps_BluetoothExt-5ab41c42cf90b30b1d8a70735b0c918eaa2fdc7f.zip |
Bluetooth-WiPower: Prevent duplicate power apply commands, send PRU alert
notifications only in connected state, don't release
the wake lock when disable charge output is received
1. WBC driver can generate spurious/duplicate Wipower charge complete
events. BT FW can get into bad state if host sends power apply command
in the connected state. To prevent this, additional checkks are being
added.
2. PRU alerts should be sent only if PRU is connected to PTU. Otherwise,
crashes can result in race conditions.
3. Wake lock should not be released when "Disable Charge Port" command
is received from PTU. Otherwise, PRU can get into deeper sleep state
resulting in timeouts at PTU for dynamic parameter reads. This will
in turn cause BLE connection to be terminated.
CRs-Fixed: 807683
Change-Id: I01edd435f031e41a1544641ac232d09a0a44ac75
-rw-r--r-- | src/org/codeaurora/bluetooth/a4wp/A4wpService.java | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/org/codeaurora/bluetooth/a4wp/A4wpService.java b/src/org/codeaurora/bluetooth/a4wp/A4wpService.java index f517206..3d0f1de 100644 --- a/src/org/codeaurora/bluetooth/a4wp/A4wpService.java +++ b/src/org/codeaurora/bluetooth/a4wp/A4wpService.java @@ -186,7 +186,8 @@ public class A4wpService extends Service // We could be in 600mS scan state here and since charging needs to be resumed // send enable power apply command to scan for short beacons */ mChargeComplete = false; - mWipowerManager.enablePowerApply(true, true, false); + if ((mState == BluetoothProfile.STATE_DISCONNECTED) && (mWipowerManager != null)) + mWipowerManager.enablePowerApply(true, true, false); } } Log.v(LOGTAG, "onWbcEventUpdate: charge complete " + mChargeComplete); @@ -370,6 +371,19 @@ public class A4wpService extends Service return status; } + if (mDevice == null) + { + Log.v(LOGTAG, "sendPruAlert. mDevice is NULL"); + return status; + } + + if (mState != BluetoothProfile.STATE_CONNECTED) + { + Log.v(LOGTAG, "sendPruAlert. Not CONNECTED"); + return status; + } + + alertVal[0] = alertValue; mPruAlertChar.setValue(alertVal); mBluetoothGattServer.notifyCharacteristicChanged(mDevice, @@ -587,9 +601,6 @@ public class A4wpService extends Service mWipowerManager.enablePowerApply(true, true, true); } mWipowerManager.stopCharging(); - if(SystemProperties.getBoolean("persist.a4wp.skipwakelock", false) == false) { - acquire_wake_lock(false); - } isChargePortSet = false; mOutputControl = false; return status; @@ -697,10 +708,10 @@ public class A4wpService extends Service @Override public void onConnectionStateChange(BluetoothDevice device, int status, int newState) { WipowerState state = WipowerState.OFF; - mState = newState; - if (mState == BluetoothProfile.STATE_DISCONNECTED) { + if (newState == BluetoothProfile.STATE_DISCONNECTED) { if (mWipowerManager != null && device.equals(mDevice)) { - Log.v(LOGTAG, "onConnectionStateChange:DISCONNECTED " + device + "charge complete " + mChargeComplete); + Log.v(LOGTAG, "onConnectionStateChange:DISCONNECTED PrevState:" + " Device:" + device + " ChargeComplete:" + mChargeComplete); + mState = newState; mWipowerManager.enableDataNotification(false); mWipowerManager.stopCharging(); if (mChargeComplete != true) { @@ -713,7 +724,7 @@ public class A4wpService extends Service mDevice = null; } isChargePortSet = false; - } else if (mState == BluetoothProfile.STATE_CONNECTED) { + } else if (newState == BluetoothProfile.STATE_CONNECTED) { Log.v(LOGTAG, "onConnectionStateChange:CONNECTED"); } } @@ -828,6 +839,7 @@ public class A4wpService extends Service mWipowerManager.enablePowerApply(false, false, false); value = mPruStaticParam.getValue(); mDevice = device; + mState = BluetoothProfile.STATE_CONNECTED; /* Initiate a dummy connection such that on stop advertisment the advetisment instances are cleared properly */ mBluetoothGattServer.connect(mDevice, false); |