summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/api/current.txt1
-rw-r--r--core/api/test-current.txt1
-rw-r--r--core/java/android/hardware/display/DisplayManager.java44
-rw-r--r--services/core/java/com/android/server/display/feature/display_flags.aconfig8
4 files changed, 51 insertions, 3 deletions
diff --git a/core/api/current.txt b/core/api/current.txt
index 17e7d7a258d8..a893fa5db157 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -20785,6 +20785,7 @@ package android.hardware.display {
method public void registerDisplayListener(android.hardware.display.DisplayManager.DisplayListener, android.os.Handler);
method @FlaggedApi("com.android.server.display.feature.flags.display_listener_performance_improvements") public void registerDisplayListener(@NonNull java.util.concurrent.Executor, long, @NonNull android.hardware.display.DisplayManager.DisplayListener);
method public void unregisterDisplayListener(android.hardware.display.DisplayManager.DisplayListener);
+ field @FlaggedApi("com.android.server.display.feature.flags.display_category_built_in") public static final String DISPLAY_CATEGORY_BUILT_IN_DISPLAYS = "android.hardware.display.category.BUILT_IN_DISPLAYS";
field public static final String DISPLAY_CATEGORY_PRESENTATION = "android.hardware.display.category.PRESENTATION";
field @FlaggedApi("com.android.server.display.feature.flags.display_listener_performance_improvements") public static final long EVENT_TYPE_DISPLAY_ADDED = 1L; // 0x1L
field @FlaggedApi("com.android.server.display.feature.flags.display_listener_performance_improvements") public static final long EVENT_TYPE_DISPLAY_CHANGED = 4L; // 0x4L
diff --git a/core/api/test-current.txt b/core/api/test-current.txt
index 7c1c86823110..85ab5ed97a38 100644
--- a/core/api/test-current.txt
+++ b/core/api/test-current.txt
@@ -1727,6 +1727,7 @@ package android.hardware.display {
method @RequiresPermission(android.Manifest.permission.OVERRIDE_DISPLAY_MODE_REQUESTS) public void setShouldAlwaysRespectAppRequestedMode(boolean);
method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void setUserDisabledHdrTypes(@NonNull int[]);
method @RequiresPermission(android.Manifest.permission.OVERRIDE_DISPLAY_MODE_REQUESTS) public boolean shouldAlwaysRespectAppRequestedMode();
+ field public static final String DISPLAY_CATEGORY_ALL_INCLUDING_DISABLED = "android.hardware.display.category.ALL_INCLUDING_DISABLED";
field public static final String DISPLAY_CATEGORY_REAR = "android.hardware.display.category.REAR";
field public static final String HDR_OUTPUT_CONTROL_FLAG = "enable_hdr_output_control";
field public static final int SWITCHING_TYPE_ACROSS_AND_WITHIN_GROUPS = 2; // 0x2
diff --git a/core/java/android/hardware/display/DisplayManager.java b/core/java/android/hardware/display/DisplayManager.java
index 34e86a414533..b7460e976313 100644
--- a/core/java/android/hardware/display/DisplayManager.java
+++ b/core/java/android/hardware/display/DisplayManager.java
@@ -146,6 +146,22 @@ public final class DisplayManager {
"android.hardware.display.category.PRESENTATION";
/**
+ * Display category: Built in displays.
+ *
+ * <p>
+ * This category can be used to identify displays that are built into the device. The
+ * displays that are returned may be inactive or disabled at the current moment. The
+ * returned displays are useful in identifying the various sizes of built-in displays. The
+ * id from {@link Display#getDisplayId()} is not guaranteed to be stable and may change
+ * when the display becomes active.
+ * </p>
+ * @see #getDisplays(String)
+ */
+ @FlaggedApi(com.android.server.display.feature.flags.Flags.FLAG_DISPLAY_CATEGORY_BUILT_IN)
+ public static final String DISPLAY_CATEGORY_BUILT_IN_DISPLAYS =
+ "android.hardware.display.category.BUILT_IN_DISPLAYS";
+
+ /**
* Display category: Rear displays.
* <p>
* This category can be used to identify complementary internal displays that are facing away
@@ -171,6 +187,8 @@ public final class DisplayManager {
* @see #getDisplays(String)
* @hide
*/
+ @TestApi
+ @SuppressLint("UnflaggedApi")
public static final String DISPLAY_CATEGORY_ALL_INCLUDING_DISABLED =
"android.hardware.display.category.ALL_INCLUDING_DISABLED";
@@ -732,10 +750,13 @@ public final class DisplayManager {
* @see #DISPLAY_CATEGORY_PRESENTATION
*/
public Display[] getDisplays(String category) {
- boolean includeDisabled = (category != null
- && category.equals(DISPLAY_CATEGORY_ALL_INCLUDING_DISABLED));
+ boolean includeDisabled = shouldIncludeDisabledDisplays(category);
final int[] displayIds = mGlobal.getDisplayIds(includeDisabled);
- if (DISPLAY_CATEGORY_PRESENTATION.equals(category)) {
+ if (Flags.displayCategoryBuiltIn()
+ && DISPLAY_CATEGORY_BUILT_IN_DISPLAYS.equals(category)) {
+ Display[] value = getDisplays(displayIds, DisplayManager::isBuiltInDisplay);
+ return value;
+ } else if (DISPLAY_CATEGORY_PRESENTATION.equals(category)) {
return getDisplays(displayIds, DisplayManager::isPresentationDisplay);
} else if (DISPLAY_CATEGORY_REAR.equals(category)) {
return getDisplays(displayIds, DisplayManager::isRearDisplay);
@@ -745,6 +766,16 @@ public final class DisplayManager {
return new Display[0];
}
+ private boolean shouldIncludeDisabledDisplays(@Nullable String category) {
+ if (DISPLAY_CATEGORY_BUILT_IN_DISPLAYS.equals(category)) {
+ return true;
+ }
+ if (DISPLAY_CATEGORY_ALL_INCLUDING_DISABLED.equals(category)) {
+ return true;
+ }
+ return false;
+ }
+
private Display[] getDisplays(int[] displayIds, Predicate<Display> predicate) {
ArrayList<Display> tmpDisplays = new ArrayList<>();
for (int displayId : displayIds) {
@@ -756,6 +787,13 @@ public final class DisplayManager {
return tmpDisplays.toArray(new Display[tmpDisplays.size()]);
}
+ private static boolean isBuiltInDisplay(@Nullable Display display) {
+ if (display == null) {
+ return false;
+ }
+ return display.getType() == Display.TYPE_INTERNAL;
+ }
+
private static boolean isPresentationDisplay(@Nullable Display display) {
if (display == null || (display.getDisplayId() == DEFAULT_DISPLAY)
|| (display.getFlags() & Display.FLAG_PRESENTATION) == 0) {
diff --git a/services/core/java/com/android/server/display/feature/display_flags.aconfig b/services/core/java/com/android/server/display/feature/display_flags.aconfig
index bbd0e41e9af7..7890db1454b4 100644
--- a/services/core/java/com/android/server/display/feature/display_flags.aconfig
+++ b/services/core/java/com/android/server/display/feature/display_flags.aconfig
@@ -509,3 +509,11 @@ flag {
purpose: PURPOSE_BUGFIX
}
}
+
+flag {
+ name: "display_category_built_in"
+ namespace: "display_manager"
+ description: "Add a new category to get the built in displays."
+ bug: "293651324"
+ is_fixed_read_only: false
+}