src/activitymanager/activity/Activity.cpp
/*
 * If scheduled, remove from the queue.
 */
If scheduled, remove from the queue.
If scheduled remove from the queue .
void Activity::endActivity()
{
    LOG_AM_TRACE("Entering function %s", __FUNCTION__);
    LOG_AM_DEBUG("[Activity %llu] Ending", m_id);
    if (!m_ending) {
        m_ending = true;
        ActivityManager::getInstance().informActivityEnding(shared_from_this());
    }
    bool requeue = shouldRequeue();
    if (!m_subscriptions.empty()) {
        return;
    }
    if (m_powerActivity &&
            (m_powerActivity->getPowerState() != AbstractPowerActivity::kPowerUnlocked)) {
        PowerManager::getInstance().requestEndPowerActivity(shared_from_this());
    } else if (m_persistCommands.empty()) {
        ActivityManager::getInstance().informActivityEnd(shared_from_this());
        if (requeue) {
            requeueActivity();
        } else {
            bool restart = shouldRestart();
            if (restart) {
                restartActivity();
            } else {
                ActivityManager::getInstance().releaseActivity(shared_from_this());
            }
        }
    }
}
void Activity :: endActivity ( ) { LOG_AM_TRACE ( " " , __FUNCTION__ ) ; LOG_AM_DEBUG ( " " , m_id ) ; if ( ! m_ending ) { m_ending = true ; ActivityManager :: getInstance ( ) . informActivityEnding ( shared_from_this ( ) ) ; } bool requeue = shouldRequeue ( ) ; if ( ! m_subscriptions . empty ( ) ) { return ; } if ( m_powerActivity && ( m_powerActivity -> getPowerState ( ) != AbstractPowerActivity :: kPowerUnlocked ) ) { PowerManager :: getInstance ( ) . requestEndPowerActivity ( shared_from_this ( ) ) ; } else if ( m_persistCommands . empty ( ) ) { ActivityManager :: getInstance ( ) . informActivityEnd ( shared_from_this ( ) ) ; if ( requeue ) { requeueActivity ( ) ; } else { bool restart = shouldRestart ( ) ; if ( restart ) { restartActivity ( ) ; } else { ActivityManager :: getInstance ( ) . releaseActivity ( shared_from_this ( ) ) ; } } } }
If scheduled, remove from the queue.
If scheduled remove from the queue .
/* If there are no subscriptions, and power unlock is not still pending,
     * check for restart, otherwise unregister. */ /* If the power is still locked on, begin unlock and wait for it to
     * complete.  This may result in the function being called
     * immediately from End() if direct power unlock is possible.
     * That's ok.
     *
     * Note: Power unlock shouldn't be initiated until after all the
     * subscribers exit
     */ /* Don't move on to restarting (a potentially updated Activity)
         * until the updates have gone through. */ /* It's ok for the Activity to restart after this.  Just let the
         * Activity Manager know that that this incarnation of the Activity
         * is done */