fix CtsStatsdAtomHostTestCases checking with proper CLOSED device state

Given 12L CTS is testing all foldable device states with the following CL,
https://android-review.googlesource.com/c/platform/tools/tradefederation/+/1766265

The devie (e.g. Z Flip) that don't support CLOSED state in the Setup level as well as don't support compat ui can proceed the test.
So add test exemption for the CLOSED device state accordingly.

Bug: 233252410
Test: run cts -m CtsStatsdAtomHostTestCases -t android.cts.statsdatom.appcompatstate.AppCompatStateStatsTests#testResizableActivityDeviceStateClosedToOpened

Signed-off-by: Sungmin <sungmin.h@samsung.com>
Change-Id: Id726061d38a28d69a436e9111edf80642810a810
diff --git a/hostsidetests/statsdatom/src/android/cts/statsdatom/appcompatstate/AppCompatStateStatsTests.java b/hostsidetests/statsdatom/src/android/cts/statsdatom/appcompatstate/AppCompatStateStatsTests.java
index e192e72..9648d8c 100644
--- a/hostsidetests/statsdatom/src/android/cts/statsdatom/appcompatstate/AppCompatStateStatsTests.java
+++ b/hostsidetests/statsdatom/src/android/cts/statsdatom/appcompatstate/AppCompatStateStatsTests.java
@@ -183,8 +183,9 @@
     private void testAppCompatFlow(String activity, @Nullable String secondActivity,
             boolean switchToOpened, List<AppCompatStateChanged.State>... expectedStatesOptions)
             throws Exception {
-        if (!isOpenedDeviceStateAvailable()) {
-            CLog.i("Device doesn't support OPENED device state.");
+        if (!isDeviceStateAvailable(DEVICE_STATE_OPENED)
+                || !isDeviceStateAvailable(DEVICE_STATE_CLOSED)) {
+            CLog.i("Device doesn't support OPENED or CLOSED device states.");
             return;
         }
 
@@ -238,10 +239,10 @@
         return result;
     }
 
-    private boolean isOpenedDeviceStateAvailable() throws Exception {
+    private boolean isDeviceStateAvailable(int state) throws Exception {
         return Arrays.stream(
                 getDevice().executeShellCommand(CMD_GET_AVAILABLE_DEVICE_STATES).split(","))
                 .map(Integer::valueOf)
-                .anyMatch(state -> state == DEVICE_STATE_OPENED);
+                .anyMatch(availableState -> availableState == state);
     }
-}
\ No newline at end of file
+}
diff --git a/hostsidetests/statsdatom/src/android/cts/statsdatom/sizecompatrestartbutton/SizeCompatRestartButtonStatsTests.java b/hostsidetests/statsdatom/src/android/cts/statsdatom/sizecompatrestartbutton/SizeCompatRestartButtonStatsTests.java
index b797e68..a6aaebf 100644
--- a/hostsidetests/statsdatom/src/android/cts/statsdatom/sizecompatrestartbutton/SizeCompatRestartButtonStatsTests.java
+++ b/hostsidetests/statsdatom/src/android/cts/statsdatom/sizecompatrestartbutton/SizeCompatRestartButtonStatsTests.java
@@ -98,8 +98,9 @@
     }
 
     public void testSizeCompatRestartButtonAppearedButNotClicked() throws Exception {
-        if (!isOpenedDeviceStateAvailable()) {
-            CLog.i("Device doesn't support OPENED device state.");
+        if (!isDeviceStateAvailable(DEVICE_STATE_OPENED)
+                || !isDeviceStateAvailable(DEVICE_STATE_CLOSED)) {
+            CLog.i("Device doesn't support OPENED or CLOSED device states.");
             return;
         }
 
@@ -120,11 +121,10 @@
         assertThat(atom.getEvent()).isEqualTo(Event.APPEARED);
     }
 
-    private boolean isOpenedDeviceStateAvailable() throws Exception {
+    private boolean isDeviceStateAvailable(int state) throws Exception {
         return Arrays.stream(
                 getDevice().executeShellCommand(CMD_GET_AVAILABLE_DEVICE_STATES).split(","))
                 .map(Integer::valueOf)
-                .anyMatch(state -> state == DEVICE_STATE_OPENED);
+                .anyMatch(availableState -> availableState == state);
     }
 }
-