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

Commit f5c7cec0 authored by Rupesh Bansal's avatar Rupesh Bansal
Browse files

Added support for a DeviceConfig flag to dynamically switch between old

and new DPC

We now support dynamic switching between the old and the new DPCs such that it can be controlled remotely as well.
To use new DPC, run adb shell device_config put display_manager use_newly_structured_display_power_controller true
To use old DPC, run adb shell device_config put display_manager
use_newly_structured_display_power_controller false.
To check the current value, run adb shell device_config list | grep
"use_newly_structured_display_power_controller".
By default, we fallback to the old DPC

Test: Manual
Bug: 254004456
Change-Id: Ica0405bc6ec0b2cb7dd1f32a5ea618a8e506f2f7
parent 283098bc
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import static android.os.Process.ROOT_UID;
import android.Manifest;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.UserIdInt;
import android.app.AppOpsManager;
import android.app.compat.CompatChanges;
@@ -101,6 +102,7 @@ import android.os.SystemProperties;
import android.os.Trace;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.DeviceConfig;
import android.provider.Settings;
import android.sysprop.DisplayProperties;
import android.text.TextUtils;
@@ -202,8 +204,6 @@ public final class DisplayManagerService extends SystemService {
    private static final String FORCE_WIFI_DISPLAY_ENABLE = "persist.debug.wfd.enable";

    private static final String PROP_DEFAULT_DISPLAY_TOP_INSET = "persist.sys.displayinset.top";
    private static final String PROP_USE_NEW_DISPLAY_POWER_CONTROLLER =
            "persist.sys.use_new_display_power_controller";
    private static final long WAIT_FOR_DEFAULT_DISPLAY_TIMEOUT = 10000;
    // This value needs to be in sync with the threshold
    // in RefreshRateConfigs::getFrameRateDivisor.
@@ -2575,6 +2575,7 @@ public final class DisplayManagerService extends SystemService {
        mLogicalDisplayMapper.forEachLocked(this::addDisplayPowerControllerLocked);
    }

    @RequiresPermission(Manifest.permission.READ_DEVICE_CONFIG)
    private void addDisplayPowerControllerLocked(LogicalDisplay display) {
        if (mPowerHandler == null) {
            // initPowerManagement has not yet been called.
@@ -2588,7 +2589,8 @@ public final class DisplayManagerService extends SystemService {
                display, mSyncRoot);
        final DisplayPowerControllerInterface displayPowerController;

        if (SystemProperties.getInt(PROP_USE_NEW_DISPLAY_POWER_CONTROLLER, 0) == 1) {
        if (DeviceConfig.getBoolean("display_manager",
                "use_newly_structured_display_power_controller", false)) {
            displayPowerController = new DisplayPowerController2(
                    mContext, /* injector= */ null, mDisplayPowerCallbacks, mPowerHandler,
                    mSensorManager, mDisplayBlanker, display, mBrightnessTracker, brightnessSetting,