bluetooth: Fix bt on/off count flag handle
Bluedroid stack tries to turn off BT first every time
before it turns on BT, so the bt on/off count comes to
minus value. Fix the multiple times BT off counter to
0 always to handle it to make actual BT off happened.
Change-Id: I53203959325437d0b9f0277860d240a15d8465b8
diff --git a/libbt-vendor/src/bt_vendor_qcom.c b/libbt-vendor/src/bt_vendor_qcom.c
index c620fff..c4b0310 100755
--- a/libbt-vendor/src/bt_vendor_qcom.c
+++ b/libbt-vendor/src/bt_vendor_qcom.c
@@ -264,15 +264,16 @@
if (value == 1)
can_perform = true;
else if (value > 3)
- return false;
+ return false;
}
else {
ALOGV("%s: off : value is: %d", __func__, value);
- value--;
- if (value == 0)
- can_perform = true;
- else if (value < 0)
- return false;
+ if (--value <= 0) {
+ ALOGE("%s: BT turn off twice before BT On(ref_count=%d)\n",
+ __func__, value);
+ value = 0;
+ can_perform = true;
+ }
}
snprintf(ref_count, 3, "%d", value);