1 /* 2 * Copyright (C) 2012 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 static android.view.Display.DEFAULT_DISPLAY; 20 import static android.view.Display.HdrCapabilities.HdrType; 21 22 import android.Manifest; 23 import android.annotation.FloatRange; 24 import android.annotation.IntDef; 25 import android.annotation.LongDef; 26 import android.annotation.NonNull; 27 import android.annotation.Nullable; 28 import android.annotation.RequiresPermission; 29 import android.annotation.SystemApi; 30 import android.annotation.SystemService; 31 import android.annotation.TestApi; 32 import android.app.KeyguardManager; 33 import android.compat.annotation.UnsupportedAppUsage; 34 import android.content.Context; 35 import android.content.res.Resources; 36 import android.graphics.Point; 37 import android.media.projection.MediaProjection; 38 import android.os.Build; 39 import android.os.Handler; 40 import android.util.Pair; 41 import android.util.Slog; 42 import android.util.SparseArray; 43 import android.view.Display; 44 import android.view.Surface; 45 46 import java.lang.annotation.Retention; 47 import java.lang.annotation.RetentionPolicy; 48 import java.util.ArrayList; 49 import java.util.List; 50 51 52 /** 53 * Manages the properties of attached displays. 54 */ 55 @SystemService(Context.DISPLAY_SERVICE) 56 public final class DisplayManager { 57 private static final String TAG = "DisplayManager"; 58 private static final boolean DEBUG = false; 59 60 private final Context mContext; 61 private final DisplayManagerGlobal mGlobal; 62 63 private final Object mLock = new Object(); 64 private final SparseArray<Display> mDisplays = new SparseArray<Display>(); 65 66 private final ArrayList<Display> mTempDisplays = new ArrayList<Display>(); 67 68 /** 69 * Broadcast receiver that indicates when the Wifi display status changes. 70 * <p> 71 * The status is provided as a {@link WifiDisplayStatus} object in the 72 * {@link #EXTRA_WIFI_DISPLAY_STATUS} extra. 73 * </p><p> 74 * This broadcast is only sent to registered receivers and can only be sent by the system. 75 * </p> 76 * @hide 77 */ 78 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 79 public static final String ACTION_WIFI_DISPLAY_STATUS_CHANGED = 80 "android.hardware.display.action.WIFI_DISPLAY_STATUS_CHANGED"; 81 82 /** 83 * Contains a {@link WifiDisplayStatus} object. 84 * @hide 85 */ 86 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 87 public static final String EXTRA_WIFI_DISPLAY_STATUS = 88 "android.hardware.display.extra.WIFI_DISPLAY_STATUS"; 89 90 /** 91 * Display category: Presentation displays. 92 * <p> 93 * This category can be used to identify secondary displays that are suitable for 94 * use as presentation displays such as external or wireless displays. Applications 95 * may automatically project their content to presentation displays to provide 96 * richer second screen experiences. 97 * </p> 98 * 99 * @see android.app.Presentation 100 * @see Display#FLAG_PRESENTATION 101 * @see #getDisplays(String) 102 */ 103 public static final String DISPLAY_CATEGORY_PRESENTATION = 104 "android.hardware.display.category.PRESENTATION"; 105 106 /** 107 * Virtual display flag: Create a public display. 108 * 109 * <h3>Public virtual displays</h3> 110 * <p> 111 * When this flag is set, the virtual display is public. 112 * </p><p> 113 * A public virtual display behaves just like most any other display that is connected 114 * to the system such as an external or wireless display. Applications can open 115 * windows on the display and the system may mirror the contents of other displays 116 * onto it. 117 * </p><p> 118 * Creating a public virtual display that isn't restricted to own-content only implicitly 119 * creates an auto-mirroring display. See {@link #VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR} for 120 * restrictions on who is allowed to create an auto-mirroring display. 121 * </p> 122 * 123 * <h3>Private virtual displays</h3> 124 * <p> 125 * When this flag is not set, the virtual display is private as defined by the 126 * {@link Display#FLAG_PRIVATE} display flag. 127 * </p> 128 * 129 * <p> 130 * A private virtual display belongs to the application that created it. Only the a owner of a 131 * private virtual display and the apps that are already on that display are allowed to place 132 * windows upon it. The private virtual display also does not participate in display mirroring: 133 * it will neither receive mirrored content from another display nor allow its own content to be 134 * mirrored elsewhere. More precisely, the only processes that are allowed to enumerate or 135 * interact with the private display are those that have the same UID as the application that 136 * originally created the private virtual display or as the activities that are already on that 137 * display. 138 * </p> 139 * 140 * @see #createVirtualDisplay 141 * @see #VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY 142 * @see #VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR 143 */ 144 public static final int VIRTUAL_DISPLAY_FLAG_PUBLIC = 1 << 0; 145 146 /** 147 * Virtual display flag: Create a presentation display. 148 * 149 * <h3>Presentation virtual displays</h3> 150 * <p> 151 * When this flag is set, the virtual display is registered as a presentation 152 * display in the {@link #DISPLAY_CATEGORY_PRESENTATION presentation display category}. 153 * Applications may automatically project their content to presentation displays 154 * to provide richer second screen experiences. 155 * </p> 156 * 157 * <h3>Non-presentation virtual displays</h3> 158 * <p> 159 * When this flag is not set, the virtual display is not registered as a presentation 160 * display. Applications can still project their content on the display but they 161 * will typically not do so automatically. This option is appropriate for 162 * more special-purpose displays. 163 * </p> 164 * 165 * @see android.app.Presentation 166 * @see #createVirtualDisplay 167 * @see #DISPLAY_CATEGORY_PRESENTATION 168 * @see Display#FLAG_PRESENTATION 169 */ 170 public static final int VIRTUAL_DISPLAY_FLAG_PRESENTATION = 1 << 1; 171 172 /** 173 * Virtual display flag: Create a secure display. 174 * 175 * <h3>Secure virtual displays</h3> 176 * <p> 177 * When this flag is set, the virtual display is considered secure as defined 178 * by the {@link Display#FLAG_SECURE} display flag. The caller promises to take 179 * reasonable measures, such as over-the-air encryption, to prevent the contents 180 * of the display from being intercepted or recorded on a persistent medium. 181 * </p><p> 182 * Creating a secure virtual display requires the CAPTURE_SECURE_VIDEO_OUTPUT permission. 183 * This permission is reserved for use by system components and is not available to 184 * third-party applications. 185 * </p> 186 * 187 * <h3>Non-secure virtual displays</h3> 188 * <p> 189 * When this flag is not set, the virtual display is considered unsecure. 190 * The content of secure windows will be blanked if shown on this display. 191 * </p> 192 * 193 * @see Display#FLAG_SECURE 194 * @see #createVirtualDisplay 195 */ 196 public static final int VIRTUAL_DISPLAY_FLAG_SECURE = 1 << 2; 197 198 /** 199 * Virtual display flag: Only show this display's own content; do not mirror 200 * the content of another display. 201 * 202 * <p> 203 * This flag is used in conjunction with {@link #VIRTUAL_DISPLAY_FLAG_PUBLIC}. 204 * Ordinarily public virtual displays will automatically mirror the content of the 205 * default display if they have no windows of their own. When this flag is 206 * specified, the virtual display will only ever show its own content and 207 * will be blanked instead if it has no windows. 208 * </p> 209 * 210 * <p> 211 * This flag is mutually exclusive with {@link #VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR}. If both 212 * flags are specified then the own-content only behavior will be applied. 213 * </p> 214 * 215 * <p> 216 * This behavior of this flag is implied whenever neither {@link #VIRTUAL_DISPLAY_FLAG_PUBLIC} 217 * nor {@link #VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR} have been set. This flag is only required to 218 * override the default behavior when creating a public display. 219 * </p> 220 * 221 * @see #createVirtualDisplay 222 */ 223 public static final int VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY = 1 << 3; 224 225 226 /** 227 * Virtual display flag: Allows content to be mirrored on private displays when no content is 228 * being shown. 229 * 230 * <p> 231 * This flag is mutually exclusive with {@link #VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY}. 232 * If both flags are specified then the own-content only behavior will be applied. 233 * </p> 234 * 235 * <p> 236 * The behavior of this flag is implied whenever {@link #VIRTUAL_DISPLAY_FLAG_PUBLIC} is set 237 * and {@link #VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY} has not been set. This flag is only 238 * required to override the default behavior when creating a private display. 239 * </p> 240 * 241 * <p> 242 * Creating an auto-mirroing virtual display requires the CAPTURE_VIDEO_OUTPUT 243 * or CAPTURE_SECURE_VIDEO_OUTPUT permission. 244 * These permissions are reserved for use by system components and are not available to 245 * third-party applications. 246 * 247 * Alternatively, an appropriate {@link MediaProjection} may be used to create an 248 * auto-mirroring virtual display. 249 * </p> 250 * 251 * @see #createVirtualDisplay 252 */ 253 public static final int VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR = 1 << 4; 254 255 /** 256 * Virtual display flag: Allows content to be displayed on private virtual displays when 257 * keyguard is shown but is insecure. 258 * 259 * <p> 260 * This might be used in a case when the content of a virtual display is captured and sent to an 261 * external hardware display that is not visible to the system directly. This flag will allow 262 * the continued display of content while other displays will be covered by a keyguard which 263 * doesn't require providing credentials to unlock. This means that there is either no password 264 * or other authentication method set, or the device is in a trusted state - 265 * {@link android.service.trust.TrustAgentService} has available and active trust agent. 266 * </p><p> 267 * This flag can only be applied to private displays as defined by the 268 * {@link Display#FLAG_PRIVATE} display flag. It is mutually exclusive with 269 * {@link #VIRTUAL_DISPLAY_FLAG_PUBLIC}. If both flags are specified then this flag's behavior 270 * will not be applied. 271 * </p> 272 * 273 * @see #createVirtualDisplay 274 * @see KeyguardManager#isDeviceSecure() 275 * @see KeyguardManager#isDeviceLocked() 276 * @hide 277 */ 278 // TODO (b/114338689): Remove the flag and use IWindowManager#shouldShowWithInsecureKeyguard 279 // TODO: Update name and documentation and un-hide the flag. Don't change the value before that. 280 public static final int VIRTUAL_DISPLAY_FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD = 1 << 5; 281 282 /** 283 * Virtual display flag: Specifies that the virtual display can be associated with a 284 * touchpad device that matches its uniqueId. 285 * 286 * @see #createVirtualDisplay 287 * @hide 288 */ 289 public static final int VIRTUAL_DISPLAY_FLAG_SUPPORTS_TOUCH = 1 << 6; 290 291 /** 292 * Virtual display flag: Indicates that the orientation of this display device is coupled to 293 * the rotation of its associated logical display. 294 * 295 * @see #createVirtualDisplay 296 * @hide 297 */ 298 public static final int VIRTUAL_DISPLAY_FLAG_ROTATES_WITH_CONTENT = 1 << 7; 299 300 /** 301 * Virtual display flag: Indicates that the contents will be destroyed once 302 * the display is removed. 303 * 304 * Public virtual displays without this flag will move their content to main display 305 * stack once they're removed. Private vistual displays will always destroy their 306 * content on removal even without this flag. 307 * 308 * @see #createVirtualDisplay 309 * @hide 310 */ 311 // TODO (b/114338689): Remove the flag and use WindowManager#REMOVE_CONTENT_MODE_DESTROY 312 public static final int VIRTUAL_DISPLAY_FLAG_DESTROY_CONTENT_ON_REMOVAL = 1 << 8; 313 314 /** 315 * Virtual display flag: Indicates that the display should support system decorations. Virtual 316 * displays without this flag shouldn't show home, IME or any other system decorations. 317 * <p>This flag doesn't work without {@link #VIRTUAL_DISPLAY_FLAG_TRUSTED}</p> 318 * 319 * @see #createVirtualDisplay 320 * @see #VIRTUAL_DISPLAY_FLAG_TRUSTED 321 * @hide 322 */ 323 // TODO (b/114338689): Remove the flag and use IWindowManager#setShouldShowSystemDecors 324 @TestApi 325 public static final int VIRTUAL_DISPLAY_FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS = 1 << 9; 326 327 /** 328 * Virtual display flags: Indicates that the display is trusted to show system decorations and 329 * receive inputs without users' touch. 330 * 331 * @see #createVirtualDisplay 332 * @see #VIRTUAL_DISPLAY_FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS 333 * @hide 334 */ 335 @TestApi 336 public static final int VIRTUAL_DISPLAY_FLAG_TRUSTED = 1 << 10; 337 338 /** 339 * Virtual display flags: Indicates that the display should not be a part of the default 340 * DisplayGroup and instead be part of a new DisplayGroup. 341 * 342 * @see #createVirtualDisplay 343 * @hide 344 */ 345 public static final int VIRTUAL_DISPLAY_FLAG_OWN_DISPLAY_GROUP = 1 << 11; 346 347 348 /** @hide */ 349 @IntDef(prefix = {"MATCH_CONTENT_FRAMERATE_"}, value = { 350 MATCH_CONTENT_FRAMERATE_UNKNOWN, 351 MATCH_CONTENT_FRAMERATE_NEVER, 352 MATCH_CONTENT_FRAMERATE_SEAMLESSS_ONLY, 353 MATCH_CONTENT_FRAMERATE_ALWAYS, 354 }) 355 @Retention(RetentionPolicy.SOURCE) 356 public @interface MatchContentFrameRateType {} 357 358 /** 359 * Match content frame rate user preference is unknown. 360 */ 361 public static final int MATCH_CONTENT_FRAMERATE_UNKNOWN = -1; 362 363 /** 364 * No mode switching is allowed. 365 */ 366 public static final int MATCH_CONTENT_FRAMERATE_NEVER = 0; 367 368 /** 369 * Only refresh rate switches without visual interruptions are allowed. 370 */ 371 public static final int MATCH_CONTENT_FRAMERATE_SEAMLESSS_ONLY = 1; 372 373 /** 374 * Refresh rate switches between all refresh rates are allowed even if they have visual 375 * interruptions for the user. 376 */ 377 public static final int MATCH_CONTENT_FRAMERATE_ALWAYS = 2; 378 379 /** @hide */ 380 @IntDef(prefix = {"SWITCHING_TYPE_"}, value = { 381 SWITCHING_TYPE_NONE, 382 SWITCHING_TYPE_WITHIN_GROUPS, 383 SWITCHING_TYPE_ACROSS_AND_WITHIN_GROUPS, 384 }) 385 @Retention(RetentionPolicy.SOURCE) 386 public @interface SwitchingType {} 387 388 /** 389 * No mode switching will happen. 390 * @hide 391 */ 392 @TestApi 393 public static final int SWITCHING_TYPE_NONE = 0; 394 395 /** 396 * Allow only refresh rate switching between modes in the same configuration group. This way 397 * only switches without visual interruptions for the user will be allowed. 398 * @hide 399 */ 400 @TestApi 401 public static final int SWITCHING_TYPE_WITHIN_GROUPS = 1; 402 403 /** 404 * Allow refresh rate switching between all refresh rates even if the switch with have visual 405 * interruptions for the user. 406 * @hide 407 */ 408 @TestApi 409 public static final int SWITCHING_TYPE_ACROSS_AND_WITHIN_GROUPS = 2; 410 411 /** 412 * @hide 413 */ 414 @LongDef(flag = true, prefix = {"EVENT_FLAG_"}, value = { 415 EVENT_FLAG_DISPLAY_ADDED, 416 EVENT_FLAG_DISPLAY_CHANGED, 417 EVENT_FLAG_DISPLAY_REMOVED, 418 EVENT_FLAG_DISPLAY_BRIGHTNESS 419 }) 420 @Retention(RetentionPolicy.SOURCE) 421 public @interface EventsMask {} 422 423 /** 424 * Event type for when a new display is added. 425 * 426 * @see #registerDisplayListener(DisplayListener, Handler, long) 427 * 428 * @hide 429 */ 430 public static final long EVENT_FLAG_DISPLAY_ADDED = 1L << 0; 431 432 /** 433 * Event type for when a display is removed. 434 * 435 * @see #registerDisplayListener(DisplayListener, Handler, long) 436 * 437 * @hide 438 */ 439 public static final long EVENT_FLAG_DISPLAY_REMOVED = 1L << 1; 440 441 /** 442 * Event type for when a display is changed. 443 * 444 * @see #registerDisplayListener(DisplayListener, Handler, long) 445 * 446 * @hide 447 */ 448 public static final long EVENT_FLAG_DISPLAY_CHANGED = 1L << 2; 449 450 /** 451 * Event flag to register for a display's brightness changes. This notification is sent 452 * through the {@link DisplayListener#onDisplayChanged} callback method. New brightness 453 * values can be retrieved via {@link android.view.Display#getBrightnessInfo()}. 454 * 455 * @see #registerDisplayListener(DisplayListener, Handler, long) 456 * 457 * @hide 458 */ 459 public static final long EVENT_FLAG_DISPLAY_BRIGHTNESS = 1L << 3; 460 461 /** @hide */ DisplayManager(Context context)462 public DisplayManager(Context context) { 463 mContext = context; 464 mGlobal = DisplayManagerGlobal.getInstance(); 465 } 466 467 /** 468 * Gets information about a logical display. 469 * 470 * The display metrics may be adjusted to provide compatibility 471 * for legacy applications. 472 * 473 * @param displayId The logical display id. 474 * @return The display object, or null if there is no valid display with the given id. 475 */ getDisplay(int displayId)476 public Display getDisplay(int displayId) { 477 synchronized (mLock) { 478 return getOrCreateDisplayLocked(displayId, false /*assumeValid*/); 479 } 480 } 481 482 /** 483 * Gets all currently valid logical displays. 484 * 485 * @return An array containing all displays. 486 */ getDisplays()487 public Display[] getDisplays() { 488 return getDisplays(null); 489 } 490 491 /** 492 * Gets all currently valid logical displays of the specified category. 493 * <p> 494 * When there are multiple displays in a category the returned displays are sorted 495 * of preference. For example, if the requested category is 496 * {@link #DISPLAY_CATEGORY_PRESENTATION} and there are multiple presentation displays 497 * then the displays are sorted so that the first display in the returned array 498 * is the most preferred presentation display. The application may simply 499 * use the first display or allow the user to choose. 500 * </p> 501 * 502 * @param category The requested display category or null to return all displays. 503 * @return An array containing all displays sorted by order of preference. 504 * 505 * @see #DISPLAY_CATEGORY_PRESENTATION 506 */ getDisplays(String category)507 public Display[] getDisplays(String category) { 508 final int[] displayIds = mGlobal.getDisplayIds(); 509 synchronized (mLock) { 510 try { 511 if (category == null) { 512 addAllDisplaysLocked(mTempDisplays, displayIds); 513 } else if (category.equals(DISPLAY_CATEGORY_PRESENTATION)) { 514 addPresentationDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_WIFI); 515 addPresentationDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_EXTERNAL); 516 addPresentationDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_OVERLAY); 517 addPresentationDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_VIRTUAL); 518 addPresentationDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_INTERNAL); 519 } 520 return mTempDisplays.toArray(new Display[mTempDisplays.size()]); 521 } finally { 522 mTempDisplays.clear(); 523 } 524 } 525 } 526 addAllDisplaysLocked(ArrayList<Display> displays, int[] displayIds)527 private void addAllDisplaysLocked(ArrayList<Display> displays, int[] displayIds) { 528 for (int i = 0; i < displayIds.length; i++) { 529 Display display = getOrCreateDisplayLocked(displayIds[i], true /*assumeValid*/); 530 if (display != null) { 531 displays.add(display); 532 } 533 } 534 } 535 addPresentationDisplaysLocked( ArrayList<Display> displays, int[] displayIds, int matchType)536 private void addPresentationDisplaysLocked( 537 ArrayList<Display> displays, int[] displayIds, int matchType) { 538 for (int i = 0; i < displayIds.length; i++) { 539 if (displayIds[i] == DEFAULT_DISPLAY) { 540 continue; 541 } 542 Display display = getOrCreateDisplayLocked(displayIds[i], true /*assumeValid*/); 543 if (display != null 544 && (display.getFlags() & Display.FLAG_PRESENTATION) != 0 545 && display.getType() == matchType) { 546 displays.add(display); 547 } 548 } 549 } 550 getOrCreateDisplayLocked(int displayId, boolean assumeValid)551 private Display getOrCreateDisplayLocked(int displayId, boolean assumeValid) { 552 Display display = mDisplays.get(displayId); 553 if (display == null) { 554 // TODO: We cannot currently provide any override configurations for metrics on displays 555 // other than the display the context is associated with. 556 final Resources resources = mContext.getDisplayId() == displayId 557 ? mContext.getResources() : null; 558 559 display = mGlobal.getCompatibleDisplay(displayId, resources); 560 if (display != null) { 561 mDisplays.put(displayId, display); 562 } 563 } else if (!assumeValid && !display.isValid()) { 564 display = null; 565 } 566 return display; 567 } 568 569 /** 570 * Registers a display listener to receive notifications about when 571 * displays are added, removed or changed. 572 * 573 * @param listener The listener to register. 574 * @param handler The handler on which the listener should be invoked, or null 575 * if the listener should be invoked on the calling thread's looper. 576 * 577 * @see #unregisterDisplayListener 578 */ registerDisplayListener(DisplayListener listener, Handler handler)579 public void registerDisplayListener(DisplayListener listener, Handler handler) { 580 registerDisplayListener(listener, handler, EVENT_FLAG_DISPLAY_ADDED 581 | EVENT_FLAG_DISPLAY_CHANGED | EVENT_FLAG_DISPLAY_REMOVED); 582 } 583 584 /** 585 * Registers a display listener to receive notifications about given display event types. 586 * 587 * @param listener The listener to register. 588 * @param handler The handler on which the listener should be invoked, or null 589 * if the listener should be invoked on the calling thread's looper. 590 * @param eventsMask A bitmask of the event types for which this listener is subscribed. 591 * 592 * @see #EVENT_FLAG_DISPLAY_ADDED 593 * @see #EVENT_FLAG_DISPLAY_CHANGED 594 * @see #EVENT_FLAG_DISPLAY_REMOVED 595 * @see #EVENT_FLAG_DISPLAY_BRIGHTNESS 596 * @see #registerDisplayListener(DisplayListener, Handler) 597 * @see #unregisterDisplayListener 598 * 599 * @hide 600 */ registerDisplayListener(@onNull DisplayListener listener, @Nullable Handler handler, @EventsMask long eventsMask)601 public void registerDisplayListener(@NonNull DisplayListener listener, 602 @Nullable Handler handler, @EventsMask long eventsMask) { 603 mGlobal.registerDisplayListener(listener, handler, eventsMask); 604 } 605 606 /** 607 * Unregisters a display listener. 608 * 609 * @param listener The listener to unregister. 610 * 611 * @see #registerDisplayListener 612 */ unregisterDisplayListener(DisplayListener listener)613 public void unregisterDisplayListener(DisplayListener listener) { 614 mGlobal.unregisterDisplayListener(listener); 615 } 616 617 /** 618 * Starts scanning for available Wifi displays. 619 * The results are sent as a {@link #ACTION_WIFI_DISPLAY_STATUS_CHANGED} broadcast. 620 * <p> 621 * Calls to this method nest and must be matched by an equal number of calls to 622 * {@link #stopWifiDisplayScan()}. 623 * </p><p> 624 * Requires {@link android.Manifest.permission#CONFIGURE_WIFI_DISPLAY}. 625 * </p> 626 * 627 * @hide 628 */ 629 @UnsupportedAppUsage startWifiDisplayScan()630 public void startWifiDisplayScan() { 631 mGlobal.startWifiDisplayScan(); 632 } 633 634 /** 635 * Stops scanning for available Wifi displays. 636 * <p> 637 * Requires {@link android.Manifest.permission#CONFIGURE_WIFI_DISPLAY}. 638 * </p> 639 * 640 * @hide 641 */ 642 @UnsupportedAppUsage stopWifiDisplayScan()643 public void stopWifiDisplayScan() { 644 mGlobal.stopWifiDisplayScan(); 645 } 646 647 /** 648 * Connects to a Wifi display. 649 * The results are sent as a {@link #ACTION_WIFI_DISPLAY_STATUS_CHANGED} broadcast. 650 * <p> 651 * Automatically remembers the display after a successful connection, if not 652 * already remembered. 653 * </p><p> 654 * Requires {@link android.Manifest.permission#CONFIGURE_WIFI_DISPLAY}. 655 * </p> 656 * 657 * @param deviceAddress The MAC address of the device to which we should connect. 658 * @hide 659 */ 660 @UnsupportedAppUsage connectWifiDisplay(String deviceAddress)661 public void connectWifiDisplay(String deviceAddress) { 662 mGlobal.connectWifiDisplay(deviceAddress); 663 } 664 665 /** @hide */ 666 @UnsupportedAppUsage pauseWifiDisplay()667 public void pauseWifiDisplay() { 668 mGlobal.pauseWifiDisplay(); 669 } 670 671 /** @hide */ 672 @UnsupportedAppUsage resumeWifiDisplay()673 public void resumeWifiDisplay() { 674 mGlobal.resumeWifiDisplay(); 675 } 676 677 /** 678 * Disconnects from the current Wifi display. 679 * The results are sent as a {@link #ACTION_WIFI_DISPLAY_STATUS_CHANGED} broadcast. 680 * @hide 681 */ 682 @UnsupportedAppUsage disconnectWifiDisplay()683 public void disconnectWifiDisplay() { 684 mGlobal.disconnectWifiDisplay(); 685 } 686 687 /** 688 * Renames a Wifi display. 689 * <p> 690 * The display must already be remembered for this call to succeed. In other words, 691 * we must already have successfully connected to the display at least once and then 692 * not forgotten it. 693 * </p><p> 694 * Requires {@link android.Manifest.permission#CONFIGURE_WIFI_DISPLAY}. 695 * </p> 696 * 697 * @param deviceAddress The MAC address of the device to rename. 698 * @param alias The alias name by which to remember the device, or null 699 * or empty if no alias should be used. 700 * @hide 701 */ 702 @UnsupportedAppUsage renameWifiDisplay(String deviceAddress, String alias)703 public void renameWifiDisplay(String deviceAddress, String alias) { 704 mGlobal.renameWifiDisplay(deviceAddress, alias); 705 } 706 707 /** 708 * Forgets a previously remembered Wifi display. 709 * <p> 710 * Automatically disconnects from the display if currently connected to it. 711 * </p><p> 712 * Requires {@link android.Manifest.permission#CONFIGURE_WIFI_DISPLAY}. 713 * </p> 714 * 715 * @param deviceAddress The MAC address of the device to forget. 716 * @hide 717 */ 718 @UnsupportedAppUsage forgetWifiDisplay(String deviceAddress)719 public void forgetWifiDisplay(String deviceAddress) { 720 mGlobal.forgetWifiDisplay(deviceAddress); 721 } 722 723 /** 724 * Gets the current Wifi display status. 725 * Watch for changes in the status by registering a broadcast receiver for 726 * {@link #ACTION_WIFI_DISPLAY_STATUS_CHANGED}. 727 * 728 * @return The current Wifi display status. 729 * @hide 730 */ 731 @UnsupportedAppUsage getWifiDisplayStatus()732 public WifiDisplayStatus getWifiDisplayStatus() { 733 return mGlobal.getWifiDisplayStatus(); 734 } 735 736 /** 737 * Set the level of color saturation to apply to the display. 738 * @param level The amount of saturation to apply, between 0 and 1 inclusive. 739 * 0 produces a grayscale image, 1 is normal. 740 * 741 * @hide 742 * @deprecated use {@link ColorDisplayManager#setSaturationLevel(int)} instead. The level passed 743 * as a parameter here will be rounded to the nearest hundredth. 744 */ 745 @SystemApi 746 @RequiresPermission(Manifest.permission.CONTROL_DISPLAY_SATURATION) setSaturationLevel(float level)747 public void setSaturationLevel(float level) { 748 if (level < 0f || level > 1f) { 749 throw new IllegalArgumentException("Saturation level must be between 0 and 1"); 750 } 751 final ColorDisplayManager cdm = mContext.getSystemService(ColorDisplayManager.class); 752 cdm.setSaturationLevel(Math.round(level * 100f)); 753 } 754 755 /** 756 * Sets the HDR types that have been disabled by user. 757 * @param userDisabledTypes the HDR types to disable. 758 * @hide 759 */ 760 @TestApi 761 @RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS) setUserDisabledHdrTypes(@onNull @drType int[] userDisabledTypes)762 public void setUserDisabledHdrTypes(@NonNull @HdrType int[] userDisabledTypes) { 763 mGlobal.setUserDisabledHdrTypes(userDisabledTypes); 764 } 765 766 /** 767 * Sets whether or not the user disabled HDR types are returned from 768 * {@link Display#getHdrCapabilities}. 769 * 770 * @param areUserDisabledHdrTypesAllowed If true, the user-disabled types 771 * are ignored and returned, if the display supports them. If false, the 772 * user-disabled types are taken into consideration and are never returned, 773 * even if the display supports them. 774 * @hide 775 */ 776 @TestApi 777 @RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS) setAreUserDisabledHdrTypesAllowed(boolean areUserDisabledHdrTypesAllowed)778 public void setAreUserDisabledHdrTypesAllowed(boolean areUserDisabledHdrTypesAllowed) { 779 mGlobal.setAreUserDisabledHdrTypesAllowed(areUserDisabledHdrTypesAllowed); 780 } 781 782 /** 783 * Returns whether or not the user-disabled HDR types are returned from 784 * {@link Display#getHdrCapabilities}. 785 * 786 * @hide 787 */ 788 @TestApi areUserDisabledHdrTypesAllowed()789 public boolean areUserDisabledHdrTypesAllowed() { 790 return mGlobal.areUserDisabledHdrTypesAllowed(); 791 } 792 793 /** 794 * Returns the HDR formats disabled by the user. 795 * 796 * @hide 797 */ 798 @TestApi getUserDisabledHdrTypes()799 public @NonNull int[] getUserDisabledHdrTypes() { 800 return mGlobal.getUserDisabledHdrTypes(); 801 } 802 803 804 /** 805 * Creates a virtual display. 806 * 807 * @see #createVirtualDisplay(String, int, int, int, Surface, int, 808 * VirtualDisplay.Callback, Handler) 809 */ createVirtualDisplay(@onNull String name, int width, int height, int densityDpi, @Nullable Surface surface, int flags)810 public VirtualDisplay createVirtualDisplay(@NonNull String name, 811 int width, int height, int densityDpi, @Nullable Surface surface, int flags) { 812 return createVirtualDisplay(name, width, height, densityDpi, surface, flags, null, null); 813 } 814 815 /** 816 * Creates a virtual display. 817 * <p> 818 * The content of a virtual display is rendered to a {@link Surface} provided 819 * by the application. 820 * </p><p> 821 * The virtual display should be {@link VirtualDisplay#release released} 822 * when no longer needed. Because a virtual display renders to a surface 823 * provided by the application, it will be released automatically when the 824 * process terminates and all remaining windows on it will be forcibly removed. 825 * </p><p> 826 * The behavior of the virtual display depends on the flags that are provided 827 * to this method. By default, virtual displays are created to be private, 828 * non-presentation and unsecure. Permissions may be required to use certain flags. 829 * </p><p> 830 * As of {@link android.os.Build.VERSION_CODES#KITKAT_WATCH}, the surface may 831 * be attached or detached dynamically using {@link VirtualDisplay#setSurface}. 832 * Previously, the surface had to be non-null when {@link #createVirtualDisplay} 833 * was called and could not be changed for the lifetime of the display. 834 * </p><p> 835 * Detaching the surface that backs a virtual display has a similar effect to 836 * turning off the screen. 837 * </p> 838 * 839 * @param name The name of the virtual display, must be non-empty. 840 * @param width The width of the virtual display in pixels, must be greater than 0. 841 * @param height The height of the virtual display in pixels, must be greater than 0. 842 * @param densityDpi The density of the virtual display in dpi, must be greater than 0. 843 * @param surface The surface to which the content of the virtual display should 844 * be rendered, or null if there is none initially. 845 * @param flags A combination of virtual display flags: 846 * {@link #VIRTUAL_DISPLAY_FLAG_PUBLIC}, {@link #VIRTUAL_DISPLAY_FLAG_PRESENTATION}, 847 * {@link #VIRTUAL_DISPLAY_FLAG_SECURE}, {@link #VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY}, 848 * or {@link #VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR}. 849 * @param callback Callback to call when the state of the {@link VirtualDisplay} changes 850 * @param handler The handler on which the listener should be invoked, or null 851 * if the listener should be invoked on the calling thread's looper. 852 * @return The newly created virtual display, or null if the application could 853 * not create the virtual display. 854 * 855 * @throws SecurityException if the caller does not have permission to create 856 * a virtual display with the specified flags. 857 */ createVirtualDisplay(@onNull String name, int width, int height, int densityDpi, @Nullable Surface surface, int flags, @Nullable VirtualDisplay.Callback callback, @Nullable Handler handler)858 public VirtualDisplay createVirtualDisplay(@NonNull String name, 859 int width, int height, int densityDpi, @Nullable Surface surface, int flags, 860 @Nullable VirtualDisplay.Callback callback, @Nullable Handler handler) { 861 final VirtualDisplayConfig.Builder builder = new VirtualDisplayConfig.Builder(name, width, 862 height, densityDpi); 863 builder.setFlags(flags); 864 if (surface != null) { 865 builder.setSurface(surface); 866 } 867 return createVirtualDisplay(null /* projection */, builder.build(), callback, handler); 868 } 869 870 // TODO : Remove this hidden API after remove all callers. (Refer to MultiDisplayService) 871 /** @hide */ createVirtualDisplay(@ullable MediaProjection projection, @NonNull String name, int width, int height, int densityDpi, @Nullable Surface surface, int flags, @Nullable VirtualDisplay.Callback callback, @Nullable Handler handler, @Nullable String uniqueId)872 public VirtualDisplay createVirtualDisplay(@Nullable MediaProjection projection, 873 @NonNull String name, int width, int height, int densityDpi, @Nullable Surface surface, 874 int flags, @Nullable VirtualDisplay.Callback callback, @Nullable Handler handler, 875 @Nullable String uniqueId) { 876 final VirtualDisplayConfig.Builder builder = new VirtualDisplayConfig.Builder(name, width, 877 height, densityDpi); 878 builder.setFlags(flags); 879 if (uniqueId != null) { 880 builder.setUniqueId(uniqueId); 881 } 882 if (surface != null) { 883 builder.setSurface(surface); 884 } 885 return createVirtualDisplay(projection, builder.build(), callback, handler); 886 } 887 888 /** @hide */ createVirtualDisplay(@ullable MediaProjection projection, @NonNull VirtualDisplayConfig virtualDisplayConfig, @Nullable VirtualDisplay.Callback callback, @Nullable Handler handler)889 public VirtualDisplay createVirtualDisplay(@Nullable MediaProjection projection, 890 @NonNull VirtualDisplayConfig virtualDisplayConfig, 891 @Nullable VirtualDisplay.Callback callback, @Nullable Handler handler) { 892 return mGlobal.createVirtualDisplay(mContext, projection, virtualDisplayConfig, callback, 893 handler); 894 } 895 896 /** 897 * Gets the stable device display size, in pixels. 898 * 899 * This should really only be used for things like server-side filtering of available 900 * applications. Most applications don't need the level of stability guaranteed by this and 901 * should instead query either the size of the display they're currently running on or the 902 * size of the default display. 903 * @hide 904 */ 905 @SystemApi getStableDisplaySize()906 public Point getStableDisplaySize() { 907 return mGlobal.getStableDisplaySize(); 908 } 909 910 /** 911 * Fetch {@link BrightnessChangeEvent}s. 912 * @hide until we make it a system api. 913 */ 914 @SystemApi 915 @RequiresPermission(Manifest.permission.BRIGHTNESS_SLIDER_USAGE) getBrightnessEvents()916 public List<BrightnessChangeEvent> getBrightnessEvents() { 917 return mGlobal.getBrightnessEvents(mContext.getOpPackageName()); 918 } 919 920 /** 921 * Fetch {@link AmbientBrightnessDayStats}s. 922 * 923 * @hide until we make it a system api 924 */ 925 @SystemApi 926 @RequiresPermission(Manifest.permission.ACCESS_AMBIENT_LIGHT_STATS) getAmbientBrightnessStats()927 public List<AmbientBrightnessDayStats> getAmbientBrightnessStats() { 928 return mGlobal.getAmbientBrightnessStats(); 929 } 930 931 /** 932 * Sets the global display brightness configuration. 933 * 934 * @hide 935 */ 936 @SystemApi 937 @RequiresPermission(Manifest.permission.CONFIGURE_DISPLAY_BRIGHTNESS) setBrightnessConfiguration(BrightnessConfiguration c)938 public void setBrightnessConfiguration(BrightnessConfiguration c) { 939 setBrightnessConfigurationForUser(c, mContext.getUserId(), mContext.getPackageName()); 940 } 941 942 /** 943 * Sets the global display brightness configuration for a specific user. 944 * 945 * Note this requires the INTERACT_ACROSS_USERS permission if setting the configuration for a 946 * user other than the one you're currently running as. 947 * 948 * @hide 949 */ setBrightnessConfigurationForUser(BrightnessConfiguration c, int userId, String packageName)950 public void setBrightnessConfigurationForUser(BrightnessConfiguration c, int userId, 951 String packageName) { 952 mGlobal.setBrightnessConfigurationForUser(c, userId, packageName); 953 } 954 955 /** 956 * Gets the global display brightness configuration or the default curve if one hasn't been set. 957 * 958 * @hide 959 */ 960 @SystemApi 961 @RequiresPermission(Manifest.permission.CONFIGURE_DISPLAY_BRIGHTNESS) getBrightnessConfiguration()962 public BrightnessConfiguration getBrightnessConfiguration() { 963 return getBrightnessConfigurationForUser(mContext.getUserId()); 964 } 965 966 /** 967 * Gets the global display brightness configuration or the default curve if one hasn't been set 968 * for a specific user. 969 * 970 * Note this requires the INTERACT_ACROSS_USERS permission if getting the configuration for a 971 * user other than the one you're currently running as. 972 * 973 * @hide 974 */ getBrightnessConfigurationForUser(int userId)975 public BrightnessConfiguration getBrightnessConfigurationForUser(int userId) { 976 return mGlobal.getBrightnessConfigurationForUser(userId); 977 } 978 979 /** 980 * Gets the default global display brightness configuration or null one hasn't 981 * been configured. 982 * 983 * @hide 984 */ 985 @SystemApi 986 @RequiresPermission(Manifest.permission.CONFIGURE_DISPLAY_BRIGHTNESS) 987 @Nullable getDefaultBrightnessConfiguration()988 public BrightnessConfiguration getDefaultBrightnessConfiguration() { 989 return mGlobal.getDefaultBrightnessConfiguration(); 990 } 991 992 993 /** 994 * Gets the last requested minimal post processing setting for the display with displayId. 995 * 996 * @hide 997 */ 998 @TestApi isMinimalPostProcessingRequested(int displayId)999 public boolean isMinimalPostProcessingRequested(int displayId) { 1000 return mGlobal.isMinimalPostProcessingRequested(displayId); 1001 } 1002 1003 /** 1004 * Temporarily sets the brightness of the display. 1005 * <p> 1006 * Requires the {@link android.Manifest.permission#CONTROL_DISPLAY_BRIGHTNESS} permission. 1007 * </p> 1008 * 1009 * @param brightness The brightness value from 0.0f to 1.0f. 1010 * 1011 * @hide Requires signature permission. 1012 */ setTemporaryBrightness(int displayId, float brightness)1013 public void setTemporaryBrightness(int displayId, float brightness) { 1014 mGlobal.setTemporaryBrightness(displayId, brightness); 1015 } 1016 1017 1018 /** 1019 * Sets the brightness of the specified display. 1020 * <p> 1021 * Requires the {@link android.Manifest.permission#CONTROL_DISPLAY_BRIGHTNESS} 1022 * permission. 1023 * </p> 1024 * 1025 * @param displayId the logical display id 1026 * @param brightness The brightness value from 0.0f to 1.0f. 1027 * 1028 * @hide 1029 */ 1030 @RequiresPermission(Manifest.permission.CONTROL_DISPLAY_BRIGHTNESS) setBrightness(int displayId, @FloatRange(from = 0f, to = 1f) float brightness)1031 public void setBrightness(int displayId, @FloatRange(from = 0f, to = 1f) float brightness) { 1032 mGlobal.setBrightness(displayId, brightness); 1033 } 1034 1035 1036 /** 1037 * Gets the brightness of the specified display. 1038 * <p> 1039 * Requires the {@link android.Manifest.permission#CONTROL_DISPLAY_BRIGHTNESS} 1040 * permission. 1041 * </p> 1042 * 1043 * @param displayId The display of which brightness value to get from. 1044 * 1045 * @hide 1046 */ 1047 @RequiresPermission(Manifest.permission.CONTROL_DISPLAY_BRIGHTNESS) 1048 @FloatRange(from = 0f, to = 1f) getBrightness(int displayId)1049 public float getBrightness(int displayId) { 1050 return mGlobal.getBrightness(displayId); 1051 } 1052 1053 1054 /** 1055 * Temporarily sets the auto brightness adjustment factor. 1056 * <p> 1057 * Requires the {@link android.Manifest.permission#CONTROL_DISPLAY_BRIGHTNESS} permission. 1058 * </p> 1059 * 1060 * @param adjustment The adjustment factor from -1.0 to 1.0. 1061 * 1062 * @hide Requires signature permission. 1063 */ setTemporaryAutoBrightnessAdjustment(float adjustment)1064 public void setTemporaryAutoBrightnessAdjustment(float adjustment) { 1065 mGlobal.setTemporaryAutoBrightnessAdjustment(adjustment); 1066 } 1067 1068 /** 1069 * Returns the minimum brightness curve, which guarantess that any brightness curve that dips 1070 * below it is rejected by the system. 1071 * This prevent auto-brightness from setting the screen so dark as to prevent the user from 1072 * resetting or disabling it, and maps lux to the absolute minimum nits that are still readable 1073 * in that ambient brightness. 1074 * 1075 * @return The minimum brightness curve (as lux values and their corresponding nits values). 1076 * 1077 * @hide 1078 */ 1079 @SystemApi getMinimumBrightnessCurve()1080 public Pair<float[], float[]> getMinimumBrightnessCurve() { 1081 return mGlobal.getMinimumBrightnessCurve(); 1082 } 1083 1084 /** 1085 * When enabled the app requested mode is always selected regardless of user settings and 1086 * policies for low brightness, low battery, etc. 1087 * 1088 * @hide 1089 */ 1090 @TestApi 1091 @RequiresPermission(Manifest.permission.OVERRIDE_DISPLAY_MODE_REQUESTS) setShouldAlwaysRespectAppRequestedMode(boolean enabled)1092 public void setShouldAlwaysRespectAppRequestedMode(boolean enabled) { 1093 mGlobal.setShouldAlwaysRespectAppRequestedMode(enabled); 1094 } 1095 1096 /** 1097 * Returns whether we are running in a mode which always selects the app requested display mode 1098 * and ignores user settings and policies for low brightness, low battery etc. 1099 * 1100 * @hide 1101 */ 1102 @TestApi 1103 @RequiresPermission(Manifest.permission.OVERRIDE_DISPLAY_MODE_REQUESTS) shouldAlwaysRespectAppRequestedMode()1104 public boolean shouldAlwaysRespectAppRequestedMode() { 1105 return mGlobal.shouldAlwaysRespectAppRequestedMode(); 1106 } 1107 1108 /** 1109 * Sets the refresh rate switching type. 1110 * This matches {@link android.provider.Settings.Secure.MATCH_CONTENT_FRAME_RATE} 1111 * 1112 * @hide 1113 */ 1114 @TestApi 1115 @RequiresPermission(Manifest.permission.MODIFY_REFRESH_RATE_SWITCHING_TYPE) setRefreshRateSwitchingType(@witchingType int newValue)1116 public void setRefreshRateSwitchingType(@SwitchingType int newValue) { 1117 mGlobal.setRefreshRateSwitchingType(newValue); 1118 } 1119 1120 /** 1121 * Returns the user preference for "Match content frame rate". 1122 * <p> 1123 * Never: Even if the app requests it, the device will never try to match its output to the 1124 * original frame rate of the content. 1125 * </p><p> 1126 * Seamless: If the app requests it, the device will match its output to the original frame 1127 * rate of the content, ONLY if the display can transition seamlessly. 1128 * </p><p> 1129 * Always: If the app requests it, the device will match its output to the original 1130 * frame rate of the content. This may cause the screen to go blank for a 1131 * second when exiting or entering a video playback. 1132 * </p> 1133 */ getMatchContentFrameRateUserPreference()1134 @MatchContentFrameRateType public int getMatchContentFrameRateUserPreference() { 1135 return toMatchContentFrameRateSetting(mGlobal.getRefreshRateSwitchingType()); 1136 } 1137 1138 @MatchContentFrameRateType toMatchContentFrameRateSetting(@witchingType int switchingType)1139 private int toMatchContentFrameRateSetting(@SwitchingType int switchingType) { 1140 switch (switchingType) { 1141 case SWITCHING_TYPE_NONE: 1142 return MATCH_CONTENT_FRAMERATE_NEVER; 1143 case SWITCHING_TYPE_WITHIN_GROUPS: 1144 return MATCH_CONTENT_FRAMERATE_SEAMLESSS_ONLY; 1145 case SWITCHING_TYPE_ACROSS_AND_WITHIN_GROUPS: 1146 return MATCH_CONTENT_FRAMERATE_ALWAYS; 1147 default: 1148 Slog.e(TAG, switchingType + " is not a valid value of switching type."); 1149 return MATCH_CONTENT_FRAMERATE_UNKNOWN; 1150 } 1151 } 1152 1153 /** 1154 * Listens for changes in available display devices. 1155 */ 1156 public interface DisplayListener { 1157 /** 1158 * Called whenever a logical display has been added to the system. 1159 * Use {@link DisplayManager#getDisplay} to get more information about 1160 * the display. 1161 * 1162 * @param displayId The id of the logical display that was added. 1163 */ onDisplayAdded(int displayId)1164 void onDisplayAdded(int displayId); 1165 1166 /** 1167 * Called whenever a logical display has been removed from the system. 1168 * 1169 * @param displayId The id of the logical display that was removed. 1170 */ onDisplayRemoved(int displayId)1171 void onDisplayRemoved(int displayId); 1172 1173 /** 1174 * Called whenever the properties of a logical {@link android.view.Display}, 1175 * such as size and density, have changed. 1176 * 1177 * @param displayId The id of the logical display that changed. 1178 */ onDisplayChanged(int displayId)1179 void onDisplayChanged(int displayId); 1180 } 1181 1182 /** 1183 * Interface for accessing keys belonging to {@link 1184 * android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER}. 1185 * @hide 1186 */ 1187 public interface DeviceConfig { 1188 1189 /** 1190 * Key for refresh rate in the low zone defined by thresholds. 1191 * 1192 * Note that the name and value don't match because they were added before we had a high 1193 * zone to consider. 1194 * @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER 1195 * @see android.R.integer#config_defaultZoneBehavior 1196 */ 1197 String KEY_REFRESH_RATE_IN_LOW_ZONE = "refresh_rate_in_zone"; 1198 1199 /** 1200 * Key for accessing the low display brightness thresholds for the configured refresh 1201 * rate zone. 1202 * The value will be a pair of comma separated integers representing the minimum and maximum 1203 * thresholds of the zone, respectively, in display backlight units (i.e. [0, 255]). 1204 * 1205 * Note that the name and value don't match because they were added before we had a high 1206 * zone to consider. 1207 * 1208 * @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER 1209 * @see android.R.array#config_brightnessThresholdsOfPeakRefreshRate 1210 * @hide 1211 */ 1212 String KEY_FIXED_REFRESH_RATE_LOW_DISPLAY_BRIGHTNESS_THRESHOLDS = 1213 "peak_refresh_rate_brightness_thresholds"; 1214 1215 /** 1216 * Key for accessing the low ambient brightness thresholds for the configured refresh 1217 * rate zone. The value will be a pair of comma separated integers representing the minimum 1218 * and maximum thresholds of the zone, respectively, in lux. 1219 * 1220 * Note that the name and value don't match because they were added before we had a high 1221 * zone to consider. 1222 * 1223 * @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER 1224 * @see android.R.array#config_ambientThresholdsOfPeakRefreshRate 1225 * @hide 1226 */ 1227 String KEY_FIXED_REFRESH_RATE_LOW_AMBIENT_BRIGHTNESS_THRESHOLDS = 1228 "peak_refresh_rate_ambient_thresholds"; 1229 /** 1230 * Key for refresh rate in the high zone defined by thresholds. 1231 * 1232 * @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER 1233 * @see android.R.integer#config_fixedRefreshRateInHighZone 1234 */ 1235 String KEY_REFRESH_RATE_IN_HIGH_ZONE = "refresh_rate_in_high_zone"; 1236 1237 /** 1238 * Key for accessing the display brightness thresholds for the configured refresh rate zone. 1239 * The value will be a pair of comma separated integers representing the minimum and maximum 1240 * thresholds of the zone, respectively, in display backlight units (i.e. [0, 255]). 1241 * 1242 * @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER 1243 * @see android.R.array#config_brightnessHighThresholdsOfFixedRefreshRate 1244 * @hide 1245 */ 1246 String KEY_FIXED_REFRESH_RATE_HIGH_DISPLAY_BRIGHTNESS_THRESHOLDS = 1247 "fixed_refresh_rate_high_display_brightness_thresholds"; 1248 1249 /** 1250 * Key for accessing the ambient brightness thresholds for the configured refresh rate zone. 1251 * The value will be a pair of comma separated integers representing the minimum and maximum 1252 * thresholds of the zone, respectively, in lux. 1253 * 1254 * @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER 1255 * @see android.R.array#config_ambientHighThresholdsOfFixedRefreshRate 1256 * @hide 1257 */ 1258 String KEY_FIXED_REFRESH_RATE_HIGH_AMBIENT_BRIGHTNESS_THRESHOLDS = 1259 "fixed_refresh_rate_high_ambient_brightness_thresholds"; 1260 /** 1261 * Key for default peak refresh rate 1262 * 1263 * @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER 1264 * @see android.R.integer#config_defaultPeakRefreshRate 1265 * @hide 1266 */ 1267 String KEY_PEAK_REFRESH_RATE_DEFAULT = "peak_refresh_rate_default"; 1268 1269 // TODO(b/162536543): rename it once it is proved not harmful for users. 1270 /** 1271 * Key for controlling which packages are explicitly blocked from running at refresh rates 1272 * higher than 60hz. An app may be added to this list if they exhibit performance issues at 1273 * higher refresh rates. 1274 * 1275 * @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER 1276 * @see android.R.array#config_highRefreshRateBlacklist 1277 * @hide 1278 */ 1279 String KEY_HIGH_REFRESH_RATE_BLACKLIST = "high_refresh_rate_blacklist"; 1280 } 1281 } 1282