diff options
author | Kiran Kelageri <kkelageri@codeaurora.org> | 2015-02-11 11:50:52 -0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2015-03-17 12:57:09 -0700 |
commit | ff21c6434930f700af072c0b2ab83ff324b9c48d (patch) | |
tree | bb66e98dfef1afad8622cb3f98aefff89185b1bc | |
parent | efab39f703c1033e22fd5693666c397930765ccf (diff) | |
download | android_packages_apps_BluetoothExt-ff21c6434930f700af072c0b2ab83ff324b9c48d.tar.gz android_packages_apps_BluetoothExt-ff21c6434930f700af072c0b2ab83ff324b9c48d.tar.bz2 android_packages_apps_BluetoothExt-ff21c6434930f700af072c0b2ab83ff324b9c48d.zip |
Wipower-Bluetooth: Host Changes for advertisment offloading.
Advertisment is offloaded to firmware to accomodate A4WP
spec timelines
Change-Id: I22426133f991073cb0571a0b7fc8c6c36aa43bdd
CRs-fixed: 797885
-rw-r--r-- | src/org/codeaurora/bluetooth/a4wp/A4wpService.java | 56 |
1 files changed, 15 insertions, 41 deletions
diff --git a/src/org/codeaurora/bluetooth/a4wp/A4wpService.java b/src/org/codeaurora/bluetooth/a4wp/A4wpService.java index 52f388f..d23c7eb 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"); @@ -803,6 +777,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 @@ -867,6 +842,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 @@ -894,8 +877,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) @@ -969,6 +951,8 @@ public class A4wpService extends Service mBluetoothGattServer.addService(a4wpService); + Log.d(LOGTAG, "calling StartAdvertising"); + StartAdvertising(); return true; } @@ -1001,11 +985,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 @@ -1019,11 +998,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 |