1 /* 2 * Copyright (C) 2014 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 android.hardware.display; 18 19 import android.annotation.IntDef; 20 import android.annotation.Nullable; 21 import android.graphics.Point; 22 import android.hardware.SensorManager; 23 import android.os.Handler; 24 import android.os.PowerManager; 25 import android.util.IntArray; 26 import android.util.Slog; 27 import android.util.SparseArray; 28 import android.view.Display; 29 import android.view.DisplayInfo; 30 import android.view.SurfaceControl; 31 import android.view.SurfaceControl.Transaction; 32 33 import java.lang.annotation.Retention; 34 import java.lang.annotation.RetentionPolicy; 35 import java.util.List; 36 import java.util.Objects; 37 38 /** 39 * Display manager local system service interface. 40 * 41 * @hide Only for use within the system server. 42 */ 43 public abstract class DisplayManagerInternal { 44 45 @IntDef(prefix = {"REFRESH_RATE_LIMIT_"}, value = { 46 REFRESH_RATE_LIMIT_HIGH_BRIGHTNESS_MODE 47 }) 48 @Retention(RetentionPolicy.SOURCE) 49 public @interface RefreshRateLimitType {} 50 51 /** Refresh rate should be limited when High Brightness Mode is active. */ 52 public static final int REFRESH_RATE_LIMIT_HIGH_BRIGHTNESS_MODE = 1; 53 54 /** 55 * Called by the power manager to initialize power management facilities. 56 */ initPowerManagement(DisplayPowerCallbacks callbacks, Handler handler, SensorManager sensorManager)57 public abstract void initPowerManagement(DisplayPowerCallbacks callbacks, 58 Handler handler, SensorManager sensorManager); 59 60 /** 61 * Called by the power manager to request a new power state. 62 * <p> 63 * The display power controller makes a copy of the provided object and then 64 * begins adjusting the power state to match what was requested. 65 * </p> 66 * 67 * @param groupId The identifier for the display group being requested to change power state 68 * @param request The requested power state. 69 * @param waitForNegativeProximity If {@code true}, issues a request to wait for 70 * negative proximity before turning the screen back on, assuming the screen 71 * was turned off by the proximity sensor. 72 * @return {@code true} if display group is ready, {@code false} if there are important 73 * changes that must be made asynchronously (such as turning the screen on), in which case 74 * the caller should grab a wake lock, watch for {@link DisplayPowerCallbacks#onStateChanged} 75 * then try the request again later until the state converges. If the provided {@code groupId} 76 * cannot be found then {@code true} will be returned. 77 */ requestPowerState(int groupId, DisplayPowerRequest request, boolean waitForNegativeProximity)78 public abstract boolean requestPowerState(int groupId, DisplayPowerRequest request, 79 boolean waitForNegativeProximity); 80 81 /** 82 * Returns {@code true} if the proximity sensor screen-off function is available. 83 */ isProximitySensorAvailable()84 public abstract boolean isProximitySensorAvailable(); 85 86 /** 87 * Registers a display group listener which will be informed of the addition, removal, or change 88 * of display groups. 89 * 90 * @param listener The listener to register. 91 */ registerDisplayGroupListener(DisplayGroupListener listener)92 public abstract void registerDisplayGroupListener(DisplayGroupListener listener); 93 94 /** 95 * Unregisters a display group listener which will be informed of the addition, removal, or 96 * change of display groups. 97 * 98 * @param listener The listener to unregister. 99 */ unregisterDisplayGroupListener(DisplayGroupListener listener)100 public abstract void unregisterDisplayGroupListener(DisplayGroupListener listener); 101 102 /** 103 * Screenshot for internal system-only use such as rotation, etc. This method includes 104 * secure layers and the result should never be exposed to non-system applications. 105 * This method does not apply any rotation and provides the output in natural orientation. 106 * 107 * @param displayId The display id to take the screenshot of. 108 * @return The buffer or null if we have failed. 109 */ systemScreenshot(int displayId)110 public abstract SurfaceControl.ScreenshotHardwareBuffer systemScreenshot(int displayId); 111 112 /** 113 * General screenshot functionality that excludes secure layers and applies appropriate 114 * rotation that the device is currently in. 115 * 116 * @param displayId The display id to take the screenshot of. 117 * @return The buffer or null if we have failed. 118 */ userScreenshot(int displayId)119 public abstract SurfaceControl.ScreenshotHardwareBuffer userScreenshot(int displayId); 120 121 /** 122 * Returns information about the specified logical display. 123 * 124 * @param displayId The logical display id. 125 * @return The logical display info, or null if the display does not exist. The 126 * returned object must be treated as immutable. 127 */ getDisplayInfo(int displayId)128 public abstract DisplayInfo getDisplayInfo(int displayId); 129 130 /** 131 * Returns the position of the display's projection. 132 * 133 * @param displayId The logical display id. 134 * @return The x, y coordinates of the display, or null if the display does not exist. The 135 * return object must be treated as immutable. 136 */ 137 @Nullable getDisplayPosition(int displayId)138 public abstract Point getDisplayPosition(int displayId); 139 140 /** 141 * Registers a display transaction listener to provide the client a chance to 142 * update its surfaces within the same transaction as any display layout updates. 143 * 144 * @param listener The listener to register. 145 */ registerDisplayTransactionListener(DisplayTransactionListener listener)146 public abstract void registerDisplayTransactionListener(DisplayTransactionListener listener); 147 148 /** 149 * Unregisters a display transaction listener to provide the client a chance to 150 * update its surfaces within the same transaction as any display layout updates. 151 * 152 * @param listener The listener to unregister. 153 */ unregisterDisplayTransactionListener(DisplayTransactionListener listener)154 public abstract void unregisterDisplayTransactionListener(DisplayTransactionListener listener); 155 156 /** 157 * Overrides the display information of a particular logical display. 158 * This is used by the window manager to control the size and characteristics 159 * of the default display. It is expected to apply the requested change 160 * to the display information synchronously so that applications will immediately 161 * observe the new state. 162 * 163 * NOTE: This method must be the only entry point by which the window manager 164 * influences the logical configuration of displays. 165 * 166 * @param displayId The logical display id. 167 * @param info The new data to be stored. 168 */ setDisplayInfoOverrideFromWindowManager( int displayId, DisplayInfo info)169 public abstract void setDisplayInfoOverrideFromWindowManager( 170 int displayId, DisplayInfo info); 171 172 /** 173 * Get current display info without override from WindowManager. 174 * Current implementation of LogicalDisplay#getDisplayInfoLocked() always returns display info 175 * with overrides from WM if set. This method can be used for getting real display size without 176 * overrides to determine if real changes to display metrics happened. 177 * @param displayId Id of the target display. 178 * @param outInfo {@link DisplayInfo} to fill. 179 */ getNonOverrideDisplayInfo(int displayId, DisplayInfo outInfo)180 public abstract void getNonOverrideDisplayInfo(int displayId, DisplayInfo outInfo); 181 182 /** 183 * Called by the window manager to perform traversals while holding a 184 * surface flinger transaction. 185 */ performTraversal(Transaction t)186 public abstract void performTraversal(Transaction t); 187 188 /** 189 * Tells the display manager about properties of the display that depend on the windows on it. 190 * This includes whether there is interesting unique content on the specified logical display, 191 * and whether the one of the windows has a preferred refresh rate. 192 * <p> 193 * If the display has unique content, then the display manager arranges for it 194 * to be presented on a physical display if appropriate. Otherwise, the display manager 195 * may choose to make the physical display mirror some other logical display. 196 * </p> 197 * 198 * <p> 199 * If one of the windows on the display has a preferred refresh rate that's supported by the 200 * display, then the display manager will request its use. 201 * </p> 202 * 203 * @param displayId The logical display id to update. 204 * @param hasContent True if the logical display has content. This is used to control automatic 205 * mirroring. 206 * @param requestedRefreshRate The preferred refresh rate for the top-most visible window that 207 * has a preference. 208 * @param requestedModeId The preferred mode id for the top-most visible window that has a 209 * preference. 210 * @param requestedMinRefreshRate The preferred lowest refresh rate for the top-most visible 211 * window that has a preference. 212 * @param requestedMaxRefreshRate The preferred highest refresh rate for the top-most visible 213 * window that has a preference. 214 * @param requestedMinimalPostProcessing The preferred minimal post processing setting for the 215 * display. This is true when there is at least one visible window that wants minimal post 216 * processng on. 217 * @param inTraversal True if called from WindowManagerService during a window traversal 218 * prior to call to performTraversalInTransactionFromWindowManager. 219 */ setDisplayProperties(int displayId, boolean hasContent, float requestedRefreshRate, int requestedModeId, float requestedMinRefreshRate, float requestedMaxRefreshRate, boolean requestedMinimalPostProcessing, boolean inTraversal)220 public abstract void setDisplayProperties(int displayId, boolean hasContent, 221 float requestedRefreshRate, int requestedModeId, float requestedMinRefreshRate, 222 float requestedMaxRefreshRate, boolean requestedMinimalPostProcessing, 223 boolean inTraversal); 224 225 /** 226 * Applies an offset to the contents of a display, for example to avoid burn-in. 227 * <p> 228 * TODO: Technically this should be associated with a physical rather than logical 229 * display but this is good enough for now. 230 * </p> 231 * 232 * @param displayId The logical display id to update. 233 * @param x The X offset by which to shift the contents of the display. 234 * @param y The Y offset by which to shift the contents of the display. 235 */ setDisplayOffsets(int displayId, int x, int y)236 public abstract void setDisplayOffsets(int displayId, int x, int y); 237 238 /** 239 * Disables scaling for a display. 240 * 241 * @param displayId The logical display id to disable scaling for. 242 * @param disableScaling {@code true} to disable scaling, 243 * {@code false} to use the default scaling behavior of the logical display. 244 */ setDisplayScalingDisabled(int displayId, boolean disableScaling)245 public abstract void setDisplayScalingDisabled(int displayId, boolean disableScaling); 246 247 /** 248 * Provide a list of UIDs that are present on the display and are allowed to access it. 249 * 250 * @param displayAccessUIDs Mapping displayId -> int array of UIDs. 251 */ setDisplayAccessUIDs(SparseArray<IntArray> displayAccessUIDs)252 public abstract void setDisplayAccessUIDs(SparseArray<IntArray> displayAccessUIDs); 253 254 /** 255 * Persist brightness slider events and ambient brightness stats. 256 */ persistBrightnessTrackerState()257 public abstract void persistBrightnessTrackerState(); 258 259 /** 260 * Notifies the display manager that resource overlays have changed. 261 */ onOverlayChanged()262 public abstract void onOverlayChanged(); 263 264 /** 265 * Get the attributes available for display color sampling. 266 * @param displayId id of the display to collect the sample from. 267 * 268 * @return The attributes the display supports, or null if sampling is not supported. 269 */ 270 @Nullable getDisplayedContentSamplingAttributes( int displayId)271 public abstract DisplayedContentSamplingAttributes getDisplayedContentSamplingAttributes( 272 int displayId); 273 274 /** 275 * Enable or disable the collection of color samples. 276 * 277 * @param displayId id of the display to collect the sample from. 278 * @param componentMask a bitmask of the color channels to collect samples for, or zero for all 279 * available. 280 * @param maxFrames maintain a ringbuffer of the last maxFrames. 281 * @param enable True to enable, False to disable. 282 * 283 * @return True if sampling was enabled, false if failure. 284 */ setDisplayedContentSamplingEnabled( int displayId, boolean enable, int componentMask, int maxFrames)285 public abstract boolean setDisplayedContentSamplingEnabled( 286 int displayId, boolean enable, int componentMask, int maxFrames); 287 288 /** 289 * Accesses the color histogram statistics of displayed frames on devices that support sampling. 290 * 291 * @param displayId id of the display to collect the sample from 292 * @param maxFrames limit the statistics to the last maxFrames number of frames. 293 * @param timestamp discard statistics that were collected prior to timestamp, where timestamp 294 * is given as CLOCK_MONOTONIC. 295 * @return The statistics representing a histogram of the color distribution of the frames 296 * displayed on-screen, or null if sampling is not supported. 297 */ 298 @Nullable getDisplayedContentSample( int displayId, long maxFrames, long timestamp)299 public abstract DisplayedContentSample getDisplayedContentSample( 300 int displayId, long maxFrames, long timestamp); 301 302 /** 303 * Temporarily ignore proximity-sensor-based display behavior until there is a change 304 * to the proximity sensor state. This allows the display to turn back on even if something 305 * is obstructing the proximity sensor. 306 */ ignoreProximitySensorUntilChanged()307 public abstract void ignoreProximitySensorUntilChanged(); 308 309 /** 310 * Returns the refresh rate switching type. 311 */ 312 @DisplayManager.SwitchingType getRefreshRateSwitchingType()313 public abstract int getRefreshRateSwitchingType(); 314 315 /** 316 * TODO: b/191384041 - Replace this with getRefreshRateLimitations() 317 * Return the refresh rate restriction for the specified display and sensor pairing. If the 318 * specified sensor is identified as an associated sensor in the specified display's 319 * display-device-config file, then return any refresh rate restrictions that it might define. 320 * If no restriction is specified, or the sensor is not associated with the display, then null 321 * will be returned. 322 * 323 * @param displayId The display to check against. 324 * @param name The name of the sensor. 325 * @param type The type of sensor. 326 * 327 * @return The min/max refresh-rate restriction as a {@link Pair} of floats, or null if not 328 * restricted. 329 */ getRefreshRateForDisplayAndSensor( int displayId, String name, String type)330 public abstract RefreshRateRange getRefreshRateForDisplayAndSensor( 331 int displayId, String name, String type); 332 333 /** 334 * Returns a list of various refresh rate limitations for the specified display. 335 * 336 * @param displayId The display to get limitations for. 337 * 338 * @return a list of {@link RefreshRateLimitation}s describing the various limits. 339 */ getRefreshRateLimitations(int displayId)340 public abstract List<RefreshRateLimitation> getRefreshRateLimitations(int displayId); 341 342 /** 343 * Describes the requested power state of the display. 344 * 345 * This object is intended to describe the general characteristics of the 346 * power state, such as whether the screen should be on or off and the current 347 * brightness controls leaving the DisplayPowerController to manage the 348 * details of how the transitions between states should occur. The goal is for 349 * the PowerManagerService to focus on the global power state and not 350 * have to micro-manage screen off animations, auto-brightness and other effects. 351 */ 352 public static final class DisplayPowerRequest { 353 // Policy: Turn screen off as if the user pressed the power button 354 // including playing a screen off animation if applicable. 355 public static final int POLICY_OFF = 0; 356 // Policy: Enable dozing and always-on display functionality. 357 public static final int POLICY_DOZE = 1; 358 // Policy: Make the screen dim when the user activity timeout is 359 // about to expire. 360 public static final int POLICY_DIM = 2; 361 // Policy: Make the screen bright as usual. 362 public static final int POLICY_BRIGHT = 3; 363 // Policy: Keep the screen and display optimized for VR mode. 364 public static final int POLICY_VR = 4; 365 366 // The basic overall policy to apply: off, doze, dim or bright. 367 public int policy; 368 369 // If true, the proximity sensor overrides the screen state when an object is 370 // nearby, turning it off temporarily until the object is moved away. 371 public boolean useProximitySensor; 372 373 // An override of the screen brightness. 374 // Set to PowerManager.BRIGHTNESS_INVALID if there's no override. 375 public float screenBrightnessOverride; 376 377 // An override of the screen auto-brightness adjustment factor in the range -1 (dimmer) to 378 // 1 (brighter). Set to Float.NaN if there's no override. 379 public float screenAutoBrightnessAdjustmentOverride; 380 381 // If true, enables automatic brightness control. 382 public boolean useAutoBrightness; 383 384 // If true, scales the brightness to a fraction of desired (as defined by 385 // screenLowPowerBrightnessFactor). 386 public boolean lowPowerMode; 387 388 // The factor to adjust the screen brightness in low power mode in the range 389 // 0 (screen off) to 1 (no change) 390 public float screenLowPowerBrightnessFactor; 391 392 // If true, applies a brightness boost. 393 public boolean boostScreenBrightness; 394 395 // If true, prevents the screen from completely turning on if it is currently off. 396 // The display does not enter a "ready" state if this flag is true and screen on is 397 // blocked. The window manager policy blocks screen on while it prepares the keyguard to 398 // prevent the user from seeing intermediate updates. 399 // 400 // Technically, we may not block the screen itself from turning on (because that introduces 401 // extra unnecessary latency) but we do prevent content on screen from becoming 402 // visible to the user. 403 public boolean blockScreenOn; 404 405 // Overrides the policy for adjusting screen brightness and state while dozing. 406 public int dozeScreenState; 407 public float dozeScreenBrightness; 408 DisplayPowerRequest()409 public DisplayPowerRequest() { 410 policy = POLICY_BRIGHT; 411 useProximitySensor = false; 412 screenBrightnessOverride = PowerManager.BRIGHTNESS_INVALID_FLOAT; 413 useAutoBrightness = false; 414 screenAutoBrightnessAdjustmentOverride = Float.NaN; 415 screenLowPowerBrightnessFactor = 0.5f; 416 blockScreenOn = false; 417 dozeScreenBrightness = PowerManager.BRIGHTNESS_INVALID_FLOAT; 418 dozeScreenState = Display.STATE_UNKNOWN; 419 } 420 DisplayPowerRequest(DisplayPowerRequest other)421 public DisplayPowerRequest(DisplayPowerRequest other) { 422 copyFrom(other); 423 } 424 isBrightOrDim()425 public boolean isBrightOrDim() { 426 return policy == POLICY_BRIGHT || policy == POLICY_DIM; 427 } 428 isVr()429 public boolean isVr() { 430 return policy == POLICY_VR; 431 } 432 copyFrom(DisplayPowerRequest other)433 public void copyFrom(DisplayPowerRequest other) { 434 policy = other.policy; 435 useProximitySensor = other.useProximitySensor; 436 screenBrightnessOverride = other.screenBrightnessOverride; 437 useAutoBrightness = other.useAutoBrightness; 438 screenAutoBrightnessAdjustmentOverride = other.screenAutoBrightnessAdjustmentOverride; 439 screenLowPowerBrightnessFactor = other.screenLowPowerBrightnessFactor; 440 blockScreenOn = other.blockScreenOn; 441 lowPowerMode = other.lowPowerMode; 442 boostScreenBrightness = other.boostScreenBrightness; 443 dozeScreenBrightness = other.dozeScreenBrightness; 444 dozeScreenState = other.dozeScreenState; 445 } 446 447 @Override equals(@ullable Object o)448 public boolean equals(@Nullable Object o) { 449 return o instanceof DisplayPowerRequest 450 && equals((DisplayPowerRequest)o); 451 } 452 equals(DisplayPowerRequest other)453 public boolean equals(DisplayPowerRequest other) { 454 return other != null 455 && policy == other.policy 456 && useProximitySensor == other.useProximitySensor 457 && floatEquals(screenBrightnessOverride, 458 other.screenBrightnessOverride) 459 && useAutoBrightness == other.useAutoBrightness 460 && floatEquals(screenAutoBrightnessAdjustmentOverride, 461 other.screenAutoBrightnessAdjustmentOverride) 462 && screenLowPowerBrightnessFactor 463 == other.screenLowPowerBrightnessFactor 464 && blockScreenOn == other.blockScreenOn 465 && lowPowerMode == other.lowPowerMode 466 && boostScreenBrightness == other.boostScreenBrightness 467 && floatEquals(dozeScreenBrightness, other.dozeScreenBrightness) 468 && dozeScreenState == other.dozeScreenState; 469 } 470 floatEquals(float f1, float f2)471 private boolean floatEquals(float f1, float f2) { 472 return f1 == f2 || Float.isNaN(f1) && Float.isNaN(f2); 473 } 474 475 @Override hashCode()476 public int hashCode() { 477 return 0; // don't care 478 } 479 480 @Override toString()481 public String toString() { 482 return "policy=" + policyToString(policy) 483 + ", useProximitySensor=" + useProximitySensor 484 + ", screenBrightnessOverride=" + screenBrightnessOverride 485 + ", useAutoBrightness=" + useAutoBrightness 486 + ", screenAutoBrightnessAdjustmentOverride=" 487 + screenAutoBrightnessAdjustmentOverride 488 + ", screenLowPowerBrightnessFactor=" + screenLowPowerBrightnessFactor 489 + ", blockScreenOn=" + blockScreenOn 490 + ", lowPowerMode=" + lowPowerMode 491 + ", boostScreenBrightness=" + boostScreenBrightness 492 + ", dozeScreenBrightness=" + dozeScreenBrightness 493 + ", dozeScreenState=" + Display.stateToString(dozeScreenState); 494 } 495 policyToString(int policy)496 public static String policyToString(int policy) { 497 switch (policy) { 498 case POLICY_OFF: 499 return "OFF"; 500 case POLICY_DOZE: 501 return "DOZE"; 502 case POLICY_DIM: 503 return "DIM"; 504 case POLICY_BRIGHT: 505 return "BRIGHT"; 506 case POLICY_VR: 507 return "VR"; 508 default: 509 return Integer.toString(policy); 510 } 511 } 512 } 513 514 /** 515 * Asynchronous callbacks from the power controller to the power manager service. 516 */ 517 public interface DisplayPowerCallbacks { onStateChanged()518 void onStateChanged(); onProximityPositive()519 void onProximityPositive(); onProximityNegative()520 void onProximityNegative(); onDisplayStateChange(boolean allInactive, boolean allOff)521 void onDisplayStateChange(boolean allInactive, boolean allOff); 522 acquireSuspendBlocker()523 void acquireSuspendBlocker(); releaseSuspendBlocker()524 void releaseSuspendBlocker(); 525 } 526 527 /** 528 * Called within a Surface transaction whenever the size or orientation of a 529 * display may have changed. Provides an opportunity for the client to 530 * update the position of its surfaces as part of the same transaction. 531 */ 532 public interface DisplayTransactionListener { onDisplayTransaction(Transaction t)533 void onDisplayTransaction(Transaction t); 534 } 535 536 /** 537 * Called when there are changes to {@link com.android.server.display.DisplayGroup 538 * DisplayGroups}. 539 */ 540 public interface DisplayGroupListener { 541 /** 542 * A new display group with the provided {@code groupId} was added. 543 * 544 * <ol> 545 * <li>The {@code groupId} is applied to all appropriate {@link Display displays}. 546 * <li>This method is called. 547 * <li>{@link android.hardware.display.DisplayManager.DisplayListener DisplayListeners} 548 * are informed of any corresponding changes. 549 * </ol> 550 */ onDisplayGroupAdded(int groupId)551 void onDisplayGroupAdded(int groupId); 552 553 /** 554 * The display group with the provided {@code groupId} was removed. 555 * 556 * <ol> 557 * <li>All affected {@link Display displays} have their group IDs updated appropriately. 558 * <li>{@link android.hardware.display.DisplayManager.DisplayListener DisplayListeners} 559 * are informed of any corresponding changes. 560 * <li>This method is called. 561 * </ol> 562 */ onDisplayGroupRemoved(int groupId)563 void onDisplayGroupRemoved(int groupId); 564 565 /** 566 * The display group with the provided {@code groupId} has changed. 567 * 568 * <ol> 569 * <li>All affected {@link Display displays} have their group IDs updated appropriately. 570 * <li>{@link android.hardware.display.DisplayManager.DisplayListener DisplayListeners} 571 * are informed of any corresponding changes. 572 * <li>This method is called. 573 * </ol> 574 */ onDisplayGroupChanged(int groupId)575 void onDisplayGroupChanged(int groupId); 576 } 577 578 /** 579 * Information about the min and max refresh rate DM would like to set the display to. 580 */ 581 public static final class RefreshRateRange { 582 public static final String TAG = "RefreshRateRange"; 583 584 // The tolerance within which we consider something approximately equals. 585 public static final float FLOAT_TOLERANCE = 0.01f; 586 587 /** 588 * The lowest desired refresh rate. 589 */ 590 public float min; 591 592 /** 593 * The highest desired refresh rate. 594 */ 595 public float max; 596 RefreshRateRange()597 public RefreshRateRange() {} 598 RefreshRateRange(float min, float max)599 public RefreshRateRange(float min, float max) { 600 if (min < 0 || max < 0 || min > max + FLOAT_TOLERANCE) { 601 Slog.e(TAG, "Wrong values for min and max when initializing RefreshRateRange : " 602 + min + " " + max); 603 this.min = this.max = 0; 604 return; 605 } 606 if (min > max) { 607 // Min and max are within epsilon of each other, but in the wrong order. 608 float t = min; 609 min = max; 610 max = t; 611 } 612 this.min = min; 613 this.max = max; 614 } 615 616 /** 617 * Checks whether the two objects have the same values. 618 */ 619 @Override equals(Object other)620 public boolean equals(Object other) { 621 if (other == this) { 622 return true; 623 } 624 625 if (!(other instanceof RefreshRateRange)) { 626 return false; 627 } 628 629 RefreshRateRange refreshRateRange = (RefreshRateRange) other; 630 return (min == refreshRateRange.min && max == refreshRateRange.max); 631 } 632 633 @Override hashCode()634 public int hashCode() { 635 return Objects.hash(min, max); 636 } 637 638 @Override toString()639 public String toString() { 640 return "(" + min + " " + max + ")"; 641 } 642 } 643 644 /** 645 * Describes a limitation on a display's refresh rate. Includes the allowed refresh rate 646 * range as well as information about when it applies, such as high-brightness-mode. 647 */ 648 public static final class RefreshRateLimitation { 649 @RefreshRateLimitType public int type; 650 651 /** The range the that refresh rate should be limited to. */ 652 public RefreshRateRange range; 653 RefreshRateLimitation(@efreshRateLimitType int type, float min, float max)654 public RefreshRateLimitation(@RefreshRateLimitType int type, float min, float max) { 655 this.type = type; 656 range = new RefreshRateRange(min, max); 657 } 658 659 @Override toString()660 public String toString() { 661 return "RefreshRateLimitation(" + type + ": " + range + ")"; 662 } 663 } 664 } 665