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

Commit 6470d3a3 authored by Liana Kazanova (xWF)'s avatar Liana Kazanova (xWF) Committed by Android (Google) Code Review
Browse files

Revert "Separately timing out different power groups"

This reverts commit 0898a10e.

Reason for revert: DroidMonitor: Potential culprit for http://b/419803718 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted

Bug: 419803718
Change-Id: Iad351023fa2eb55751ee97ddf626c06f7e845670
parent 0898a10e
Loading
Loading
Loading
Loading
+1 −11
Original line number Diff line number Diff line
@@ -208,22 +208,12 @@ public abstract class PowerManagerInternal {

    public abstract void uidIdle(int uid);

    /**
     * Checks if the wakefulness of the supplied group is interactive.
     */
    public abstract boolean isGroupInteractive(int groupId);

    /** Returns if any of the default adjacent group is interactive. */
    public abstract boolean isAnyDefaultAdjacentGroupInteractive();

    /** Returns if the supplied group is adjacent to the default group. */
    public abstract boolean isDefaultGroupAdjacent(int groupId);

    /**
     * Used to notify the power manager that wakelocks should be disabled.
     *
     * @param force {@code true} to activate force disable wakelocks, {@code false} to turn it off.
     */

    public abstract void setForceDisableWakelocks(boolean force);

    /**
+7 −7
Original line number Diff line number Diff line
@@ -1099,12 +1099,14 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
            decidedGroupId = calculateGroupId(requiredGroupType, mDisplayGroups);
            groupName = requiredGroupType;
        }

        // Get the new display group if a change is needed, if display group name is empty and
        // {@code DisplayDeviceInfo.FLAG_OWN_DISPLAY_GROUP} is not set, and required group type
        // has not been decided, the display is assigned to the default display group.
        final boolean needsOwnDisplayGroup =
                (displayDeviceInfo.flags & DisplayDeviceInfo.FLAG_OWN_DISPLAY_GROUP) != 0
                        || !TextUtils.isEmpty(groupName);

        final boolean hasOwnDisplayGroup = groupId != Display.DEFAULT_DISPLAY_GROUP;
        final boolean needsDeviceDisplayGroup =
                !needsOwnDisplayGroup && linkedDeviceUniqueId != null;
@@ -1115,7 +1117,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
                || hasDeviceDisplayGroup != needsDeviceDisplayGroup
                || decidedGroupId != Display.INVALID_DISPLAY_GROUP) {
            groupId =
                    assignDisplayGroupIdLocked(needsDeviceDisplayGroup, needsOwnDisplayGroup,
                    assignDisplayGroupIdLocked(needsOwnDisplayGroup,
                            display.getLayoutGroupNameLocked(), needsDeviceDisplayGroup,
                            linkedDeviceUniqueId, decidedGroupId);
        }
@@ -1129,9 +1131,8 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {

            int reason = mDisplayGroupAllocator.getContentModeForDisplayLocked(
                    display, displayDeviceInfo.type);
            if (groupId != Display.DEFAULT_DISPLAY_GROUP
                    && (reason == REASON_PROJECTED || reason == REASON_EXTENDED
                    || reason == REASON_NON_DESKTOP)) {
            if (reason == REASON_PROJECTED || reason == REASON_EXTENDED
                    || reason == REASON_NON_DESKTOP) {
                newGroup.setFlags(DisplayGroup.FLAG_DEFAULT_GROUP_ADJACENT);
            }
        }
@@ -1342,10 +1343,9 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
        }
    }

    private int assignDisplayGroupIdLocked(boolean needsDeviceDisplayGroup,
            boolean isOwnDisplayGroup, String displayGroupName,
    private int assignDisplayGroupIdLocked(boolean isOwnDisplayGroup, String displayGroupName,
            boolean isDeviceDisplayGroup, Integer linkedDeviceUniqueId, int decidedGroupId) {
        if (decidedGroupId != Display.INVALID_DISPLAY_GROUP && !needsDeviceDisplayGroup) {
        if (decidedGroupId != Display.INVALID_DISPLAY_GROUP) {
            return decidedGroupId;
        }
        if (isDeviceDisplayGroup && linkedDeviceUniqueId != null) {
+10 −54
Original line number Diff line number Diff line
@@ -1329,11 +1329,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            }
        }

        goToSleep(eventTime, PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, flags);
        sleepDefaultDisplay(eventTime, PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, flags);
        return true;
    }

    private void goToSleep(long eventTime, int reason, int flags) {
    private void sleepDefaultDisplay(long eventTime, int reason, int flags) {
        mRequestedOrSleepingDefaultDisplay = true;
        mPowerManager.goToSleep(eventTime, reason, flags);
    }
@@ -1371,7 +1371,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                            Settings.Global.THEATER_MODE_ON, 1);

                    if (mGoToSleepOnButtonPressTheaterMode && interactive) {
                        goToSleep(eventTime, PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON,
                        sleepDefaultDisplay(eventTime, PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON,
                                0);
                    }
                }
@@ -1544,7 +1544,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            case SHORT_PRESS_SLEEP_GO_TO_SLEEP:
            case SHORT_PRESS_SLEEP_GO_TO_SLEEP_AND_GO_HOME:
                Slog.i(TAG, "sleepRelease() calling goToSleep(GO_TO_SLEEP_REASON_SLEEP_BUTTON)");
                goToSleep(eventTime, PowerManager.GO_TO_SLEEP_REASON_SLEEP_BUTTON, 0);
                sleepDefaultDisplay(eventTime, PowerManager.GO_TO_SLEEP_REASON_SLEEP_BUTTON, 0);
                break;
        }
    }
@@ -4637,7 +4637,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                            }
                            if ((mEndcallBehavior
                                    & Settings.System.END_BUTTON_BEHAVIOR_SLEEP) != 0) {
                                goToSleep(event.getEventTime(),
                                sleepDefaultDisplay(event.getEventTime(),
                                        PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, 0);
                                isWakeKey = false;
                            }
@@ -5288,45 +5288,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        mDeviceGoingToSleep = false;
    }

    // Both the default and default adjacent groups should be non interactive
    private boolean isReadyToSignalSleep(int displayGroupId) {
        if (!com.android.server.display.feature.flags.Flags.separateTimeouts()) {
            return displayGroupId == Display.DEFAULT_DISPLAY_GROUP;
        }

        // We only care about default and default-adjacent groups
        if (displayGroupId != Display.DEFAULT_DISPLAY_GROUP
                && !mPowerManagerInternal.isDefaultGroupAdjacent(displayGroupId)) {
            return false;
        }

        boolean areAllDefaultAdjacentGroupsNonInteractive =
                !mPowerManagerInternal.isAnyDefaultAdjacentGroupInteractive();
        boolean isDefaultGroupNonInteractive =
                !mPowerManagerInternal.isGroupInteractive(DEFAULT_DISPLAY);
        return areAllDefaultAdjacentGroupsNonInteractive && isDefaultGroupNonInteractive;
    }

    // Either of the default or default adjacent groups should be interactive
    private boolean isReadyToSignalWakeup(int displayGroupId) {
        if (!com.android.server.display.feature.flags.Flags.separateTimeouts()) {
            return displayGroupId == Display.DEFAULT_DISPLAY_GROUP;
        }

        // We only care about default and default-adjacent groups
        if (displayGroupId != Display.DEFAULT_DISPLAY_GROUP
                && !mPowerManagerInternal.isDefaultGroupAdjacent(displayGroupId)) {
            return false;
        }

        boolean isAnyDefaultAdjacentGroupInteractive =
                mPowerManagerInternal.isAnyDefaultAdjacentGroupInteractive();
        boolean isDefaultGroupInteractive = mPowerManagerInternal
                .isGroupInteractive(DEFAULT_DISPLAY);

        return isAnyDefaultAdjacentGroupInteractive || isDefaultGroupInteractive;
    }

    // Called on the PowerManager's Notifier thread.
    @Override
    public void startedGoingToSleep(int displayGroupId,
@@ -5337,8 +5298,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                            WindowManagerPolicyConstants.translateSleepReasonToOffReason(
                                    pmSleepReason)) + ")");
        }

        if (!isReadyToSignalSleep(displayGroupId)) {
        if (displayGroupId != Display.DEFAULT_DISPLAY_GROUP) {
            return;
        }

@@ -5354,10 +5314,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    @Override
    public void finishedGoingToSleep(int displayGroupId,
            @PowerManager.GoToSleepReason int pmSleepReason) {
        if (!isReadyToSignalSleep(displayGroupId)) {
        if (displayGroupId != Display.DEFAULT_DISPLAY_GROUP) {
            return;
        }

        EventLogTags.writeScreenToggled(0);
        if (DEBUG_WAKEUP) {
            Slog.i(TAG, "Finished going to sleep... (groupId=" + displayGroupId + " why="
@@ -5399,11 +5358,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    WindowManagerPolicyConstants.translateWakeReasonToOnReason(
                            pmWakeReason)) + ")");
        }

        if (!isReadyToSignalWakeup(displayGroupId)) {
        if (displayGroupId != Display.DEFAULT_DISPLAY_GROUP) {
            return;
        }

        EventLogTags.writeScreenToggled(1);

        mIsGoingToSleepDefaultDisplay = false;
@@ -5435,8 +5392,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                            WindowManagerPolicyConstants.translateWakeReasonToOnReason(
                                    pmWakeReason)) + ")");
        }

        if (!isReadyToSignalWakeup(displayGroupId)) {
        if (displayGroupId != Display.DEFAULT_DISPLAY_GROUP) {
            return;
        }

@@ -6101,7 +6057,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    mWindowManagerFuncs.lockDeviceNow();
                    break;
                case LID_BEHAVIOR_SLEEP:
                    goToSleep(SystemClock.uptimeMillis(),
                    sleepDefaultDisplay(SystemClock.uptimeMillis(),
                            PowerManager.GO_TO_SLEEP_REASON_LID_SWITCH,
                            PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE);
                    break;
+3 −62
Original line number Diff line number Diff line
@@ -107,8 +107,6 @@ public class PowerGroup {
    private final long mDimDuration;
    private final long mScreenOffTimeout;

    private boolean mDreamManagerAttemptedDreaming;

    PowerGroup(int groupId, PowerGroupListener wakefulnessListener, Notifier notifier,
            DisplayManagerInternal displayManagerInternal, int wakefulness, boolean ready,
            boolean supportsSandman, long eventTime, PowerManagerFlags featureFlags,
@@ -213,12 +211,6 @@ public class PowerGroup {
                    mLastSleepReason = reason;
                }
            }

            // Since the group is transitioning to interactive wakefulness, we should reset the
            // previous attempt of dream made by DreamManager
            if (newWakefulness == WAKEFULNESS_AWAKE) {
                setDreamManagerAttemptedDreamingLocked(/* dreamManagerAttemptedDreaming */ false);
            }
            mWakefulness = newWakefulness;
            mWakefulnessListener.onWakefulnessChangedLocked(mGroupId, mWakefulness, eventTime,
                    reason, uid, opUid, opPackageName, details);
@@ -227,43 +219,6 @@ public class PowerGroup {
        return false;
    }

    /**
     * Indicates if the power group already attempted to dream by the DreamManagerService. This
     * doesn't necessarily indicate that the group is dreaming, as DreamManagerService might
     * have failed
     */
    public boolean dreamManagerAttemptedDreamingLocked() {
        return mDreamManagerAttemptedDreaming;
    }

    /**
     * Sets the dreamManagerAttemptedDreaming status, indicating if the DreamManager attempted to
     * put the group to dream. This being true doesn't necessarily mean that the group is dreaming
     * as it can fail in that attempt
     * @param dreamManagerAttemptedDreaming
     */
    public void setDreamManagerAttemptedDreamingLocked(boolean dreamManagerAttemptedDreaming) {
        Slog.i(TAG, "dreamManagerAttemptedDreaming status changed to "
                + dreamManagerAttemptedDreaming + " for group " + mGroupId);
        mDreamManagerAttemptedDreaming = dreamManagerAttemptedDreaming;
    }

    public boolean isDefaultOrAdjacentGroup() {
        return isDefaultGroupAdjacent() || getGroupId() == Display.DEFAULT_DISPLAY_GROUP;
    }

    /**
     * A group can transition from sleep to doze
     * 1. It is a default display
     * 2. com.android.server.display.feature.flags.Flags.separateTimeouts() is enabled
     * 3. Is non interactive
     */
    public boolean canTransitionBetweenNonInteractiveStates() {
        return (com.android.server.display.feature.flags.Flags.separateTimeouts())
                && (getGroupId() == Display.DEFAULT_DISPLAY_GROUP)
                && !isInteractive(getWakefulnessLocked());
    }

    /**
     * Returns {@code true} if every display in this group has its requested state matching
     * its actual state.
@@ -303,7 +258,8 @@ public class PowerGroup {
        return mPoweringOn;
    }

    public boolean isDefaultGroupAdjacent() {
    @VisibleForTesting
    boolean isDefaultGroupAdjacent() {
        return mIsDefaultGroupAdjacent;
    }

@@ -368,20 +324,7 @@ public class PowerGroup {
    }

    boolean dozeLocked(long eventTime, int uid, @PowerManager.GoToSleepReason int reason) {
        return dozeLocked(eventTime, uid, reason, false);
    }

    boolean dozeLocked(long eventTime, int uid, @PowerManager.GoToSleepReason int reason,
            boolean allowSleepToDozeTransition) {
        if (!com.android.server.display.feature.flags.Flags.separateTimeouts()) {
            allowSleepToDozeTransition = false;
        }

        if (eventTime < getLastWakeTimeLocked() || mWakefulness == WAKEFULNESS_DOZING) {
            return false;
        }

        if (mWakefulness == WAKEFULNESS_ASLEEP && !allowSleepToDozeTransition) {
        if (eventTime < getLastWakeTimeLocked() || !isInteractive(mWakefulness)) {
            return false;
        }

@@ -643,8 +586,6 @@ public class PowerGroup {
                + "\nmDimDuration=" + mDimDuration
                + "\nmWakefulness=" + mWakefulness
                + "\nmIsDefaultGroupAdjacent=" + mIsDefaultGroupAdjacent
                + "\nmSupportsSandman=" + mSupportsSandman
                + "\nmDreamManagerAttemptedDreaming=" + mDreamManagerAttemptedDreaming
                + "\nmScreenOffTimeout=" + mScreenOffTimeout;
    }

+20 −120

File changed.

Preview size limit exceeded, changes collapsed.

Loading