Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit da2faff5 authored by Brian Quezada's avatar Brian Quezada Committed by Android (Google) Code Review
Browse files

Merge "Fix dim duration on flip to screen off." into sc-dev

parents a6907d35 2dccad6f
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -322,6 +322,13 @@ public final class PowerManager {
     */
    public static final int USER_ACTIVITY_EVENT_ATTENTION = 4;

    /**
     * User activity event type: {@link com.android.server.power.FaceDownDetector} taking action
     * on behalf of user.
     * @hide
     */
    public static final int USER_ACTIVITY_EVENT_FACE_DOWN = 5;

    /**
     * User activity flag: If already dimmed, extend the dim timeout
     * but do not brighten.  This flag is useful for keeping the screen on
+4 −2
Original line number Diff line number Diff line
@@ -291,9 +291,11 @@ public class FaceDownDetector implements SensorEventListener {
     * The user interacted with the screen while face down, indicated the phone is in use.
     * We log this event and temporarily make this detector inactive.
     */
    public void userActivity() {
    public void userActivity(int event) {
        if (event != PowerManager.USER_ACTIVITY_EVENT_FACE_DOWN) {
            mHandler.post(mUserActivityRunnable);
        }
    }

    private void exitFaceDown(int resultType, long millisSinceFlip) {
        FrameworkStatsLog.write(FrameworkStatsLog.FACE_DOWN_REPORTED,
+4 −3
Original line number Diff line number Diff line
@@ -549,6 +549,7 @@ public class Notifier {
            if (!mUserActivityPending) {
                mUserActivityPending = true;
                Message msg = mHandler.obtainMessage(MSG_USER_ACTIVITY);
                msg.arg1 = event;
                msg.setAsynchronous(true);
                mHandler.sendMessage(msg);
            }
@@ -647,7 +648,7 @@ public class Notifier {
        mSuspendBlocker.release();
    }

    private void sendUserActivity() {
    private void sendUserActivity(int event) {
        synchronized (mLock) {
            if (!mUserActivityPending) {
                return;
@@ -657,7 +658,7 @@ public class Notifier {
        TelephonyManager tm = mContext.getSystemService(TelephonyManager.class);
        tm.notifyUserActivity();
        mPolicy.userActivity();
        mFaceDownDetector.userActivity();
        mFaceDownDetector.userActivity(event);
    }

    void postEnhancedDischargePredictionBroadcast(long delayMs) {
@@ -833,7 +834,7 @@ public class Notifier {
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case MSG_USER_ACTIVITY:
                    sendUserActivity();
                    sendUserActivity(msg.arg1);
                    break;
                case MSG_BROADCAST:
                    sendNextBroadcast();
+3 −4
Original line number Diff line number Diff line
@@ -180,8 +180,6 @@ public final class PowerManagerService extends SystemService
    private static final int DIRTY_VR_MODE_CHANGED = 1 << 13;
    // Dirty bit: attentive timer may have timed out
    private static final int DIRTY_ATTENTIVE = 1 << 14;
    // Dirty bit: phone flipped to face down
    private static final int DIRTY_FACE_DOWN = 1 << 15;
    // Dirty bit: display group power state has changed
    private static final int DIRTY_DISPLAY_GROUP_POWER_UPDATED = 1 << 16;

@@ -1069,8 +1067,9 @@ public final class PowerManagerService extends SystemService
                final long screenOffTimeout = getScreenOffTimeoutLocked(sleepTimeout, -1L);
                millisUntilNormalTimeout =
                        mLastUserActivityTime + screenOffTimeout - mClock.uptimeMillis();
                mDirty |= DIRTY_FACE_DOWN;
                updatePowerStateLocked();
                userActivityInternal(mClock.uptimeMillis(),
                        PowerManager.USER_ACTIVITY_EVENT_FACE_DOWN, /* flags= */0,
                        Process.SYSTEM_UID);
            }
        }
        if (isFaceDown) {