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

Commit 5f48b7a8 authored by Sean Stout's avatar Sean Stout Committed by Automerger Merge Worker
Browse files

Merge "Request power state updates for individual DisplayGroups" into sc-dev am: 303e58ee

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13554025

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I769f020d36b6edcd1d3450ff54c78350454ec80c
parents 8ca69dbf 303e58ee
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -66,12 +66,6 @@ public abstract class DisplayManagerInternal {
     */
    public abstract boolean isProximitySensorAvailable();

    /**
     * Returns the id of the {@link com.android.server.display.DisplayGroup} to which the provided
     * display belongs.
     */
    public abstract int getDisplayGroupId(int displayId);

    /**
     * Registers a display group listener which will be informed of the addition, removal, or change
     * of display groups.
@@ -469,7 +463,7 @@ public abstract class DisplayManagerInternal {
        void onStateChanged();
        void onProximityPositive();
        void onProximityNegative();
        void onDisplayStateChange(int state); // one of the Display state constants
        void onDisplayStateChange(boolean allInactive, boolean allOff);

        void acquireSuspendBlocker();
        void releaseSuspendBlocker();
+4 −0
Original line number Diff line number Diff line
@@ -354,6 +354,10 @@ class AutomaticBrightnessController {
        }
    }

    public void stop() {
        setLightSensorEnabled(false);
    }

    public boolean hasUserDataPoints() {
        return mBrightnessMapper.hasUserDataPoints();
    }
+0 −1
Original line number Diff line number Diff line
@@ -243,7 +243,6 @@ public class BrightnessTracker {
    }

    /** Stop listening for events */
    @VisibleForTesting
    void stop() {
        if (DEBUG) {
            Slog.d(TAG, "Stop");
+6 −0
Original line number Diff line number Diff line
@@ -817,6 +817,12 @@ final class ColorFade {
                }

                DisplayInfo displayInfo = mDisplayManagerInternal.getDisplayInfo(mDisplayId);
                if (displayInfo == null) {
                    // displayInfo can be null if the associated display has been removed. There
                    // is a delay between the display being removed and ColorFade being dismissed.
                    return;
                }

                switch (displayInfo.rotation) {
                    case Surface.ROTATION_0:
                        t.setPosition(mSurfaceControl, 0, 0);
+49 −24
Original line number Diff line number Diff line
@@ -249,30 +249,48 @@ public final class DisplayManagerService extends SystemService {

    /** {@link DisplayBlanker} used by all {@link DisplayPowerController}s. */
    private final DisplayBlanker mDisplayBlanker = new DisplayBlanker() {
        // Synchronized to avoid race conditions when updating multiple display states.
        @Override
        public void requestDisplayState(int displayId, int state, float brightness) {
            // TODO (b/168210494): Stop applying default display state to all displays.
            if (displayId != Display.DEFAULT_DISPLAY) {
                return;
            }
            final int[] displayIds;
        public synchronized void requestDisplayState(int displayId, int state, float brightness) {
            boolean allInactive = true;
            boolean allOff = true;
            final boolean stateChanged;
            synchronized (mSyncRoot) {
                displayIds = mLogicalDisplayMapper.getDisplayIdsLocked();
                final int index = mDisplayStates.indexOfKey(displayId);
                if (index > -1) {
                    final int currentState = mDisplayStates.valueAt(index);
                    stateChanged = state != currentState;
                    if (stateChanged) {
                        final int size = mDisplayStates.size();
                        for (int i = 0; i < size; i++) {
                            final int displayState = i == index ? state : mDisplayStates.valueAt(i);
                            if (displayState != Display.STATE_OFF) {
                                allOff = false;
                            }
                            if (Display.isActiveState(displayState)) {
                                allInactive = false;
                            }
                            if (!allOff && !allInactive) {
                                break;
                            }
                        }
                    }
                } else {
                    stateChanged = false;
                }
            }

            // The order of operations is important for legacy reasons.
            if (state == Display.STATE_OFF) {
                for (int id : displayIds) {
                    requestDisplayStateInternal(id, state, brightness);
                }
                requestDisplayStateInternal(displayId, state, brightness);
            }

            mDisplayPowerCallbacks.onDisplayStateChange(state);
            if (stateChanged) {
                mDisplayPowerCallbacks.onDisplayStateChange(allInactive, allOff);
            }

            if (state != Display.STATE_OFF) {
                for (int id : displayIds) {
                    requestDisplayStateInternal(id, state, brightness);
                }
                requestDisplayStateInternal(displayId, state, brightness);
            }
        }
    };
@@ -1160,7 +1178,7 @@ public final class DisplayManagerService extends SystemService {

    private void handleLogicalDisplayRemovedLocked(@NonNull LogicalDisplay display) {
        final int displayId = display.getDisplayIdLocked();
        mDisplayPowerControllers.delete(displayId);
        mDisplayPowerControllers.removeReturnOld(displayId).stop();
        mDisplayStates.delete(displayId);
        mDisplayBrightnesses.delete(displayId);
        DisplayManagerGlobal.invalidateLocalDisplayInfoCaches();
@@ -2758,23 +2776,30 @@ public final class DisplayManagerService extends SystemService {
        public boolean requestPowerState(int groupId, DisplayPowerRequest request,
                boolean waitForNegativeProximity) {
            synchronized (mSyncRoot) {
                return mDisplayPowerControllers.get(Display.DEFAULT_DISPLAY)
                        .requestPowerState(request, waitForNegativeProximity);
                final DisplayGroup displayGroup = mLogicalDisplayMapper.getDisplayGroupLocked(
                        groupId);
                if (displayGroup == null) {
                    return true;
                }

                final int size = displayGroup.getSizeLocked();
                boolean ready = true;
                for (int i = 0; i < size; i++) {
                    final DisplayPowerController displayPowerController =
                            mDisplayPowerControllers.get(displayGroup.getIdLocked(i));
                    ready &= displayPowerController.requestPowerState(request,
                            waitForNegativeProximity);
                }

        @Override
        public boolean isProximitySensorAvailable() {
            synchronized (mSyncRoot) {
                return mDisplayPowerControllers.get(Display.DEFAULT_DISPLAY)
                        .isProximitySensorAvailable();
                return ready;
            }
        }

        @Override
        public int getDisplayGroupId(int displayId) {
        public boolean isProximitySensorAvailable() {
            synchronized (mSyncRoot) {
                return mLogicalDisplayMapper.getDisplayGroupIdLocked(displayId);
                return mDisplayPowerControllers.get(Display.DEFAULT_DISPLAY)
                        .isProximitySensorAvailable();
            }
        }

Loading