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

Commit 092dc013 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 6f1fafb9.

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

Bug: 414444200
Bug: 421201132
Change-Id: If557bb83e0a4a21b4cbe66fb4a26d001e28efbb1
parent 6f1fafb9
Loading
Loading
Loading
Loading
+1 −11
Original line number Original line Diff line number Diff line
@@ -208,22 +208,12 @@ public abstract class PowerManagerInternal {


    public abstract void uidIdle(int uid);
    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.
     * 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.
     * @param force {@code true} to activate force disable wakelocks, {@code false} to turn it off.
     */
     */

    public abstract void setForceDisableWakelocks(boolean force);
    public abstract void setForceDisableWakelocks(boolean force);


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

        // Get the new display group if a change is needed, if display group name is empty and
        // 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
        // {@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.
        // has not been decided, the display is assigned to the default display group.
        final boolean needsOwnDisplayGroup =
        final boolean needsOwnDisplayGroup =
                (displayDeviceInfo.flags & DisplayDeviceInfo.FLAG_OWN_DISPLAY_GROUP) != 0
                (displayDeviceInfo.flags & DisplayDeviceInfo.FLAG_OWN_DISPLAY_GROUP) != 0
                        || !TextUtils.isEmpty(groupName);
                        || !TextUtils.isEmpty(groupName);

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


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


    private int assignDisplayGroupIdLocked(boolean needsDeviceDisplayGroup,
    private int assignDisplayGroupIdLocked(boolean isOwnDisplayGroup, String displayGroupName,
            boolean isOwnDisplayGroup, String displayGroupName,
            boolean isDeviceDisplayGroup, Integer linkedDeviceUniqueId, int decidedGroupId) {
            boolean isDeviceDisplayGroup, Integer linkedDeviceUniqueId, int decidedGroupId) {
        if (decidedGroupId != Display.INVALID_DISPLAY_GROUP && !needsDeviceDisplayGroup) {
        if (decidedGroupId != Display.INVALID_DISPLAY_GROUP) {
            return decidedGroupId;
            return decidedGroupId;
        }
        }
        if (isDeviceDisplayGroup && linkedDeviceUniqueId != null) {
        if (isDeviceDisplayGroup && linkedDeviceUniqueId != null) {
+10 −54
Original line number Original line 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;
        return true;
    }
    }


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


                    if (mGoToSleepOnButtonPressTheaterMode && interactive) {
                    if (mGoToSleepOnButtonPressTheaterMode && interactive) {
                        goToSleep(eventTime, PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON,
                        sleepDefaultDisplay(eventTime, PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON,
                                0);
                                0);
                    }
                    }
                }
                }
@@ -1544,7 +1544,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            case SHORT_PRESS_SLEEP_GO_TO_SLEEP:
            case SHORT_PRESS_SLEEP_GO_TO_SLEEP:
            case SHORT_PRESS_SLEEP_GO_TO_SLEEP_AND_GO_HOME:
            case SHORT_PRESS_SLEEP_GO_TO_SLEEP_AND_GO_HOME:
                Slog.i(TAG, "sleepRelease() calling goToSleep(GO_TO_SLEEP_REASON_SLEEP_BUTTON)");
                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;
                break;
        }
        }
    }
    }
@@ -4642,7 +4642,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                            }
                            }
                            if ((mEndcallBehavior
                            if ((mEndcallBehavior
                                    & Settings.System.END_BUTTON_BEHAVIOR_SLEEP) != 0) {
                                    & Settings.System.END_BUTTON_BEHAVIOR_SLEEP) != 0) {
                                goToSleep(event.getEventTime(),
                                sleepDefaultDisplay(event.getEventTime(),
                                        PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, 0);
                                        PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, 0);
                                isWakeKey = false;
                                isWakeKey = false;
                            }
                            }
@@ -5293,45 +5293,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        mDeviceGoingToSleep = false;
        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.
    // Called on the PowerManager's Notifier thread.
    @Override
    @Override
    public void startedGoingToSleep(int displayGroupId,
    public void startedGoingToSleep(int displayGroupId,
@@ -5342,8 +5303,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                            WindowManagerPolicyConstants.translateSleepReasonToOffReason(
                            WindowManagerPolicyConstants.translateSleepReasonToOffReason(
                                    pmSleepReason)) + ")");
                                    pmSleepReason)) + ")");
        }
        }

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


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

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

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

        EventLogTags.writeScreenToggled(1);
        EventLogTags.writeScreenToggled(1);


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

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


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


    private boolean mDreamManagerAttemptedDreaming;

    PowerGroup(int groupId, PowerGroupListener wakefulnessListener, Notifier notifier,
    PowerGroup(int groupId, PowerGroupListener wakefulnessListener, Notifier notifier,
            DisplayManagerInternal displayManagerInternal, int wakefulness, boolean ready,
            DisplayManagerInternal displayManagerInternal, int wakefulness, boolean ready,
            boolean supportsSandman, long eventTime, PowerManagerFlags featureFlags,
            boolean supportsSandman, long eventTime, PowerManagerFlags featureFlags,
@@ -213,12 +211,6 @@ public class PowerGroup {
                    mLastSleepReason = reason;
                    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;
            mWakefulness = newWakefulness;
            mWakefulnessListener.onWakefulnessChangedLocked(mGroupId, mWakefulness, eventTime,
            mWakefulnessListener.onWakefulnessChangedLocked(mGroupId, mWakefulness, eventTime,
                    reason, uid, opUid, opPackageName, details);
                    reason, uid, opUid, opPackageName, details);
@@ -227,43 +219,6 @@ public class PowerGroup {
        return false;
        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
     * Returns {@code true} if every display in this group has its requested state matching
     * its actual state.
     * its actual state.
@@ -303,7 +258,8 @@ public class PowerGroup {
        return mPoweringOn;
        return mPoweringOn;
    }
    }


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


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


    boolean dozeLocked(long eventTime, int uid, @PowerManager.GoToSleepReason int reason) {
    boolean dozeLocked(long eventTime, int uid, @PowerManager.GoToSleepReason int reason) {
        return dozeLocked(eventTime, uid, reason, false);
        if (eventTime < getLastWakeTimeLocked() || !isInteractive(mWakefulness)) {
    }

    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) {
            return false;
            return false;
        }
        }


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


+20 −127

File changed.

Preview size limit exceeded, changes collapsed.

Loading