Update dismiss logic in SuspendDialogTest to handle watches.

Test: cts-tradefed run cts -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.MixedDeviceOwnerTest#testSuspendPackage

Bug: 63393362
Change-Id: I32686b142584f156942a98074936c50ed1d57fe8
(cherry picked from commit 70c3aef7687296a3a625daef83a4d4499006b99c)
diff --git a/hostsidetests/devicepolicy/app/IntentSender/src/com/android/cts/intent/sender/SuspendPackageTest.java b/hostsidetests/devicepolicy/app/IntentSender/src/com/android/cts/intent/sender/SuspendPackageTest.java
index 68e9e8b..19c13b5 100644
--- a/hostsidetests/devicepolicy/app/IntentSender/src/com/android/cts/intent/sender/SuspendPackageTest.java
+++ b/hostsidetests/devicepolicy/app/IntentSender/src/com/android/cts/intent/sender/SuspendPackageTest.java
@@ -3,8 +3,10 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager;
+import android.content.res.Configuration;
 import android.support.test.uiautomator.By;
 import android.support.test.uiautomator.BySelector;
+import android.support.test.uiautomator.Direction;
 import android.support.test.uiautomator.UiDevice;
 import android.support.test.uiautomator.UiObject2;
 import android.support.test.uiautomator.Until;
@@ -17,6 +19,11 @@
             .res("com.android.settings:id/admin_support_icon")
             .pkg("com.android.settings");
 
+    private static final BySelector POPUP_TITLE_WATCH_SELECTOR = By
+            .clazz(android.widget.TextView.class.getName())
+            .res("android:id/alertTitle")
+            .pkg("com.google.android.apps.wearable.settings");
+
     private static final BySelector POPUP_BUTTON_SELECTOR = By
             .clazz(android.widget.Button.class.getName())
             .res("android:id/button1")
@@ -75,12 +82,24 @@
      */
     private void dismissPolicyTransparencyDialog() {
         final UiDevice device = UiDevice.getInstance(getInstrumentation());
-        device.wait(Until.hasObject(POPUP_IMAGE_SELECTOR), WAIT_DIALOG_TIMEOUT_IN_MS);
-        final UiObject2 icon = device.findObject(POPUP_IMAGE_SELECTOR);
-        assertNotNull("Policy transparency dialog icon not found", icon);
-        // "OK" button only present in the dialog if it is blocked by policy.
-        final UiObject2 button = device.findObject(POPUP_BUTTON_SELECTOR);
-        assertNotNull("OK button not found", button);
-        button.click();
+        if (isWatch()) {
+            device.wait(Until.hasObject(POPUP_TITLE_WATCH_SELECTOR), WAIT_DIALOG_TIMEOUT_IN_MS);
+            final UiObject2 title = device.findObject(POPUP_TITLE_WATCH_SELECTOR);
+            assertNotNull("Policy transparency dialog title not found", title);
+            title.swipe(Direction.RIGHT, 1.0f);
+        } else {
+            device.wait(Until.hasObject(POPUP_IMAGE_SELECTOR), WAIT_DIALOG_TIMEOUT_IN_MS);
+            final UiObject2 icon = device.findObject(POPUP_IMAGE_SELECTOR);
+            assertNotNull("Policy transparency dialog icon not found", icon);
+            // "OK" button only present in the dialog if it is blocked by policy.
+            final UiObject2 button = device.findObject(POPUP_BUTTON_SELECTOR);
+            assertNotNull("OK button not found", button);
+            button.click();
+        }
+    }
+
+    private boolean isWatch() {
+        return (getInstrumentation().getContext().getResources().getConfiguration().uiMode
+                & Configuration.UI_MODE_TYPE_WATCH) == Configuration.UI_MODE_TYPE_WATCH;
     }
 }