summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKiran Kelageri <kkelageri@codeaurora.org>2015-02-11 11:50:52 -0800
committerUmesh Vats <uvats@codeaurora.org>2015-03-10 13:10:34 -0700
commit460361bceb343b94e58d8e0ff3890eb417d97594 (patch)
treee29edbbae10ae47e51a23321c3e8f040ea07f7ce /src
parente3fe22741311649e28336fe4005f2a28f07f4d1e (diff)
downloadandroid_packages_apps_BluetoothExt-460361bceb343b94e58d8e0ff3890eb417d97594.tar.gz
android_packages_apps_BluetoothExt-460361bceb343b94e58d8e0ff3890eb417d97594.tar.bz2
android_packages_apps_BluetoothExt-460361bceb343b94e58d8e0ff3890eb417d97594.zip
Wipower-Bluetooth: Host Changes for advertisment offloading.
Advertisment is offloaded to firmware to accomodate A4WP spec timelines. Change-Id: I22426133f991073cb0571a0b7fc8c6c36aa43bdd CRs-fixed: 797885
Diffstat (limited to 'src')
-rw-r--r--src/org/codeaurora/bluetooth/a4wp/A4wpService.java57
1 files changed, 15 insertions, 42 deletions
diff --git a/src/org/codeaurora/bluetooth/a4wp/A4wpService.java b/src/org/codeaurora/bluetooth/a4wp/A4wpService.java
index 38e1116..978bb38 100644
--- a/src/org/codeaurora/bluetooth/a4wp/A4wpService.java
+++ b/src/org/codeaurora/bluetooth/a4wp/A4wpService.java
@@ -61,7 +61,6 @@ import com.quicinc.wbc.WbcManager;
import com.quicinc.wbc.WbcTypes;
import android.os.Handler;
import android.os.HandlerThread;
-import android.os.Looper;
import android.os.Message;
import android.bluetooth.le.AdvertiseCallback;
@@ -87,7 +86,6 @@ public class A4wpService extends Service
// Advertising variables
private final static int START_ADVERTISING = 1;
private final static int STOP_ADVERTISING = 0;
- private WipowerAdvHandler mHandler;
private static final UUID A4WP_SERVICE_UUID = UUID.fromString("6455fffe-a146-11e2-9e96-0800200c9a67");
//PRU writes
@@ -167,25 +165,6 @@ public class A4wpService extends Service
private AdvertiseCallback mAdvertiseCallback = new myAdvertiseCallback(1);
ParcelUuid uuid1 = ParcelUuid.fromString("6455fffe-a146-11e2-9e96-0800200c9a67");
- // Handler to maintain advertisement messages
- private final class WipowerAdvHandler extends Handler {
- private WipowerAdvHandler(Looper looper) {
- super(looper);
- }
-
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case START_ADVERTISING:
- StartAdvertising();
- break;
- case STOP_ADVERTISING:
- stopAdvertising();
- break;
- }
- }
- }
-
private WbcManager.WbcEventListener mWbcCallback = new WbcManager.WbcEventListener() {
@Override
@@ -535,9 +514,6 @@ public class A4wpService extends Service
acquire_wake_lock(true);
}
if (mOutputControl == true) {
- Log.v(LOGTAG, "StopAdvertising on connect");
- Message msg = mHandler.obtainMessage(STOP_ADVERTISING);
- mHandler.sendMessage(msg);
mWipowerManager.enableAlertNotification(false);
mWipowerManager.enableDataNotification(true);
}
@@ -601,6 +577,7 @@ public class A4wpService extends Service
@Override
public void onWipowerReady() {
Log.v(LOGTAG, "onWipowerReady");
+ mWipowerManager.enablePowerApply(false, false, false);
if (mChargeComplete == true) {
mWipowerManager.enablePowerApply(true, true, true);
} else {
@@ -616,12 +593,9 @@ public class A4wpService extends Service
@Override
public void onPowerApply(PowerApplyEvent state) {
- Log.v(LOGTAG, "onPowerApply" + state);
- if (state == PowerApplyEvent.ON) {
- Log.v(LOGTAG, "StartAdvertising");
- Message msg = mHandler.obtainMessage(START_ADVERTISING);
- mHandler.sendMessage(msg);
+ if (state == PowerApplyEvent.ON) {
+ Log.v(LOGTAG, "onPowerApply" + state);
} else {
if (mBluetoothGattServer != null && mDevice != null) {
Log.v(LOGTAG, "onPowerApply " + state + "dropping Connection");
@@ -780,6 +754,7 @@ public class A4wpService extends Service
}
else if(id == A4WP_PRU_STATIC_UUID)
{
+ mWipowerManager.enablePowerApply(false, false, false);
value = mPruStaticParam.getValue();
mDevice = device;
/* Initiate a dummy connection such that on stop advertisment
@@ -844,6 +819,14 @@ public class A4wpService extends Service
@Override
public void onStartSuccess(AdvertiseSettings settingsInEffect) {
Log.d(LOGTAG, "advertise success " + mIndex);
+ if (mWipowerManager != null) {
+ mWipowerManager.enablePowerApply(false, false, false);
+ if (mChargeComplete == true) {
+ mWipowerManager.enablePowerApply(true, true, true);
+ } else {
+ mWipowerManager.enablePowerApply(true, true, false);
+ }
+ }
}
@Override
@@ -871,8 +854,7 @@ public class A4wpService extends Service
mAdvertiseSettings = new AdvertiseSettings.Builder()
.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY)
.setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH)
- .setConnectable(true)
- .setTimeout(WIPOWER_ADV_TIMEOUT).build();
+ .setConnectable(true).build();
Log.d(LOGTAG, " Calling mAdvertiser.startAdvertising");
if(mAdvertiser != null)
@@ -946,6 +928,8 @@ public class A4wpService extends Service
mBluetoothGattServer.addService(a4wpService);
+ Log.d(LOGTAG, "calling StartAdvertising");
+ StartAdvertising();
return true;
}
@@ -977,11 +961,6 @@ public class A4wpService extends Service
Log.v(LOGTAG, "onCreate: charge complete " + mChargeComplete);
mWbcManager.register(mWbcCallback);
}
- // Starting a thread to handle the advertising
- HandlerThread thread = new HandlerThread("WipowerAdvHandler");
- thread.start();
- Looper looper = thread.getLooper();
- mHandler = new WipowerAdvHandler(looper);
}
@Override
@@ -995,12 +974,6 @@ public class A4wpService extends Service
//release wake lock during BT-OFF.
acquire_wake_lock(false);
}
-
- // Clear thread on destroy
- Looper looper = mHandler.getLooper();
- if (looper != null) {
- looper.quit();
- }
}
@Override