• 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 execute the selected strategy
25  */
26 public final class StrategyExecutionRequest {
27     // The request to change the associated display's state and brightness
28     private final DisplayManagerInternal.DisplayPowerRequest mDisplayPowerRequest;
29 
30     private final float mCurrentScreenBrightness;
31 
32     // Represents if the user set screen brightness was changed or not.
33     private boolean mUserSetBrightnessChanged;
34 
35     private boolean mIsStylusBeingUsed;
36 
StrategyExecutionRequest(DisplayManagerInternal.DisplayPowerRequest displayPowerRequest, float currentScreenBrightness, boolean userSetBrightnessChanged, boolean isStylusBeingUsed)37     public StrategyExecutionRequest(DisplayManagerInternal.DisplayPowerRequest displayPowerRequest,
38             float currentScreenBrightness, boolean userSetBrightnessChanged,
39             boolean isStylusBeingUsed) {
40         mDisplayPowerRequest = displayPowerRequest;
41         mCurrentScreenBrightness = currentScreenBrightness;
42         mUserSetBrightnessChanged = userSetBrightnessChanged;
43         mIsStylusBeingUsed = isStylusBeingUsed;
44     }
45 
getDisplayPowerRequest()46     public DisplayManagerInternal.DisplayPowerRequest getDisplayPowerRequest() {
47         return mDisplayPowerRequest;
48     }
49 
getCurrentScreenBrightness()50     public float getCurrentScreenBrightness() {
51         return mCurrentScreenBrightness;
52     }
53 
isUserSetBrightnessChanged()54     public boolean isUserSetBrightnessChanged() {
55         return mUserSetBrightnessChanged;
56     }
57 
isStylusBeingUsed()58     public boolean isStylusBeingUsed() {
59         return mIsStylusBeingUsed;
60     }
61 
62     @Override
equals(Object obj)63     public boolean equals(Object obj) {
64         if (!(obj instanceof StrategyExecutionRequest)) {
65             return false;
66         }
67         StrategyExecutionRequest other = (StrategyExecutionRequest) obj;
68         return Objects.equals(mDisplayPowerRequest, other.getDisplayPowerRequest())
69                 && mCurrentScreenBrightness == other.getCurrentScreenBrightness()
70                 && mUserSetBrightnessChanged == other.isUserSetBrightnessChanged()
71                 && mIsStylusBeingUsed == other.isStylusBeingUsed();
72     }
73 
74     @Override
hashCode()75     public int hashCode() {
76         return Objects.hash(mDisplayPowerRequest, mCurrentScreenBrightness,
77                 mUserSetBrightnessChanged, mIsStylusBeingUsed);
78     }
79 }
80