diff options
| author | 2024-02-26 16:31:04 +0000 | |
|---|---|---|
| committer | 2024-02-28 08:12:05 +0000 | |
| commit | d5449e6354e548e93e0fed9b982e8c6139ba095c (patch) | |
| tree | 071f918f24b0ca1693c70397e919417b19123a27 | |
| parent | b9ea0e22e8d2935383886b897733ceac5f9ca8c1 (diff) | |
Consolidating all the strategies in a single object
Bug: 326952125
Test: NA
Change-Id: I35aea1fd6efcb7d4166e14752b848d1652b0966b
10 files changed, 45 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/display/brightness/DisplayBrightnessStrategySelector.java b/services/core/java/com/android/server/display/brightness/DisplayBrightnessStrategySelector.java index 055f94a23363..babc36efcca8 100644 --- a/services/core/java/com/android/server/display/brightness/DisplayBrightnessStrategySelector.java +++ b/services/core/java/com/android/server/display/brightness/DisplayBrightnessStrategySelector.java @@ -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); + } } } diff --git a/services/core/java/com/android/server/display/brightness/strategy/BoostBrightnessStrategy.java b/services/core/java/com/android/server/display/brightness/strategy/BoostBrightnessStrategy.java index dd400d998eb4..9ee1d73726bd 100644 --- a/services/core/java/com/android/server/display/brightness/strategy/BoostBrightnessStrategy.java +++ b/services/core/java/com/android/server/display/brightness/strategy/BoostBrightnessStrategy.java @@ -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) {} } diff --git a/services/core/java/com/android/server/display/brightness/strategy/DisplayBrightnessStrategy.java b/services/core/java/com/android/server/display/brightness/strategy/DisplayBrightnessStrategy.java index 27d04fd7f743..1f28eb4fa113 100644 --- a/services/core/java/com/android/server/display/brightness/strategy/DisplayBrightnessStrategy.java +++ b/services/core/java/com/android/server/display/brightness/strategy/DisplayBrightnessStrategy.java @@ -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); } diff --git a/services/core/java/com/android/server/display/brightness/strategy/DozeBrightnessStrategy.java b/services/core/java/com/android/server/display/brightness/strategy/DozeBrightnessStrategy.java index 8299586e1cac..2be74438f87a 100644 --- a/services/core/java/com/android/server/display/brightness/strategy/DozeBrightnessStrategy.java +++ b/services/core/java/com/android/server/display/brightness/strategy/DozeBrightnessStrategy.java @@ -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) {} } diff --git a/services/core/java/com/android/server/display/brightness/strategy/FollowerBrightnessStrategy.java b/services/core/java/com/android/server/display/brightness/strategy/FollowerBrightnessStrategy.java index 585f576c25c3..54f9afcbdd94 100644 --- a/services/core/java/com/android/server/display/brightness/strategy/FollowerBrightnessStrategy.java +++ b/services/core/java/com/android/server/display/brightness/strategy/FollowerBrightnessStrategy.java @@ -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); diff --git a/services/core/java/com/android/server/display/brightness/strategy/InvalidBrightnessStrategy.java b/services/core/java/com/android/server/display/brightness/strategy/InvalidBrightnessStrategy.java index bc241964ff86..49c3e03c8742 100644 --- a/services/core/java/com/android/server/display/brightness/strategy/InvalidBrightnessStrategy.java +++ b/services/core/java/com/android/server/display/brightness/strategy/InvalidBrightnessStrategy.java @@ -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 is in the invalid state. */ @@ -39,4 +41,7 @@ public class InvalidBrightnessStrategy implements DisplayBrightnessStrategy { public String getName() { return "InvalidBrightnessStrategy"; } + + @Override + public void dump(PrintWriter writer) {} } diff --git a/services/core/java/com/android/server/display/brightness/strategy/OffloadBrightnessStrategy.java b/services/core/java/com/android/server/display/brightness/strategy/OffloadBrightnessStrategy.java index 55f8914e26f6..4ffb16be5789 100644 --- a/services/core/java/com/android/server/display/brightness/strategy/OffloadBrightnessStrategy.java +++ b/services/core/java/com/android/server/display/brightness/strategy/OffloadBrightnessStrategy.java @@ -67,6 +67,7 @@ public class OffloadBrightnessStrategy implements DisplayBrightnessStrategy { /** * Dumps the state of this class. */ + @Override public void dump(PrintWriter writer) { writer.println("OffloadBrightnessStrategy:"); writer.println(" mOffloadScreenBrightness:" + mOffloadScreenBrightness); diff --git a/services/core/java/com/android/server/display/brightness/strategy/OverrideBrightnessStrategy.java b/services/core/java/com/android/server/display/brightness/strategy/OverrideBrightnessStrategy.java index 13327cb4dd2f..7b651d8ced8e 100644 --- a/services/core/java/com/android/server/display/brightness/strategy/OverrideBrightnessStrategy.java +++ b/services/core/java/com/android/server/display/brightness/strategy/OverrideBrightnessStrategy.java @@ -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 brightness is overridden */ @@ -40,4 +42,7 @@ public class OverrideBrightnessStrategy implements DisplayBrightnessStrategy { public String getName() { return "OverrideBrightnessStrategy"; } + + @Override + public void dump(PrintWriter writer) {} } diff --git a/services/core/java/com/android/server/display/brightness/strategy/ScreenOffBrightnessStrategy.java b/services/core/java/com/android/server/display/brightness/strategy/ScreenOffBrightnessStrategy.java index 3d411d3db658..201ef4118854 100644 --- a/services/core/java/com/android/server/display/brightness/strategy/ScreenOffBrightnessStrategy.java +++ b/services/core/java/com/android/server/display/brightness/strategy/ScreenOffBrightnessStrategy.java @@ -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 is in the ScreenOff state. */ @@ -41,4 +43,7 @@ public class ScreenOffBrightnessStrategy implements DisplayBrightnessStrategy { public String getName() { return "ScreenOffBrightnessStrategy"; } + + @Override + public void dump(PrintWriter writer) {} } diff --git a/services/core/java/com/android/server/display/brightness/strategy/TemporaryBrightnessStrategy.java b/services/core/java/com/android/server/display/brightness/strategy/TemporaryBrightnessStrategy.java index 35f7dd0a524d..bbd0c009debb 100644 --- a/services/core/java/com/android/server/display/brightness/strategy/TemporaryBrightnessStrategy.java +++ b/services/core/java/com/android/server/display/brightness/strategy/TemporaryBrightnessStrategy.java @@ -68,6 +68,7 @@ public class TemporaryBrightnessStrategy implements DisplayBrightnessStrategy { /** * Dumps the state of this class. */ + @Override public void dump(PrintWriter writer) { writer.println("TemporaryBrightnessStrategy:"); writer.println(" mTemporaryScreenBrightness:" + mTemporaryScreenBrightness); |