sp<BluetoothAdapterStateMachine> spBtAdapterStateMachine = mBtAdapterStateMachine.promote();
CHECK_NULL_POINTER_RETURN(spBtAdapterStateMachine)
GLOGI("Enter PowerOff State: %d", spBtAdapterStateMachine->getCurrentMessage()->what);
}
case BluetoothAdapterStateMachine::TURN_HOT:
GLOGI("PowerOff State: TURN_HOT");
if (prepareBluetooth()) {
spBtAdapterStateMachine->transitionTo(spBtAdapterStateMachine->mWarmUp);
}
break;
default:
GLOGW("WarmUp State: default = %d", message->what);
return NOT_HANDLED;
case BluetoothAdapterStateMachine::SERVICE_RECORD_LOADED:
GLOGI("WarmUp State: SERVICE_RECORD_LOADED");
spBtAdapterStateMachine->removeMessages(BluetoothAdapterStateMachine::PREPARE_BLUETOOTH_TIMEOUT);
spBtAdapterStateMachine->transitionTo(spBtAdapterStateMachine->mHotOff);
if (spBtAdapterStateMachine->mDelayBroadcastStateOff) {
spBtAdapterStateMachine->broadcastState(BluetoothAdapter::STATE_OFF);
spBtAdapterStateMachine->mDelayBroadcastStateOff = false;
}
break;
case BluetoothAdapterStateMachine::POWER_STATE_CHANGED: {
GLOGI("Switching state: POWER_STATE_CHANGED");
spBtAdapterStateMachine->removeMessages(BluetoothAdapterStateMachine::TURN_OFF_TIMEOUT);
sp<Boolean> spBoolean = safe_cast<Boolean*>(message->obj.get());
if (spBoolean == NULL) {
break;
}
if (!(spBoolean->booleanValue())) {
if (spBtAdapterStateMachine->mPublicState == BluetoothAdapter::STATE_TURNING_OFF) {
#ifdef COS_BRCM_BT
spBtAdapterStateMachine->mBluetoothService->switchConnectable(false);
#endif // COS_BRCM_BT
spBtAdapterStateMachine->transitionTo(spBtAdapterStateMachine->mHotOff);
spBtAdapterStateMachine->mBluetoothService->finishDisable();
spBtAdapterStateMachine->mBluetoothService->cleanupAfterFinishDisable();
spBtAdapterStateMachine->deferMessage(spBtAdapterStateMachine->obtainMessage(BluetoothAdapterStateMachine::TURN_COLD));
#ifdef COS_BRCM_BT
if (BluetoothAdapterStateMachine::quickSwitch &&
#else
if (spBtAdapterStateMachine->mContext->getResources()->getBoolean
(com::gaia::internal::R::rbool::config_bluetooth_adapter_quick_switch) &&
#endif // COS_BRCM_BT
!spBtAdapterStateMachine->mBluetoothService->isAirplaneModeOn()) {
spBtAdapterStateMachine->deferMessage(spBtAdapterStateMachine->obtainMessage(BluetoothAdapterStateMachine::TURN_HOT));
spBtAdapterStateMachine->mDelayBroadcastStateOff = true;
}
}
} else {
if (spBtAdapterStateMachine->mPublicState != BluetoothAdapter::STATE_TURNING_ON) {
#ifdef COS_BRCM_BT
if (BluetoothAdapterStateMachine::quickSwitch) {
#else
if (spBtAdapterStateMachine->mContext->getResources()->getBoolean
(com::gaia::internal::R::rbool::config_bluetooth_adapter_quick_switch)) {
#endif // COS_BRCM_BT
spBtAdapterStateMachine->recoverStateMachine(BluetoothAdapterStateMachine::TURN_HOT, NULL);
} else {
spBtAdapterStateMachine->recoverStateMachine(BluetoothAdapterStateMachine::TURN_COLD, NULL);
}
}
}
break;
}
D/SuspendMonitor:delegateprocess( 661): TID:664 ...packages/SuspendMonitor/src/Monitor.cpp:166: Monitor::ScreenReceiver onReceive: android.intent.action.SCREEN_OFF
I/BT_Server( 344): TID:423 .../BluetoothAdapterStateMachine.cpp:617: BluetoothOn state: USER_TURN_OFF
case BluetoothAdapterStateMachine::USER_TURN_OFF: {
GLOGI("BluetoothOn state: USER_TURN_OFF");
sp<Boolean> spBoolean = safe_cast<Boolean*>(message->obj.get());
if (spBoolean == NULL) {
break;
}
if (spBoolean->booleanValue()) {
spBtAdapterStateMachine->persistSwitchSetting(false);
}
if (spBtAdapterStateMachine->mBluetoothService->isDiscovering()) {
spBtAdapterStateMachine->mBluetoothService->cancelDiscovery();
}
if (!spBtAdapterStateMachine->mBluetoothService->isApplicationStateChangeTrackerEmpty()) {
spBtAdapterStateMachine->transitionTo(spBtAdapterStateMachine->mPerProcessState);
spBtAdapterStateMachine->deferMessage(spBtAdapterStateMachine->obtainMessage(BluetoothAdapterStateMachine::TURN_HOT));
break;
}
// $FALL-THROUGH$ to AIRPLANE_MODE_ON
spBtAdapterStateMachine->broadcastState(BluetoothAdapter::STATE_TURNING_OFF);
spBtAdapterStateMachine->transitionTo(spBtAdapterStateMachine->mSwitching);
if (spBtAdapterStateMachine->mBluetoothService->getAdapterConnectionState() !=
BluetoothAdapter::STATE_DISCONNECTED) {
spBtAdapterStateMachine->mBluetoothService->disconnectDevices();
spBtAdapterStateMachine->sendMessageDelayed(BluetoothAdapterStateMachine::DEVICES_DISCONNECT_TIMEOUT,
BluetoothAdapterStateMachine::DEVICES_DISCONNECT_TIMEOUT_TIME);
} else {
spBtAdapterStateMachine->mBluetoothService->switchConnectable(false);
spBtAdapterStateMachine->sendMessageDelayed(BluetoothAdapterStateMachine::TURN_OFF_TIMEOUT, BluetoothAdapterStateMachine::TURN_OFF_TIMEOUT_TIME);
}
if (message->what == BluetoothAdapterStateMachine::AIRPLANE_MODE_ON || spBtAdapterStateMachine->mBluetoothService->isAirplaneModeOn()) {
// We inform all the per process callbacks
spBtAdapterStateMachine->allProcessesCallback(false);
}
break;
}
D/SuspendMonitor:delegateprocess( 661): TID:664 ...packages/SuspendMonitor/src/Monitor.cpp:166: Monitor::ScreenReceiver onReceive: android.intent.action.SCREEN_ON
I/ams ( 338): TID:589 .../ServiceRecord.cpp:118: ~ServiceRecord: BluetoothOppPbapService/.BluetoothOppService
I/BT_Server( 344): TID:423 .../BluetoothAdapterStateMachine.cpp:563: Switching state: USER_TURN_ON
I/BT_Server( 344): TID:423 .../BluetoothAdapterStateMachine.cpp:481: Switching state: POWER_STATE_CHANGED
case BluetoothAdapterStateMachine::POWER_STATE_CHANGED: {
GLOGI("Switching state: POWER_STATE_CHANGED");
spBtAdapterStateMachine->removeMessages(BluetoothAdapterStateMachine::TURN_OFF_TIMEOUT);
sp<Boolean> spBoolean = safe_cast<Boolean*>(message->obj.get());
if (spBoolean == NULL) {
break;
}
if (!(spBoolean->booleanValue())) {
if (spBtAdapterStateMachine->mPublicState == BluetoothAdapter::STATE_TURNING_OFF) {
#ifdef COS_BRCM_BT
spBtAdapterStateMachine->mBluetoothService->switchConnectable(false);
#endif // COS_BRCM_BT
spBtAdapterStateMachine->transitionTo(spBtAdapterStateMachine->mHotOff);
spBtAdapterStateMachine->mBluetoothService->finishDisable();
spBtAdapterStateMachine->mBluetoothService->cleanupAfterFinishDisable();
spBtAdapterStateMachine->deferMessage(spBtAdapterStateMachine->obtainMessage(BluetoothAdapterStateMachine::TURN_COLD));
#ifdef COS_BRCM_BT
if (BluetoothAdapterStateMachine::quickSwitch &&
#else
if (spBtAdapterStateMachine->mContext->getResources()->getBoolean
(com::gaia::internal::R::rbool::config_bluetooth_adapter_quick_switch) &&
#endif // COS_BRCM_BT
!spBtAdapterStateMachine->mBluetoothService->isAirplaneModeOn()) {
spBtAdapterStateMachine->deferMessage(spBtAdapterStateMachine->obtainMessage(BluetoothAdapterStateMachine::TURN_HOT));
spBtAdapterStateMachine->mDelayBroadcastStateOff = true;
}
}
} else {
if (spBtAdapterStateMachine->mPublicState != BluetoothAdapter::STATE_TURNING_ON) {
#ifdef COS_BRCM_BT
if (BluetoothAdapterStateMachine::quickSwitch) {
#else
if (spBtAdapterStateMachine->mContext->getResources()->getBoolean
(com::gaia::internal::R::rbool::config_bluetooth_adapter_quick_switch)) {
#endif // COS_BRCM_BT
spBtAdapterStateMachine->recoverStateMachine(BluetoothAdapterStateMachine::TURN_HOT, NULL);
} else {
spBtAdapterStateMachine->recoverStateMachine(BluetoothAdapterStateMachine::TURN_COLD, NULL);
}
}
}
break;
}
I/BT_Server( 344): TID:423 .../BluetoothAdapterStateMachine.cpp:342: HotOff state: USER_TURN_ON
I/BT_Server( 344): TID:423 .../BluetoothAdapterStateMachine.cpp:946: Bluetooth state 13 -> 11
case BluetoothAdapterStateMachine::USER_TURN_ON: {
GLOGI("HotOff state: USER_TURN_ON");
#ifdef COS_BRCM_BT
// Impossible to have this if quick switch not enabled
if (!BluetoothAdapterStateMachine::quickSwitch) {
spBtAdapterStateMachine->deferMessage(message);
break;
}
#endif // COS_BRCM_BT
spBtAdapterStateMachine->broadcastState(BluetoothAdapter::STATE_TURNING_ON);
sp<Boolean> spBoolean = safe_cast<Boolean*>(message->obj.get());
if (spBoolean == NULL) {
break;
}
if (spBoolean->booleanValue()) {
spBtAdapterStateMachine->persistSwitchSetting(true);
}
// let it fall to TURN_ON_CONTINUE:
// $FALL-THROUGH$
spBtAdapterStateMachine->mBluetoothService->switchConnectable(true);
spBtAdapterStateMachine->transitionTo(spBtAdapterStateMachine->mSwitching);
break;
}