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

Commit 9595df5b authored by Santos Cordon's avatar Santos Cordon Committed by Android (Google) Code Review
Browse files

Merge "Swap default display when lid-switch is toggled."

parents 0f8fde35 b254db18
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -266,6 +266,12 @@ public abstract class DisplayManagerInternal {
     */
     */
    public abstract void ignoreProximitySensorUntilChanged();
    public abstract void ignoreProximitySensorUntilChanged();


    /**
     * Sets the folded state of the device.
     * TODO: b/168208522 - Remove in favor of DisplayStatePolicy when that is available.
     */
    public abstract void setDeviceFolded(boolean isFolded);

    /**
    /**
     * Describes the requested power state of the display.
     * Describes the requested power state of the display.
     *
     *
+9 −0
Original line number Original line Diff line number Diff line
@@ -4443,4 +4443,13 @@


    <!-- WindowsManager JetPack display features -->
    <!-- WindowsManager JetPack display features -->
    <string name="config_display_features" translatable="false" />
    <string name="config_display_features" translatable="false" />

    <!-- Physical Display IDs of the display-devices that are swapped when a folding device folds.
         This list is expected to contain two elements: the first is the display to use
         when the device is folded, the second is the display to use when unfolded. If the array
         is empty or the display IDs are not recognized, this feature is turned off and the value
         ignored.
         TODO: b/170470621 - remove once we can have multiple Internal displays in DMS as
               well as a notification from DisplayStateManager. -->
    <string-array name="config_internalFoldedPhysicalDisplayIds" translatable="false" />
</resources>
</resources>
+1 −0
Original line number Original line Diff line number Diff line
@@ -4076,4 +4076,5 @@


  <java-symbol type="array" name="config_keep_warming_services" />
  <java-symbol type="array" name="config_keep_warming_services" />
  <java-symbol type="string" name="config_display_features" />
  <java-symbol type="string" name="config_display_features" />
  <java-symbol type="array" name="config_internalFoldedPhysicalDisplayIds" />
</resources>
</resources>
+11 −0
Original line number Original line Diff line number Diff line
@@ -112,6 +112,17 @@ class DisplayDeviceRepository implements DisplayAdapter.Listener {
        }
        }
    }
    }


    public DisplayDevice getByIdLocked(@NonNull String uniqueId) {
        final int count = mDisplayDevices.size();
        for (int i = 0; i < count; i++) {
            final DisplayDevice d = mDisplayDevices.get(i);
            if (uniqueId.equals(d.getUniqueId())) {
                return d;
            }
        }
        return null;
    }

    private void handleDisplayDeviceAdded(DisplayDevice device) {
    private void handleDisplayDeviceAdded(DisplayDevice device) {
        synchronized (mSyncRoot) {
        synchronized (mSyncRoot) {
            DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
            DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
+36 −4
Original line number Original line Diff line number Diff line
@@ -324,7 +324,7 @@ public final class DisplayManagerService extends SystemService {
        mHandler = new DisplayManagerHandler(DisplayThread.get().getLooper());
        mHandler = new DisplayManagerHandler(DisplayThread.get().getLooper());
        mUiHandler = UiThread.getHandler();
        mUiHandler = UiThread.getHandler();
        mDisplayDeviceRepo = new DisplayDeviceRepository(mSyncRoot, mPersistentDataStore);
        mDisplayDeviceRepo = new DisplayDeviceRepository(mSyncRoot, mPersistentDataStore);
        mLogicalDisplayMapper = new LogicalDisplayMapper(mDisplayDeviceRepo,
        mLogicalDisplayMapper = new LogicalDisplayMapper(context, mDisplayDeviceRepo,
                new LogicalDisplayListener(), mPersistentDataStore);
                new LogicalDisplayListener(), mPersistentDataStore);
        mDisplayModeDirector = new DisplayModeDirector(context, mHandler);
        mDisplayModeDirector = new DisplayModeDirector(context, mHandler);
        Resources resources = mContext.getResources();
        Resources resources = mContext.getResources();
@@ -576,6 +576,7 @@ public final class DisplayManagerService extends SystemService {
                    Trace.traceBegin(Trace.TRACE_TAG_POWER, "requestGlobalDisplayState("
                    Trace.traceBegin(Trace.TRACE_TAG_POWER, "requestGlobalDisplayState("
                            + Display.stateToString(state)
                            + Display.stateToString(state)
                            + ", brightness=" + brightnessState + ")");
                            + ", brightness=" + brightnessState + ")");

                    mGlobalDisplayState = state;
                    mGlobalDisplayState = state;
                    mGlobalDisplayBrightness = brightnessState;
                    mGlobalDisplayBrightness = brightnessState;
                    applyGlobalDisplayStateLocked(mTempDisplayStateWorkQueue);
                    applyGlobalDisplayStateLocked(mTempDisplayStateWorkQueue);
@@ -983,6 +984,15 @@ public final class DisplayManagerService extends SystemService {
        scheduleTraversalLocked(false);
        scheduleTraversalLocked(false);
    }
    }


    private void handleLogicalDisplaySwappedLocked(@NonNull LogicalDisplay display) {
        final DisplayDevice device = display.getPrimaryDisplayDeviceLocked();
        final Runnable work = updateDisplayStateLocked(device);
        if (work != null) {
            mHandler.post(work);
        }
        handleLogicalDisplayChangedLocked(display);
    }

    private void applyGlobalDisplayStateLocked(List<Runnable> workQueue) {
    private void applyGlobalDisplayStateLocked(List<Runnable> workQueue) {
        mDisplayDeviceRepo.forEachLocked((DisplayDevice device) -> {
        mDisplayDeviceRepo.forEachLocked((DisplayDevice device) -> {
            Runnable runnable = updateDisplayStateLocked(device);
            Runnable runnable = updateDisplayStateLocked(device);
@@ -997,10 +1007,15 @@ public final class DisplayManagerService extends SystemService {
        // by the display power controller (if known).
        // by the display power controller (if known).
        DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
        DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
        if ((info.flags & DisplayDeviceInfo.FLAG_NEVER_BLANK) == 0) {
        if ((info.flags & DisplayDeviceInfo.FLAG_NEVER_BLANK) == 0) {
            // TODO - multi-display - The rules regarding what display state to apply to each
            // TODO - b/170498827 The rules regarding what display state to apply to each
            // display will depend on the configuration/mapping of logical displays.
            // display will depend on the configuration/mapping of logical displays.
            return device.requestDisplayStateLocked(
            // Clean up LogicalDisplay.isEnabled() mechanism once this is fixed.
                    mGlobalDisplayState, mGlobalDisplayBrightness);
            int state = mGlobalDisplayState;
            final LogicalDisplay display = mLogicalDisplayMapper.getLocked(device);
            if (display != null && !display.isEnabled()) {
                state = Display.STATE_OFF;
            }
            return device.requestDisplayStateLocked(state, mGlobalDisplayBrightness);
        }
        }
        return null;
        return null;
    }
    }
@@ -1346,6 +1361,12 @@ public final class DisplayManagerService extends SystemService {
        }
        }
    }
    }


    void setFoldOverride(Boolean isFolded) {
        synchronized (mSyncRoot) {
            mLogicalDisplayMapper.setFoldOverrideLocked(isFolded);
        }
    }

    private void clearViewportsLocked() {
    private void clearViewportsLocked() {
        mViewports.clear();
        mViewports.clear();
    }
    }
@@ -1698,6 +1719,10 @@ public final class DisplayManagerService extends SystemService {
                case LogicalDisplayMapper.LOGICAL_DISPLAY_EVENT_REMOVED:
                case LogicalDisplayMapper.LOGICAL_DISPLAY_EVENT_REMOVED:
                    handleLogicalDisplayRemovedLocked(display);
                    handleLogicalDisplayRemovedLocked(display);
                    break;
                    break;

                case LogicalDisplayMapper.LOGICAL_DISPLAY_EVENT_SWAPPED:
                    handleLogicalDisplaySwappedLocked(display);
                    break;
            }
            }
        }
        }


@@ -2538,6 +2563,13 @@ public final class DisplayManagerService extends SystemService {
        public void ignoreProximitySensorUntilChanged() {
        public void ignoreProximitySensorUntilChanged() {
            mDisplayPowerController.ignoreProximitySensorUntilChanged();
            mDisplayPowerController.ignoreProximitySensorUntilChanged();
        }
        }

        @Override
        public void setDeviceFolded(boolean isFolded) {
            synchronized (mSyncRoot) {
                mLogicalDisplayMapper.setDeviceFoldedLocked(isFolded);
            }
        }
    }
    }


    class DesiredDisplayModeSpecsObserver
    class DesiredDisplayModeSpecsObserver
Loading