Merge "Bluetooth-Wipower: Cleanup activity for wipower on disconnect."
diff --git a/src/org/codeaurora/bluetooth/a4wp/A4wpService.java b/src/org/codeaurora/bluetooth/a4wp/A4wpService.java
index 85e8e0b..3b55e23 100644
--- a/src/org/codeaurora/bluetooth/a4wp/A4wpService.java
+++ b/src/org/codeaurora/bluetooth/a4wp/A4wpService.java
@@ -571,8 +571,10 @@
     private final BluetoothGattServerCallback mGattCallbacks = new BluetoothGattServerCallback() {
         @Override
         public void onConnectionStateChange(BluetoothDevice device, int status, int newState) {
+            WipowerState state = WipowerState.OFF;
             mState = newState;
-            if (mState == BluetoothProfile.STATE_DISCONNECTED) {
+            state = mWipowerManager.getState();
+            if ((mState == BluetoothProfile.STATE_DISCONNECTED) && state == WipowerState.ON) {
                 Log.v(LOGTAG, "onConnectionStateChange:DISCONNECTED " + device + "charge complete " + mChargeComplete);
                 if (mDevice != null && mWipowerManager != null) {
                     mWipowerManager.enableDataNotification(false);