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

Commit f85fac6c authored by Rupesh Bansal's avatar Rupesh Bansal Committed by Android (Google) Code Review
Browse files

Merge "Consolidating all the strategies in a single object" into main

parents e809cd2e d5449e63
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -71,6 +71,8 @@ public class DisplayBrightnessStrategySelector {
    @Nullable
    private final OffloadBrightnessStrategy mOffloadBrightnessStrategy;

    private final DisplayBrightnessStrategy[] mDisplayBrightnessStrategies;

    // We take note of the old brightness strategy so that we can know when the strategy changes.
    private String mOldBrightnessStrategyName;

@@ -98,6 +100,10 @@ public class DisplayBrightnessStrategySelector {
        } else {
            mOffloadBrightnessStrategy = null;
        }
        mDisplayBrightnessStrategies = new DisplayBrightnessStrategy[]{mInvalidBrightnessStrategy,
                mScreenOffBrightnessStrategy, mDozeBrightnessStrategy, mFollowerBrightnessStrategy,
                mBoostBrightnessStrategy, mOverrideBrightnessStrategy, mTemporaryBrightnessStrategy,
                mOffloadBrightnessStrategy};
        mAllowAutoBrightnessWhileDozingConfig = context.getResources().getBoolean(
                R.bool.config_allowAutoBrightnessWhileDozing);
        mOldBrightnessStrategyName = mInvalidBrightnessStrategy.getName();
@@ -179,9 +185,10 @@ public class DisplayBrightnessStrategySelector {
                "  mAllowAutoBrightnessWhileDozingConfig= "
                        + mAllowAutoBrightnessWhileDozingConfig);
        IndentingPrintWriter ipw = new IndentingPrintWriter(writer, " ");
        mTemporaryBrightnessStrategy.dump(ipw);
        if (mOffloadBrightnessStrategy != null) {
            mOffloadBrightnessStrategy.dump(ipw);
        for (DisplayBrightnessStrategy displayBrightnessStrategy: mDisplayBrightnessStrategies) {
            if (displayBrightnessStrategy != null) {
                displayBrightnessStrategy.dump(ipw);
            }
        }
    }

+5 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import com.android.server.display.DisplayBrightnessState;
import com.android.server.display.brightness.BrightnessReason;
import com.android.server.display.brightness.BrightnessUtils;

import java.io.PrintWriter;

/**
 * Manages the brightness of the display when the system brightness boost is requested.
 */
@@ -48,4 +50,7 @@ public class BoostBrightnessStrategy implements DisplayBrightnessStrategy {
    public String getName() {
        return "BoostBrightnessStrategy";
    }

    @Override
    public void dump(PrintWriter writer) {}
}
+8 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import android.hardware.display.DisplayManagerInternal;

import com.android.server.display.DisplayBrightnessState;

import java.io.PrintWriter;

/**
 * Decides the DisplayBrighntessState that the display should change to based on strategy-specific
 * logic within each implementation. Clamping should be done outside of DisplayBrightnessStrategy if
@@ -40,4 +42,10 @@ public interface DisplayBrightnessStrategy {
     */
    @NonNull
    String getName();

    /**
     * Dumps the state of the Strategy
     * @param writer
     */
    void dump(PrintWriter writer);
}
+4 −0
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ import com.android.server.display.DisplayBrightnessState;
import com.android.server.display.brightness.BrightnessReason;
import com.android.server.display.brightness.BrightnessUtils;

import java.io.PrintWriter;

/**
 * Manages the brightness of the display when the system is in the doze state.
 */
@@ -42,4 +44,6 @@ public class DozeBrightnessStrategy implements DisplayBrightnessStrategy {
        return "DozeBrightnessStrategy";
    }

    @Override
    public void dump(PrintWriter writer) {}
}
+1 −0
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ public class FollowerBrightnessStrategy implements DisplayBrightnessStrategy {
    /**
     * Dumps the state of this class.
     */
    @Override
    public void dump(PrintWriter writer) {
        writer.println("FollowerBrightnessStrategy:");
        writer.println("  mDisplayId=" + mDisplayId);
Loading