screencap: Require display ID in -d switch

Remove undocumented fallback to layer stack, since virtual displays can
now be specified by their unambiguous IDs.

Bug: 182939859
Test: screencap -d <id>
Change-Id: I86a8e713d8076abe55aeeb327fd9d746c46e5a40
diff --git a/cmds/screencap/screencap.cpp b/cmds/screencap/screencap.cpp
index d4da5e5..7e6a521 100644
--- a/cmds/screencap/screencap.cpp
+++ b/cmds/screencap/screencap.cpp
@@ -45,13 +45,13 @@
 #define COLORSPACE_SRGB       1
 #define COLORSPACE_DISPLAY_P3 2
 
-static void usage(const char* pname, PhysicalDisplayId displayId)
+static void usage(const char* pname, DisplayId displayId)
 {
     fprintf(stderr,
             "usage: %s [-hp] [-d display-id] [FILENAME]\n"
             "   -h: this message\n"
             "   -p: save the file as a png.\n"
-            "   -d: specify the physical display ID to capture (default: %s)\n"
+            "   -d: specify the display ID to capture (default: %s)\n"
             "       see \"dumpsys SurfaceFlinger --display-id\" for valid display IDs.\n"
             "If FILENAME ends with .png it will be saved as a png.\n"
             "If FILENAME is not given, the results will be printed to stdout.\n",
@@ -121,9 +121,9 @@
 
 int main(int argc, char** argv)
 {
-    std::optional<PhysicalDisplayId> displayId = SurfaceComposerClient::getInternalDisplayId();
+    std::optional<DisplayId> displayId = SurfaceComposerClient::getInternalDisplayId();
     if (!displayId) {
-        fprintf(stderr, "Failed to get token for internal display\n");
+        fprintf(stderr, "Failed to get ID for internal display\n");
         return 1;
     }
 
@@ -136,7 +136,11 @@
                 png = true;
                 break;
             case 'd':
-                displayId = PhysicalDisplayId(atoll(optarg));
+                displayId = DisplayId::fromValue(atoll(optarg));
+                if (!displayId) {
+                    fprintf(stderr, "Invalid display ID\n");
+                    return 1;
+                }
                 break;
             case '?':
             case 'h':
@@ -182,7 +186,7 @@
     ProcessState::self()->startThreadPool();
 
     sp<SyncScreenCaptureListener> captureListener = new SyncScreenCaptureListener();
-    status_t result = ScreenshotClient::captureDisplay(displayId->value, captureListener);
+    status_t result = ScreenshotClient::captureDisplay(*displayId, captureListener);
     if (result != NO_ERROR) {
         close(fd);
         return 1;