• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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;
18 
19 import android.hardware.display.DisplayManagerInternal;
20 
21 import java.util.Objects;
22 
23 /**
24  * A wrapper class to encapsulate the request to select a strategy from
25  * DisplayBrightnessStrategySelector
26  */
27 public final class StrategySelectionRequest {
28     // The request to change the associated display's state and brightness
29     private DisplayManagerInternal.DisplayPowerRequest mDisplayPowerRequest;
30 
31     // The display state to which the screen is switching to
32     private int mTargetDisplayState;
33 
34     // The last brightness that was set by the user and not temporary. Set to
35     // PowerManager.BRIGHTNESS_INVALID_FLOAT when a brightness has yet to be recorded.
36     private float mLastUserSetScreenBrightness;
37 
38     // Represents if the user set screen brightness was changed or not.
39     private boolean mUserSetBrightnessChanged;
40 
41     private DisplayManagerInternal.DisplayOffloadSession mDisplayOffloadSession;
42 
43     private boolean mIsStylusBeingUsed;
44 
45     private boolean mIsWearBedtimeModeEnabled;
46 
StrategySelectionRequest(DisplayManagerInternal.DisplayPowerRequest displayPowerRequest, int targetDisplayState, float lastUserSetScreenBrightness, boolean userSetBrightnessChanged, DisplayManagerInternal.DisplayOffloadSession displayOffloadSession, boolean isStylusBeingUsed, boolean isWearBedtimeModeEnabled)47     public StrategySelectionRequest(DisplayManagerInternal.DisplayPowerRequest displayPowerRequest,
48             int targetDisplayState, float lastUserSetScreenBrightness,
49             boolean userSetBrightnessChanged,
50             DisplayManagerInternal.DisplayOffloadSession displayOffloadSession,
51             boolean isStylusBeingUsed,
52             boolean isWearBedtimeModeEnabled) {
53         mDisplayPowerRequest = displayPowerRequest;
54         mTargetDisplayState = targetDisplayState;
55         mLastUserSetScreenBrightness = lastUserSetScreenBrightness;
56         mUserSetBrightnessChanged = userSetBrightnessChanged;
57         mDisplayOffloadSession = displayOffloadSession;
58         mIsStylusBeingUsed = isStylusBeingUsed;
59         mIsWearBedtimeModeEnabled = isWearBedtimeModeEnabled;
60     }
61 
getDisplayPowerRequest()62     public DisplayManagerInternal.DisplayPowerRequest getDisplayPowerRequest() {
63         return mDisplayPowerRequest;
64     }
65 
getTargetDisplayState()66     public int getTargetDisplayState() {
67         return mTargetDisplayState;
68     }
69 
70 
getLastUserSetScreenBrightness()71     public float getLastUserSetScreenBrightness() {
72         return mLastUserSetScreenBrightness;
73     }
74 
isUserSetBrightnessChanged()75     public boolean isUserSetBrightnessChanged() {
76         return mUserSetBrightnessChanged;
77     }
78 
isWearBedtimeModeEnabled()79     public boolean isWearBedtimeModeEnabled() {
80         return mIsWearBedtimeModeEnabled;
81     }
82 
getDisplayOffloadSession()83     public DisplayManagerInternal.DisplayOffloadSession getDisplayOffloadSession() {
84         return mDisplayOffloadSession;
85     }
86 
isStylusBeingUsed()87     public boolean isStylusBeingUsed() {
88         return mIsStylusBeingUsed;
89     }
90 
91     @Override
equals(Object obj)92     public boolean equals(Object obj) {
93         if (!(obj instanceof StrategySelectionRequest)) {
94             return false;
95         }
96         StrategySelectionRequest other = (StrategySelectionRequest) obj;
97         return Objects.equals(mDisplayPowerRequest, other.getDisplayPowerRequest())
98                 && mTargetDisplayState == other.getTargetDisplayState()
99                 && mLastUserSetScreenBrightness == other.getLastUserSetScreenBrightness()
100                 && mUserSetBrightnessChanged == other.isUserSetBrightnessChanged()
101                 && mDisplayOffloadSession.equals(other.getDisplayOffloadSession())
102                 && mIsStylusBeingUsed == other.isStylusBeingUsed()
103                 && mIsWearBedtimeModeEnabled == other.isWearBedtimeModeEnabled();
104     }
105 
106     @Override
hashCode()107     public int hashCode() {
108         return Objects.hash(mDisplayPowerRequest, mTargetDisplayState,
109                 mLastUserSetScreenBrightness, mUserSetBrightnessChanged, mDisplayOffloadSession,
110                 mIsStylusBeingUsed);
111     }
112 }
113