Merge "Add ALL_INCLUDING_DISPLAYS category for getDisplays()" into tm-dev am: d5b0c3f163

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18488313

Change-Id: Ic2c6441d9a9a8bd4d6e3102bb628307d35f7a0fe
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2022-05-25 03:00:16 +00:00
committed by Automerger Merge Worker
2 changed files with 30 additions and 1 deletions

View File

@@ -108,6 +108,17 @@ public final class DisplayManager {
public static final String DISPLAY_CATEGORY_PRESENTATION =
"android.hardware.display.category.PRESENTATION";
/**
* Display category: All displays, including disabled displays.
* <p>
* This returns all displays, including currently disabled and inaccessible displays.
*
* @see #getDisplays(String)
* @hide
*/
public static final String DISPLAY_CATEGORY_ALL_INCLUDING_DISABLED =
"android.hardware.display.category.ALL_INCLUDING_DISABLED";
/** @hide **/
@IntDef(prefix = "VIRTUAL_DISPLAY_FLAG_", flag = true, value = {
VIRTUAL_DISPLAY_FLAG_PUBLIC,
@@ -552,7 +563,8 @@ public final class DisplayManager {
final int[] displayIds = mGlobal.getDisplayIds();
synchronized (mLock) {
try {
if (category == null) {
if (category == null
|| DISPLAY_CATEGORY_ALL_INCLUDING_DISABLED.equals(category)) {
addAllDisplaysLocked(mTempDisplays, displayIds);
} else if (category.equals(DISPLAY_CATEGORY_PRESENTATION)) {
addPresentationDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_WIFI);

View File

@@ -76,6 +76,8 @@ class DisplayManagerShellCommand extends ShellCommand {
return setUserDisabledHdrTypes();
case "get-user-disabled-hdr-types":
return getUserDisabledHdrTypes();
case "get-displays":
return getDisplays();
case "dock":
return setDockedAndIdle();
case "undock":
@@ -133,6 +135,9 @@ class DisplayManagerShellCommand extends ShellCommand {
pw.println(" Sets the user disabled HDR types as TYPES");
pw.println(" get-user-disabled-hdr-types");
pw.println(" Returns the user disabled HDR types");
pw.println(" get-displays [CATEGORY]");
pw.println(" Returns the current displays. Can specify string category among");
pw.println(" DisplayManager.DISPLAY_CATEGORY_*; must use the actual string value.");
pw.println(" dock");
pw.println(" Sets brightness to docked + idle screen brightness mode");
pw.println(" undock");
@@ -141,6 +146,18 @@ class DisplayManagerShellCommand extends ShellCommand {
Intent.printIntentArgsHelp(pw , "");
}
private int getDisplays() {
String category = getNextArg();
DisplayManager dm = mService.getContext().getSystemService(DisplayManager.class);
Display[] displays = dm.getDisplays(category);
PrintWriter out = getOutPrintWriter();
out.println("Displays:");
for (int i = 0; i < displays.length; i++) {
out.println(" " + displays[i]);
}
return 0;
}
private int setBrightness() {
String brightnessText = getNextArg();
if (brightnessText == null) {