Android standby status update

Source: Internet
Author: User

Android standby status update

The standby status of Android is managedPowerManagerService. javaManagement

The main status update method is to post the code below, and the comments are clearly written. The first time I saw the system source code, I felt pretty good.

Update wake-up, screen sleep, and other statuses. Then, the system performs some operations based on the updated status, such as system sleep, screen saver, or power mode change.

 

 

 /**     * Updates the global power state based on dirty bits recorded in mDirty.     *     * This is the main function that performs power state transitions.     * We centralize them here so that we can recompute the power state completely     * each time something important changes, and ensure that we do it the same     * way each time.  The point is to gather all of the transition logic here.     */    private void updatePowerStateLocked() {        if (!mSystemReady || mDirty == 0) {            return;        }        if (!Thread.holdsLock(mLock)) {            Slog.wtf(TAG, "Power manager lock was not held when calling updatePowerStateLocked");        }        // Phase 0: Basic state updates.        updateIsPoweredLocked(mDirty);        updateStayOnLocked(mDirty);        // Phase 1: Update wakefulness.        // Loop because the wake lock and user activity computations are influenced        // by changes in wakefulness.        final long now = SystemClock.uptimeMillis();        int dirtyPhase2 = 0;        for (;;) {            int dirtyPhase1 = mDirty;            dirtyPhase2 |= dirtyPhase1;            mDirty = 0;            updateWakeLockSummaryLocked(dirtyPhase1);            updateUserActivitySummaryLocked(now, dirtyPhase1);            if (!updateWakefulnessLocked(dirtyPhase1)) {                break;            }        }        // Phase 2: Update dreams and display power state.        updateDreamLocked(dirtyPhase2);        updateDisplayPowerStateLocked(dirtyPhase2);        // Phase 3: Send notifications, if needed.        if (mDisplayReady) {            sendPendingNotificationsLocked();        }        // Phase 4: Update suspend blocker.        // Because we might release the last suspend blocker here, we need to make sure        // we finished everything else first!        updateSuspendBlockerLocked();    }

The updatePowerStateLocked () method is called in the following ways:

 

It can be found that, after receiving some System Broadcasts, call (Methods Starting with handle) and call (Methods Starting with set) after system settings to update the power status, there are also some interface callbacks, mainly for some user operations


First, the public callback method is used. The callback method transmits the task to the Internal private method (ending with Internal) and the received native METHOD (ending with Native ), the last step is to call updatePowerStateLocked () to update the status through the method ending with Locked.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.