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 StrategyExecutionRequest(DisplayManagerInternal.DisplayPowerRequest displayPowerRequest, float currentScreenBrightness, boolean userSetBrightnessChanged)35 public StrategyExecutionRequest(DisplayManagerInternal.DisplayPowerRequest displayPowerRequest, 36 float currentScreenBrightness, boolean userSetBrightnessChanged) { 37 mDisplayPowerRequest = displayPowerRequest; 38 mCurrentScreenBrightness = currentScreenBrightness; 39 mUserSetBrightnessChanged = userSetBrightnessChanged; 40 } 41 getDisplayPowerRequest()42 public DisplayManagerInternal.DisplayPowerRequest getDisplayPowerRequest() { 43 return mDisplayPowerRequest; 44 } 45 getCurrentScreenBrightness()46 public float getCurrentScreenBrightness() { 47 return mCurrentScreenBrightness; 48 } 49 isUserSetBrightnessChanged()50 public boolean isUserSetBrightnessChanged() { 51 return mUserSetBrightnessChanged; 52 } 53 54 @Override equals(Object obj)55 public boolean equals(Object obj) { 56 if (!(obj instanceof StrategyExecutionRequest)) { 57 return false; 58 } 59 StrategyExecutionRequest other = (StrategyExecutionRequest) obj; 60 return Objects.equals(mDisplayPowerRequest, other.getDisplayPowerRequest()) 61 && mCurrentScreenBrightness == other.getCurrentScreenBrightness() 62 && mUserSetBrightnessChanged == other.isUserSetBrightnessChanged(); 63 } 64 65 @Override hashCode()66 public int hashCode() { 67 return Objects.hash(mDisplayPowerRequest, mCurrentScreenBrightness, 68 mUserSetBrightnessChanged); 69 } 70 } 71