diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2015-03-09 14:07:59 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2015-03-09 14:07:59 -0700 |
commit | 23ead970f10b8f1d067346fb3aa65ffbdc123790 (patch) | |
tree | d4f88019ff339a073bd57baf8ac4f4f7e6cb02d8 | |
parent | 37e8129f7fa0416f3c5e6ca02db73f5ad873fb15 (diff) | |
parent | f52babbfd5429c53f84db8097ca7ebc89b07b598 (diff) | |
download | android_packages_apps_BluetoothExt-23ead970f10b8f1d067346fb3aa65ffbdc123790.tar.gz android_packages_apps_BluetoothExt-23ead970f10b8f1d067346fb3aa65ffbdc123790.tar.bz2 android_packages_apps_BluetoothExt-23ead970f10b8f1d067346fb3aa65ffbdc123790.zip |
Merge "Wipower-Bluetooth: Host Changes for advertisment offloading."
-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 ebd4cc4..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,11 +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 |