Fix for Automotive devices supporting only "landscape" screen orientation

When "portrait" is specified on an automotive device that supports only
"landscape" screen orientation, the test fails due to insufficient screen width.
Therefore, the test was modified to specify the screen orientation during
the test by checking the screen orientation supported by the device.
And, we need an increased CountDownLatch count for the large size display in order to fully complete the screen transition before checking the result.

Bug: 225797185
Test: atest android.view.cts.PixelCopyTest#testDialogProducerScaling
Change-Id: I153c0f7e38b3ef719f2b469d1d8abac91ca3c949
diff --git a/tests/tests/view/src/android/view/cts/util/DisableFixToUserRotationRule.java b/tests/tests/view/src/android/view/cts/util/DisableFixToUserRotationRule.java
index 43bc27c..36b6314 100644
--- a/tests/tests/view/src/android/view/cts/util/DisableFixToUserRotationRule.java
+++ b/tests/tests/view/src/android/view/cts/util/DisableFixToUserRotationRule.java
@@ -17,6 +17,7 @@
 package android.view.cts.util;
 
 import android.app.UiAutomation;
+import android.content.pm.PackageManager;
 import android.os.ParcelFileDescriptor;
 import android.util.Log;
 
@@ -35,9 +36,16 @@
     private static final String COMMAND = "cmd window set-fix-to-user-rotation ";
 
     private final UiAutomation mUiAutomation;
+    private final boolean mSupportsRotation;
 
     public DisableFixToUserRotationRule() {
         mUiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
+        PackageManager pm = InstrumentationRegistry
+                .getInstrumentation()
+                .getContext()
+                .getPackageManager();
+        mSupportsRotation = pm.hasSystemFeature(PackageManager.FEATURE_SCREEN_LANDSCAPE)
+                && pm.hasSystemFeature(PackageManager.FEATURE_SCREEN_PORTRAIT);
     }
 
     @Override
@@ -45,11 +53,15 @@
         return new Statement() {
             @Override
             public void evaluate() throws Throwable {
-                executeShellCommandAndPrint(COMMAND + "disabled");
+                if (mSupportsRotation) {
+                    executeShellCommandAndPrint(COMMAND + "disabled");
+                }
                 try {
                     base.evaluate();
                 } finally {
-                    executeShellCommandAndPrint(COMMAND + "default");
+                    if (mSupportsRotation) {
+                        executeShellCommandAndPrint(COMMAND + "default");
+                    }
                 }
             }
         };