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

Commit b8b907fa authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Making power groups aware if they are default group adjacent" into main

parents ce6c5e7b 95eaa42e
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -504,6 +504,11 @@ public abstract class DisplayManagerInternal {
    public abstract void setScreenBrightnessOverrideFromWindowManager(
            SparseArray<DisplayBrightnessOverrideRequest> brightnessOverrides);

    /**
     * Gets the flags set for the supplied DisplayGroupId
     */
    public abstract long getDisplayGroupFlags(int groupId);

    /**
     * Describes a request for overriding the brightness of a single display.
     */
+24 −2
Original line number Diff line number Diff line
@@ -28,12 +28,19 @@ import java.util.List;
 * @hide
 */
public class DisplayGroup {

    // Indicates that the display group is adjacent to the default group. Some of the
    // properties that happen for such groups in conjuncture with the default groups are
    // 1. The device will lock only when all the groups with this flag and the default group are
    // made non interactive
    // 2. The power button will sleep only these groups and the default group
    public static long FLAG_DEFAULT_GROUP_ADJACENT = 1L << 1;
    private final List<LogicalDisplay> mDisplays = new ArrayList<>();
    private final int mGroupId;

    private String mGroupName;

    private long mFlags;

    private int mChangeCount;

    DisplayGroup(int groupId) {
@@ -53,6 +60,20 @@ public class DisplayGroup {
        mGroupName = groupName;
    }

    /**
     * Sets the supplied flag for this display group
     */
    public void setFlags(long flags) {
        mFlags |= flags;
    }

    /**
     * Gets the flags set for this display group
     */
    public long getFlags() {
        return mFlags;
    }

    /**
     * Adds the provided {@code display} to the Group
     *
@@ -117,7 +138,8 @@ public class DisplayGroup {
            LogicalDisplay logicalDisplay = mDisplays.get(i);
            ipw.println("Display " + logicalDisplay.getDisplayIdLocked() + " "
                    + logicalDisplay.getPrimaryDisplayDeviceLocked());
            ipw.println("Group name: " + getGroupName());
        }
        ipw.println("Group Name: " + getGroupName());
        ipw.println("Flags: " + getFlags());
    }
}
+13 −0
Original line number Diff line number Diff line
@@ -5697,6 +5697,19 @@ public final class DisplayManagerService extends SystemService {
            }
        }

        @Override
        public long getDisplayGroupFlags(int groupId) {
            synchronized (mSyncRoot) {
                final DisplayGroup displayGroup = mLogicalDisplayMapper.getDisplayGroupLocked(
                        groupId);
                if (displayGroup == null) {
                    return 0;
                }
                return displayGroup.getFlags();
            }
        }


        @Override
        public boolean requestPowerState(int groupId, DisplayPowerRequest request,
                boolean waitForNegativeProximity) {
+12 −2
Original line number Diff line number Diff line
@@ -23,6 +23,9 @@ import static android.hardware.devicestate.DeviceStateManager.INVALID_DEVICE_STA
import static android.view.Display.DEFAULT_DISPLAY;

import static com.android.server.display.DisplayGroupAllocator.GROUP_TYPE_PRIMARY;
import static com.android.server.display.DisplayGroupAllocator.REASON_EXTENDED;
import static com.android.server.display.DisplayGroupAllocator.REASON_NON_DESKTOP;
import static com.android.server.display.DisplayGroupAllocator.REASON_PROJECTED;
import static com.android.server.display.DisplayGroupAllocator.calculateGroupId;

import android.annotation.NonNull;
@@ -816,13 +819,13 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
        for (int i = mLogicalDisplays.size() - 1; i >= 0; i--) {
            final int displayId = mLogicalDisplays.keyAt(i);
            LogicalDisplay display = mLogicalDisplays.valueAt(i);
            assignDisplayGroupLocked(display);

            boolean wasDirty = display.isDirtyLocked();
            mTempDisplayInfo.copyFrom(display.getDisplayInfoLocked());
            display.getNonOverrideDisplayInfoLocked(mTempNonOverrideDisplayInfo);

            display.updateLocked(mDisplayDeviceRepo, mSyntheticModeManager);
            assignDisplayGroupLocked(display);

            final DisplayInfo newDisplayInfo = display.getDisplayInfoLocked();
            final int updateState = mUpdatedLogicalDisplays.get(displayId, UPDATE_STATE_NEW);
            final boolean wasPreviouslyUpdated = updateState != UPDATE_STATE_NEW;
@@ -1125,6 +1128,13 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
            newGroup = new DisplayGroup(groupId);
            newGroup.setGroupName(groupName);
            mDisplayGroups.append(groupId, newGroup);

            int reason = mDisplayGroupAllocator.getContentModeForDisplayLocked(
                    display, displayDeviceInfo.type);
            if (reason == REASON_PROJECTED || reason == REASON_EXTENDED
                    || reason == REASON_NON_DESKTOP) {
                newGroup.setFlags(DisplayGroup.FLAG_DEFAULT_GROUP_ADJACENT);
            }
        }
        if (oldGroup != newGroup) {
            if (oldGroup != null) {
+14 −2
Original line number Diff line number Diff line
@@ -76,6 +76,8 @@ public class PowerGroup {
    private final int mGroupId;
    private final PowerManagerFlags mFeatureFlags;

    private final boolean mIsDefaultGroupAdjacent;

    /** True if DisplayManagerService has applied all the latest display states that were requested
     *  for this group. */
    private boolean mReady;
@@ -107,7 +109,8 @@ public class PowerGroup {

    PowerGroup(int groupId, PowerGroupListener wakefulnessListener, Notifier notifier,
            DisplayManagerInternal displayManagerInternal, int wakefulness, boolean ready,
            boolean supportsSandman, long eventTime, PowerManagerFlags featureFlags) {
            boolean supportsSandman, long eventTime, PowerManagerFlags featureFlags,
            boolean isDefaultGroupAdjacent) {
        mGroupId = groupId;
        mWakefulnessListener = wakefulnessListener;
        mNotifier = notifier;
@@ -118,6 +121,7 @@ public class PowerGroup {
        mLastWakeTime = eventTime;
        mLastSleepTime = eventTime;
        mFeatureFlags = featureFlags;
        mIsDefaultGroupAdjacent = isDefaultGroupAdjacent;

        long dimDuration = INVALID_TIMEOUT;
        long screenOffTimeout = INVALID_TIMEOUT;
@@ -146,7 +150,7 @@ public class PowerGroup {

    PowerGroup(int wakefulness, PowerGroupListener wakefulnessListener, Notifier notifier,
            DisplayManagerInternal displayManagerInternal, long eventTime,
            PowerManagerFlags featureFlags) {
            PowerManagerFlags featureFlags, boolean isDefaultGroupAdjacent) {
        mGroupId = Display.DEFAULT_DISPLAY_GROUP;
        mWakefulnessListener = wakefulnessListener;
        mNotifier = notifier;
@@ -159,6 +163,7 @@ public class PowerGroup {
        mFeatureFlags = featureFlags;
        mDimDuration = INVALID_TIMEOUT;
        mScreenOffTimeout = INVALID_TIMEOUT;
        mIsDefaultGroupAdjacent = isDefaultGroupAdjacent;
    }

    long getScreenOffTimeoutOverrideLocked(long defaultScreenOffTimeout) {
@@ -253,6 +258,11 @@ public class PowerGroup {
        return mPoweringOn;
    }

    @VisibleForTesting
    boolean isDefaultGroupAdjacent() {
        return mIsDefaultGroupAdjacent;
    }

    void setIsPoweringOnLocked(boolean isPoweringOnNew) {
        mPoweringOn = isPoweringOnNew;
    }
@@ -574,6 +584,8 @@ public class PowerGroup {
                + "\nmLastWakeReason=" + mLastWakeReason
                + "\nmLastSleepReason=" + mLastSleepReason
                + "\nmDimDuration=" + mDimDuration
                + "\nmWakefulness=" + mWakefulness
                + "\nmIsDefaultGroupAdjacent=" + mIsDefaultGroupAdjacent
                + "\nmScreenOffTimeout=" + mScreenOffTimeout;
    }

Loading