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

Commit 433cfd2d authored by Rupesh Bansal's avatar Rupesh Bansal
Browse files

Add duplicated DisplayPowerController

We are creating a copy of the existing DisplayPowerController so that it
can be used as a base to apply the refactoring ideas. This is crucial as
the old DisplayPowerController will continue to behave as it does today,
minimizing the risk of any bugs that might get introduced.
Reviewers of DisplayPowerController class are expected to ensure any changes happening
in DisplayPowerController are also accommodated in
DisplayPowerController2.

Bug: 241307688
Test: Manual
Change-Id: I7682996d4e47cece6cdfc3e4e6e539677e85496b
parent 4456fb95
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2562,10 +2562,10 @@ public final class DisplayManagerService extends SystemService {

        final BrightnessSetting brightnessSetting = new BrightnessSetting(mPersistentDataStore,
                display, mSyncRoot);
        final DisplayPowerController displayPowerController;
        final DisplayPowerControllerInterface displayPowerController;

        if (SystemProperties.getInt(PROP_USE_NEW_DISPLAY_POWER_CONTROLLER, 0) == 1) {
            displayPowerController = new DisplayPowerController(
            displayPowerController = new DisplayPowerController2(
                    mContext, /* injector= */ null, mDisplayPowerCallbacks, mPowerHandler,
                    mSensorManager, mDisplayBlanker, display, mBrightnessTracker, brightnessSetting,
                    () -> handleBrightnessChange(display));
+4 −3
Original line number Diff line number Diff line
@@ -798,8 +798,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
     * Notified when the display is changed. We use this to apply any changes that might be needed
     * when displays get swapped on foldable devices.  For example, different brightness properties
     * of each display need to be properly reflected in AutomaticBrightnessController.
     *
     * Make sure DisplayManagerService.mSyncRoot is held when this is called
     */
    @GuardedBy("DisplayManagerService.mSyncRoot")
    @Override
    public void onDisplayChanged() {
        final DisplayDevice device = mLogicalDisplay.getPrimaryDisplayDeviceLocked();
@@ -1896,7 +1897,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
                    }
                },
                () -> {
                    sendUpdatePowerStateLocked();
                    sendUpdatePowerState();
                    postBrightnessChangeRunnable();
                    // TODO(b/192258832): Switch the HBMChangeCallback to a listener pattern.
                    if (mAutomaticBrightnessController != null) {
@@ -1912,7 +1913,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
                ddConfig != null ? ddConfig.getBrightnessThrottlingData() : null;
        return new BrightnessThrottler(mHandler, data,
                () -> {
                    sendUpdatePowerStateLocked();
                    sendUpdatePowerState();
                    postBrightnessChangeRunnable();
                }, mUniqueDisplayId);
    }