summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKiran Kelageri <kkelageri@codeaurora.org>2014-11-10 16:29:48 -0800
committerKiran Kelageri <kkelageri@codeaurora.org>2014-11-11 14:15:40 -0800
commitfa677c0fe2aa52c0ea70eaf80d95796d03afc74f (patch)
tree984481baa821dfe831cf5e4a4ef3a913c7cc8c66
parent23872771fd7eb5c69199829261041d8ecf3a85ed (diff)
downloadandroid_packages_apps_BluetoothExt-fa677c0fe2aa52c0ea70eaf80d95796d03afc74f.tar.gz
android_packages_apps_BluetoothExt-fa677c0fe2aa52c0ea70eaf80d95796d03afc74f.tar.bz2
android_packages_apps_BluetoothExt-fa677c0fe2aa52c0ea70eaf80d95796d03afc74f.zip
Bluetooth-Wipower: Avoid advertisement on USB connect.
Following changes have been made: a> Advertisement seen after USB connection, Charge complete ensures power apply event is only triggered on 600ms long beacons. b> Limited mode advetisement interval is reduced to 5seconds. c> NULL validation been made to avoid unnecessary crashes. Change-Id: Ie9e31a905674b98a429dca5a25910d62a9f51150 CRs-fixed: 749930
-rw-r--r--src/org/codeaurora/bluetooth/a4wp/A4wpService.java28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/org/codeaurora/bluetooth/a4wp/A4wpService.java b/src/org/codeaurora/bluetooth/a4wp/A4wpService.java
index 7e9b7bb..6df222d 100644
--- a/src/org/codeaurora/bluetooth/a4wp/A4wpService.java
+++ b/src/org/codeaurora/bluetooth/a4wp/A4wpService.java
@@ -107,8 +107,8 @@ public class A4wpService extends Service
private static final int MSB_MASK = 0xFF00;
private static final int LSB_MASK= 0x00FF;
- //Timout value set to 30Sec which enures we advertise in lmited mode
- private static final int WIPOWER_ADV_TIMEOUT= 0x7530;
+ //Timeout value set to 5Sec which enures we advertise in limited mode
+ private static final int WIPOWER_ADV_TIMEOUT = 5000;
//PRU Write param length for validation
private static final byte A4WP_PTU_STATIC_LENGTH = 0x11;
@@ -437,15 +437,22 @@ public class A4wpService extends Service
Log.v(LOGTAG, "processPruControl>");
PruControl control = new PruControl(value);
control.print();
+
+ if (mWipowerManager == null) {
+ Log.e(LOGTAG, "mWipowerManager is null");
+ return status;
+ }
+
if (control.getEnablePruOutput()) {
Log.v(LOGTAG, "do Enable PruOutPut");
mWipowerManager.startCharging();
mWipowerManager.enableAlertNotification(false);
mWipowerManager.enableDataNotification(true);
- stopAdvertising();
- isConnected = true;
} else {
Log.v(LOGTAG, "do Disable PruOutPut");
+ if (mChargeComplete == true) {
+ mWipowerManager.enablePowerApply(true, true, true);
+ }
mWipowerManager.stopCharging();
mWipowerManager.enableDataNotification(false);
return status;
@@ -584,11 +591,10 @@ public class A4wpService extends Service
Log.v(LOGTAG, "onConnectionStateChange:DISCONNECTED " + device + "charge complete " + mChargeComplete);
isConnected = false;
if (mDevice != null && mWipowerManager != null) {
+ stopAdvertising();
mWipowerManager.enableDataNotification(false);
mWipowerManager.stopCharging();
- if (mChargeComplete == true) {
- mWipowerManager.enablePowerApply(true, true, true);
- } else {
+ if (mChargeComplete != true) {
mWipowerManager.enablePowerApply(true, true, false);
}
mDevice = null;
@@ -596,6 +602,9 @@ public class A4wpService extends Service
} else if (mState == BluetoothProfile.STATE_CONNECTED) {
Log.v(LOGTAG, "onConnectionStateChange:CONNECTED");
mDevice = device;
+ /* Initiate a dummy connection such that on stop advertisment
+ the advetisment instances are cleared properly */
+ mBluetoothGattServer.connect(mDevice, false);
}
}
@@ -639,7 +648,7 @@ public class A4wpService extends Service
else if(id == A4WP_PRU_STATIC_UUID)
{
value = mPruStaticParam.getValue();
- mBluetoothGattServer.connect(mDevice, false);
+ isConnected = true;
}
else if (id == A4WP_PRU_DYNAMIC_UUID) {
if (mPruDynamicParam == null) {
@@ -786,9 +795,6 @@ public class A4wpService extends Service
mBluetoothGattServer.addService(a4wpService);
- //Log.d(LOGTAG, "calling StartAdvertising");
- //StartAdvertising();
-
return true;
}