DO NOT MERGE: Change the way that find UI elements

If we change the style of notifications, a NullPointerException
may occur when looking up UI elements by the string of
'Permission requested' in a unit test.

So we change the way that find UI elements. Match UI elements
by means of regular expressions that starts with 'Permission requested'.

Test: run cts -m CtsSyncContentHostTestCases -t \
android.content.cts.SyncAdapterAccountAccessHostTest#\
testOtherCertAuthenticatorCanSeeAccount
Bug: 111417274

Change-Id: Ib044babbb09f993870fdac78954690acdb4d23cd
diff --git a/hostsidetests/content/test-apps/CtsSyncAccountAccessOtherCertTests/src/com/android/cts/content/CtsSyncAccountAccessOtherCertTestCases.java b/hostsidetests/content/test-apps/CtsSyncAccountAccessOtherCertTests/src/com/android/cts/content/CtsSyncAccountAccessOtherCertTestCases.java
index cb8f163..d6d7386 100644
--- a/hostsidetests/content/test-apps/CtsSyncAccountAccessOtherCertTests/src/com/android/cts/content/CtsSyncAccountAccessOtherCertTestCases.java
+++ b/hostsidetests/content/test-apps/CtsSyncAccountAccessOtherCertTests/src/com/android/cts/content/CtsSyncAccountAccessOtherCertTestCases.java
@@ -49,6 +49,7 @@
 import java.io.IOException;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
+import java.util.regex.Pattern;
 
 import static junit.framework.Assert.assertFalse;
 import static junit.framework.Assert.assertTrue;
@@ -62,6 +63,7 @@
 public class CtsSyncAccountAccessOtherCertTestCases {
     private static final long SYNC_TIMEOUT_MILLIS = 20000; // 20 sec
     private static final long UI_TIMEOUT_MILLIS = 5000; // 5 sec
+    private static final Pattern PERMISSION_REQUESTED = Pattern.compile("^Permission requested.*");
 
     public static final String TOKEN_TYPE_REMOVE_ACCOUNTS = "TOKEN_TYPE_REMOVE_ACCOUNTS";
 
@@ -125,10 +127,10 @@
                 notification.click();
             } else {
                 uiDevice.openNotification();
-                uiDevice.wait(Until.hasObject(By.text("Permission requested")),
+                uiDevice.wait(Until.hasObject(By.text(PERMISSION_REQUESTED)),
                         UI_TIMEOUT_MILLIS);
 
-                uiDevice.findObject(By.text("Permission requested")).click();
+                uiDevice.findObject(By.text(PERMISSION_REQUESTED)).click();
             }
 
             uiDevice.wait(Until.hasObject(By.text("ALLOW")),