Debian Codegraph @

core/java/android/hardware/display/DisplayManagerInternal.java

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