if (!sBluetoothInterface) return result;
int ret = sBluetoothInterface->disable();
- result = (ret == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
+ /* Retrun JNI_FALSE only when BTIF explicitly reports
+ BT_STATUS_FAIL. It is fine for the BT_STATUS_NOT_READY
+ case which indicates that stack had not been enabled.
+ */
+ result = (ret == BT_STATUS_FAIL) ? JNI_FALSE : JNI_TRUE;
return result;
}
Log.w(TAG,"Timeout will setting scan mode..Continuing with disable...");
//Fall through
case BEGIN_DISABLE: {
- if (DBG) Log.d(TAG,"CURRENT_STATE=PENDING, MESSAGE = BEGIN_DISABLE" + isTurningOn + ", isTurningOff=" + isTurningOff);
+ if (DBG) Log.d(TAG,"CURRENT_STATE=PENDING, MESSAGE = BEGIN_DISABLE, isTurningOn=" + isTurningOn + ", isTurningOff=" + isTurningOff);
removeMessages(SET_SCAN_MODE_TIMEOUT);
sendMessageDelayed(DISABLE_TIMEOUT, DISABLE_TIMEOUT_DELAY);
boolean ret = mAdapterService.disableNative();
break;
case DISABLED:
if (DBG) Log.d(TAG,"CURRENT_STATE=PENDING, MESSAGE = DISABLED, isTurningOn=" + isTurningOn + ", isTurningOff=" + isTurningOff);
+ if (isTurningOn) {
+ removeMessages(ENABLE_TIMEOUT);
+ errorLog("Error enabling Bluetooth - hardware init failed");
+ mPendingCommandState.setTurningOn(false);
+ transitionTo(mOffState);
+ mAdapterService.stopProfileServices();
+ notifyAdapterStateChange(BluetoothAdapter.STATE_OFF);
+ break;
+ }
removeMessages(DISABLE_TIMEOUT);
sendMessageDelayed(STOP_TIMEOUT, STOP_TIMEOUT_DELAY);
if (mAdapterService.stopProfileServices()) {