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 StrategySelectionRequest(DisplayManagerInternal.DisplayPowerRequest displayPowerRequest, int targetDisplayState, float lastUserSetScreenBrightness, boolean userSetBrightnessChanged, DisplayManagerInternal.DisplayOffloadSession displayOffloadSession)43 public StrategySelectionRequest(DisplayManagerInternal.DisplayPowerRequest displayPowerRequest, 44 int targetDisplayState, float lastUserSetScreenBrightness, 45 boolean userSetBrightnessChanged, 46 DisplayManagerInternal.DisplayOffloadSession displayOffloadSession) { 47 mDisplayPowerRequest = displayPowerRequest; 48 mTargetDisplayState = targetDisplayState; 49 mLastUserSetScreenBrightness = lastUserSetScreenBrightness; 50 mUserSetBrightnessChanged = userSetBrightnessChanged; 51 mDisplayOffloadSession = displayOffloadSession; 52 } 53 getDisplayPowerRequest()54 public DisplayManagerInternal.DisplayPowerRequest getDisplayPowerRequest() { 55 return mDisplayPowerRequest; 56 } 57 getTargetDisplayState()58 public int getTargetDisplayState() { 59 return mTargetDisplayState; 60 } 61 62 getLastUserSetScreenBrightness()63 public float getLastUserSetScreenBrightness() { 64 return mLastUserSetScreenBrightness; 65 } 66 isUserSetBrightnessChanged()67 public boolean isUserSetBrightnessChanged() { 68 return mUserSetBrightnessChanged; 69 } 70 getDisplayOffloadSession()71 public DisplayManagerInternal.DisplayOffloadSession getDisplayOffloadSession() { 72 return mDisplayOffloadSession; 73 } 74 75 @Override equals(Object obj)76 public boolean equals(Object obj) { 77 if (!(obj instanceof StrategySelectionRequest)) { 78 return false; 79 } 80 StrategySelectionRequest other = (StrategySelectionRequest) obj; 81 return Objects.equals(mDisplayPowerRequest, other.getDisplayPowerRequest()) 82 && mTargetDisplayState == other.getTargetDisplayState() 83 && mLastUserSetScreenBrightness == other.getLastUserSetScreenBrightness() 84 && mUserSetBrightnessChanged == other.isUserSetBrightnessChanged() 85 && mDisplayOffloadSession.equals(other.getDisplayOffloadSession()); 86 } 87 88 @Override hashCode()89 public int hashCode() { 90 return Objects.hash(mDisplayPowerRequest, mTargetDisplayState, 91 mLastUserSetScreenBrightness, mUserSetBrightnessChanged, mDisplayOffloadSession); 92 } 93 } 94