📄 pshookswtask.cpp
字号:
} break; case WAIT_FOR_INTR: // fall through default: assert(FALSE); break; } if (mDebounceState == WAIT_FOR_INTR) { if (mHookswState == ON_HOOK) // enable the hooksw interrupt mpHookswDev->enableIntr(TRUE); // look for off hook else mpHookswDev->enableIntr(FALSE); // look for on hook } else { startDebounceTimer(); }#ifdef HOOKSW_TEMP_HACK }#endif break; default: processed = FALSE; // unexpected message subtype break; } return processed;}// Handle an incoming hookswitch message (HOOKSW_OFF or HOOKSW_ON).// Return TRUE if the message was handled, otherwise FALSE.// A write lock should be acquired before calling this method.UtlBoolean PsHookswTask::handlePhoneMessage(const PsMsg& rMsg){ PsPhoneTask* pPhoneTask; UtlBoolean processed; OsStatus res; int state; state = rMsg.getParam1(); assert(state == OFF_HOOK || state == ON_HOOK); processed = TRUE; switch (rMsg.getMsg()) { case PsMsg::HOOKSW_STATE:#ifdef HOOKSW_TEMP_HACK if (oldStyleHooksw) { if (state != mHookswState) { mHookswState = state; // post message to the phone set pPhoneTask = PsPhoneTask::getPhoneTask(); res = pPhoneTask->postEvent(PsMsg::HOOKSW_STATE, // msg type this, // source mHookswState, // hooksw state 0); // not used assert(res == OS_SUCCESS); startDebounceTimer(); } else { // no hookswitch state change, just reenable the interrupt if (mHookswState == ON_HOOK) mpHookswDev->enableIntr(TRUE); // look for off hook else mpHookswDev->enableIntr(FALSE); // look for on hook } } else {#endif switch (mDebounceState) { case WAIT_FOR_INTR: // If the new hookswitch state differs from the old state, // then save the new state as mDebounceHookswState, // start the debounce timer and go to the SHORT_DEBOUNCE // debounce state. if (state != mHookswState) { mDebounceHookswState = state; mDebounceTicks = 0; mDebounceState = SHORT_DEBOUNCE; startDebounceTimer(); } else { // no hookswitch state change, just reenable the interrupt if (mHookswState == ON_HOOK) mpHookswDev->enableIntr(TRUE); // look for off hook else mpHookswDev->enableIntr(FALSE); // look for on hook } break; case SHORT_DEBOUNCE: case LONG_DEBOUNCE: default: // Hookswitch interrupts should be turned off while the phone // is in the SHORT_DEBOUNCE and LONG_DEBOUNCE states. As a result, // we shouldn't be calling this routine while the phone is in these // states. assert(FALSE); break; }#ifdef HOOKSW_TEMP_HACK }#endif break; case PsMsg::HOOKSW_SET_STATE:#ifdef HOOKSW_TEMP_HACK if (oldStyleHooksw) { if (state != mHookswState) { mHookswState = state; // post message to the phone set pPhoneTask = PsPhoneTask::getPhoneTask(); res = pPhoneTask->postEvent(PsMsg::HOOKSW_STATE, // msg type this, // source mHookswState, // hooksw state 0); // not used assert(res == OS_SUCCESS); startDebounceTimer(); } else { // no hookswitch state change, just reenable the interrupt if (mHookswState == ON_HOOK) mpHookswDev->enableIntr(TRUE); // look for off hook else mpHookswDev->enableIntr(FALSE); // look for on hook } } else {#endif if (state != mHookswState) { mHookswState = state; // post message to the phone set pPhoneTask = PsPhoneTask::getPhoneTask(); res = pPhoneTask->postEvent(PsMsg::HOOKSW_STATE, // msg type this, // source mHookswState, // hooksw state 0); // not used assert(res == OS_SUCCESS); }#ifdef HOOKSW_TEMP_HACK }#endif break; case PsMsg::HOOKSW_GET_STATE: { // post message to the phone set TaoPhoneComponentAdaptor *pObj = (TaoPhoneComponentAdaptor*) rMsg.getMsgSource(); TaoMessage *pMsg; pMsg = new TaoMessage(TaoMessage::COMPONENT_RESULT, TaoMessage::COMPONENT_RESULT, 0, 0, mHookswState, 0, ""); pObj->postMessage((OsMsg &) *pMsg); delete pMsg; } break; case PsMsg::HOOKSW_GET_CALL: // post message to the phone set pPhoneTask = PsPhoneTask::getPhoneTask(); res = pPhoneTask->postEvent(PsMsg::HOOKSW_GET_CALL, // msg type this, // source mHookswState, // hooksw state 0); // not used assert(res == OS_SUCCESS); // startDebounceTimer(); // ???: why is this here??? break; default: assert(FALSE); processed = FALSE; // unexpected message break; } if (rMsg.getSentFromISR()) // indicate that we are done with the msg ((PsMsg&) rMsg).setInUse(FALSE); return processed;}// Start the debounce timer for the hookswitchvoid PsHookswTask::startDebounceTimer(void){ OsStatus res; OsTime debounceTime(0, DEBOUNCE_TIMER_MSECS * 1000);#ifdef HOOKSW_TEMP_HACK OsTime debounceTime2(0, DEBOUNCE_MSECS * 1000);#endif res = mpTimer->stop(); // just in case the timer is already assert(res == OS_SUCCESS); // enabled, stop it first.#ifdef HOOKSW_TEMP_HACK if (oldStyleHooksw) res = mpTimer->oneshotAfter(debounceTime2); else#endif res = mpTimer->oneshotAfter(debounceTime); assert(res == OS_SUCCESS);}// Read the hookswitch state from the hardwareint PsHookswTask::readHwHookswState(void){ if (mpHookswDev->isOffHook()) return OFF_HOOK; else return ON_HOOK;}#ifdef HOOKSW_TEMP_HACKint setNewStyleHookswMode(void){ int mode = oldStyleHooksw; oldStyleHooksw = 0; return mode;}int setOldStyleHookswMode(void){ int mode = oldStyleHooksw; oldStyleHooksw = 1; return mode;}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -