// Handle an incoming event message (timer expiration). // Return TRUE if the message was handled, otherwise FALSE. UtlBoolean PsButtonTask::handleEventMessage(const OsEventMsg& rMsg) { int index; PsButtonInfo* pButtonInfo; PsPhoneTask* pPhoneTask; UtlBoolean processed; OsTimer* pTimer; OsStatus res; OsWriteLock lock(mMutex); // acquire a write lock if (mpButtonInfo == NULL) // if not yet initialized, just return return FALSE; processed = TRUE; switch(rMsg.getMsgSubType()) { case OsEventMsg::NOTIFY: rMsg.getUserData(index); // get button index rMsg.getEventData((int&) pTimer); // get timer object assert(index > 0 && index <= mMaxBtnIdx); // check for valid index pButtonInfo = &mpButtonInfo[index]; // get ptr to button info // In order to send the phone set task a button repeat message, three // conditions must be satisfied: // 1) The button must currently be down // 2) The BUTTON_REPEAT event must be enabled for this button // 3) The pointers to the OsTimer object in the mpRepTimers array and // the event message must match (otherwise, we may be processing an // event message for an OsTimer object that has already be released. if ((pButtonInfo->getState() == PsButtonInfo::DOWN) && (pButtonInfo->getEventMask() & PsButtonInfo::BUTTON_REPEAT) && (mpRepTimers[index] == pTimer)) { // post msg to the phone set pPhoneTask = PsPhoneTask::getPhoneTask(); res = pPhoneTask->postEvent(PsMsg::BUTTON_REPEAT, // msg type this, // source index, // button index pButtonInfo->getId()); // button id assert(res == OS_SUCCESS); } break; default: processed = FALSE; // unexpected message subtype break; } return processed; }
// Handle an incoming event message (timer expiration). // Return TRUE if the message was handled, otherwise FALSE. // A write lock should be acquired before calling this method. UtlBoolean PsHookswTask::handleEventMessage(const OsEventMsg& rMsg) { int debounceInterval; int hookswState; PsPhoneTask* pPhoneTask; UtlBoolean processed; OsTimer* pTimer; OsStatus res; processed = TRUE; switch(rMsg.getMsgSubType()) { case OsEventMsg::NOTIFY: rMsg.getEventData((int&) pTimer); // get timer object assert(pTimer == mpTimer); hookswState = readHwHookswState();// determine HW hook state #ifdef HOOKSW_TEMP_HACK if (oldStyleHooksw) { if (hookswState == mHookswState) { // no change since last time, if (mHookswState == ON_HOOK) // enable the hooksw interrupt mpHookswDev->enableIntr(TRUE); // look for off hook else mpHookswDev->enableIntr(FALSE); // look for on hook } else { mHookswState = hookswState; // update the hookswitch state // Send a hookswitch message to the phone set with the new state pPhoneTask = PsPhoneTask::getPhoneTask(); res = pPhoneTask->postEvent(PsMsg::HOOKSW_STATE, // msg type this, // source mHookswState, // hooksw state 0); // not used assert(res == OS_SUCCESS); startDebounceTimer(); // rearm the debounce timer } } else { #endif mDebounceTicks++; switch (mDebounceState) { case SHORT_DEBOUNCE: case LONG_DEBOUNCE: debounceInterval = ((mDebounceState == SHORT_DEBOUNCE) ? SHORT_DEBOUNCE_MSECS : LONG_DEBOUNCE_MSECS); if (mDebounceHookswState != hookswState) // is state still bouncing? { mDebounceHookswState = hookswState; // stay in the current mDebounceTicks = 0; // state } if ((mDebounceTicks * DEBOUNCE_TIMER_MSECS) >= debounceInterval) { if (mDebounceHookswState != mHookswState) { mHookswState = hookswState; // update the hookswitch state // Send a hookswitch message to the phone set with the new state pPhoneTask = PsPhoneTask::getPhoneTask(); res = pPhoneTask->postEvent(PsMsg::HOOKSW_STATE, // msg type this, // source mHookswState, // hooksw state 0); // not used assert(res == OS_SUCCESS); mDebounceState = ((mDebounceState == SHORT_DEBOUNCE) ? LONG_DEBOUNCE : WAIT_FOR_INTR); mDebounceTicks = 0; } else { mDebounceState = WAIT_FOR_INTR;// enable the hooksw interrupt mDebounceTicks = 0; } } 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; }