InattentiveSleepTests: Account for the change in WMS proto format

The window manager service proto dump format has changed, so the tests
that check for a window being shown need to be udpated.

Bug: 155350825
Test: atest InattentiveSleepTests
Change-Id: Icf1cc5934a87841a8bcf59ecf1175a8b9c4f67dc
diff --git a/hostsidetests/os/Android.bp b/hostsidetests/os/Android.bp
index 24afa1a..997bfb9 100644
--- a/hostsidetests/os/Android.bp
+++ b/hostsidetests/os/Android.bp
@@ -23,6 +23,9 @@
         "compatibility-host-util",
         "truth-host-prebuilt",
     ],
+    static_libs: [
+        "compatibility-host-util-axt"
+    ],
     // Tag this module as a cts test artifact
     test_suites: [
         "cts",
diff --git a/hostsidetests/os/src/android/os/cts/InattentiveSleepTests.java b/hostsidetests/os/src/android/os/cts/InattentiveSleepTests.java
index b1bda95..e117d14 100644
--- a/hostsidetests/os/src/android/os/cts/InattentiveSleepTests.java
+++ b/hostsidetests/os/src/android/os/cts/InattentiveSleepTests.java
@@ -25,10 +25,9 @@
 
 import com.android.compatibility.common.util.PollingCheck;
 import com.android.compatibility.common.util.ProtoUtils;
+import com.android.compatibility.common.util.WindowManagerUtil;
 import com.android.server.power.PowerManagerServiceDumpProto;
 import com.android.server.power.PowerServiceSettingsAndConfigurationDumpProto;
-import com.android.server.wm.WindowManagerServiceDumpProto;
-import com.android.server.wm.WindowStateProto;
 import com.android.tradefed.device.ITestDevice;
 import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;
@@ -38,8 +37,6 @@
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
-import java.util.List;
-
 @RunWith(DeviceJUnit4ClassRunner.class)
 public class InattentiveSleepTests extends BaseHostJUnit4Test {
     private static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only";
@@ -49,7 +46,6 @@
     private static final long TIME_BEFORE_WARNING_MS = 1200L;
 
     private static final String CMD_DUMPSYS_POWER = "dumpsys power --proto";
-    private static final String CMD_GET_WINDOW_TOKENS = "dumpsys window t --proto";
     private static final String WARNING_WINDOW_TOKEN_TITLE = "InattentiveSleepWarning";
     private static final String CMD_START_APP_TEMPLATE =
             "am start -W -a android.intent.action.MAIN -p %s -c android.intent.category.LAUNCHER";
@@ -234,18 +230,7 @@
     }
 
     private boolean isWarningShown() throws Exception {
-        WindowManagerServiceDumpProto windowManagerDump = ProtoUtils.getProto(getDevice(),
-                WindowManagerServiceDumpProto.parser(), CMD_GET_WINDOW_TOKENS);
-
-        List<WindowStateProto> windows =
-                windowManagerDump.getRootWindowContainer().getWindowsList();
-        for (WindowStateProto window : windows) {
-            if (WARNING_WINDOW_TOKEN_TITLE.equals(window.getIdentifier().getTitle())) {
-                return true;
-            }
-        }
-
-        return false;
+        return WindowManagerUtil.hasWindowWithTitle(getDevice(), WARNING_WINDOW_TOKEN_TITLE);
     }
 
     private void waitUntilAsleep() throws Exception {