• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.server.display.brightness.clamper;
18 
19 import android.hardware.display.DisplayManagerInternal;
20 import android.os.PowerManager;
21 import android.util.IndentingPrintWriter;
22 
23 import com.android.server.display.brightness.BrightnessReason;
24 
25 import java.io.PrintWriter;
26 
27 class BrightnessLowPowerModeModifier extends BrightnessModifier {
28 
29     @Override
shouldApply(DisplayManagerInternal.DisplayPowerRequest request)30     boolean shouldApply(DisplayManagerInternal.DisplayPowerRequest request) {
31         return request.lowPowerMode;
32     }
33 
34 
35     @Override
getBrightnessAdjusted(float currentBrightness, DisplayManagerInternal.DisplayPowerRequest request)36     float getBrightnessAdjusted(float currentBrightness,
37             DisplayManagerInternal.DisplayPowerRequest request) {
38         final float brightnessFactor =
39                 Math.min(request.screenLowPowerBrightnessFactor, 1);
40         return Math.max((currentBrightness * brightnessFactor), PowerManager.BRIGHTNESS_MIN);
41     }
42 
43     @Override
getModifier()44     int getModifier() {
45         return BrightnessReason.MODIFIER_LOW_POWER;
46     }
47 
48     @Override
dump(PrintWriter pw)49     public void dump(PrintWriter pw) {
50         pw.println("BrightnessLowPowerModeModifier:");
51         IndentingPrintWriter ipw = new IndentingPrintWriter(pw, "    ");
52         super.dump(ipw);
53     }
54 
55     @Override
shouldListenToLightSensor()56     public boolean shouldListenToLightSensor() {
57         return false;
58     }
59 
60     @Override
setAmbientLux(float lux)61     public void setAmbientLux(float lux) {
62         // unused
63     }
64 }
65