Set assist settings and tweak tests to align with platform expectations.

Change assumptions for screenshot to rely on context setting, set assist
settings rather than checking for them, and modify DisableContextTest to
change settings within the test method so subsequent tests are not
affected by failure.

Bug: 23240210
Bug: 23235045
Change-Id: I4912ee5384434efa1279e4f0b38d4b6653468d68
diff --git a/tests/tests/assist/src/android/assist/cts/AssistStructureTest.java b/tests/tests/assist/src/android/assist/cts/AssistStructureTest.java
index 97ab290..763ecef 100644
--- a/tests/tests/assist/src/android/assist/cts/AssistStructureTest.java
+++ b/tests/tests/assist/src/android/assist/cts/AssistStructureTest.java
@@ -42,9 +42,6 @@
     }
 
     public void testAssistStructure() throws Exception {
-        assertEquals("1", Settings.Secure.getString(
-            mContext.getContentResolver(), "assist_structure_enabled"));
-
         verifyAssistDataNullness(false, false, false, false);
         verifyAssistStructure(Utils.getTestAppComponent(TEST_CASE_TYPE),
                     false /*FLAG_SECURE set*/);
diff --git a/tests/tests/assist/src/android/assist/cts/AssistTestBase.java b/tests/tests/assist/src/android/assist/cts/AssistTestBase.java
index e6d08cf..bdf3d4a 100644
--- a/tests/tests/assist/src/android/assist/cts/AssistTestBase.java
+++ b/tests/tests/assist/src/android/assist/cts/AssistTestBase.java
@@ -27,6 +27,7 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.res.XmlResourceParser;
+import android.cts.util.SystemUtil;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.os.Bundle;
@@ -58,10 +59,10 @@
     protected void setUp() throws Exception {
         super.setUp();
         mContext = getInstrumentation().getTargetContext();
-        assertEquals("1", Settings.Secure.getString(
-            mContext.getContentResolver(), "assist_structure_enabled"));
-        assertEquals("1", Settings.Secure.getString(
-            mContext.getContentResolver(), "assist_screenshot_enabled"));
+        SystemUtil.runShellCommand(getInstrumentation(),
+            "settings put secure assist_structure_enabled 1");
+        SystemUtil.runShellCommand(getInstrumentation(),
+            "settings put secure assist_screenshot_enabled 1");
         logContextAndScreenshotSetting();
     }
 
diff --git a/tests/tests/assist/src/android/assist/cts/DisableContextTest.java b/tests/tests/assist/src/android/assist/cts/DisableContextTest.java
index 9407ec5..04bea77 100644
--- a/tests/tests/assist/src/android/assist/cts/DisableContextTest.java
+++ b/tests/tests/assist/src/android/assist/cts/DisableContextTest.java
@@ -50,13 +50,7 @@
     @Override
     public void setUp() throws Exception {
         super.setUp();
-        SystemUtil.runShellCommand(getInstrumentation(),
-                "settings put secure assist_structure_enabled 0");
-        SystemUtil.runShellCommand(getInstrumentation(),
-            "settings put secure assist_screenshot_enabled 0");
-        logContextAndScreenshotSetting();
         startTestActivity(TEST_CASE_TYPE);
-        waitForBroadcast();
     }
 
     @Override
@@ -71,6 +65,14 @@
 
     public void testContextAndScreenshotOff() throws Exception {
         // Both settings off
+        SystemUtil.runShellCommand(getInstrumentation(),
+            "settings put secure assist_structure_enabled 0");
+        SystemUtil.runShellCommand(getInstrumentation(),
+            "settings put secure assist_screenshot_enabled 0");
+        waitForBroadcast();
+
+        logContextAndScreenshotSetting();
+
         verifyAssistDataNullness(true, true, true, true);
 
         // Screenshot off, context on
@@ -93,6 +95,6 @@
 
         logContextAndScreenshotSetting();
 
-        verifyAssistDataNullness(true, true, true, false);
+        verifyAssistDataNullness(true, true, true, true);
     }
 }
\ No newline at end of file
diff --git a/tests/tests/assist/src/android/assist/cts/FlagSecureTest.java b/tests/tests/assist/src/android/assist/cts/FlagSecureTest.java
index 0e79d9d..fc14900 100644
--- a/tests/tests/assist/src/android/assist/cts/FlagSecureTest.java
+++ b/tests/tests/assist/src/android/assist/cts/FlagSecureTest.java
@@ -47,7 +47,7 @@
     }
 
     public void testSecureActivity() throws Exception {
-        verifyAssistDataNullness(false, false, false, true);
+        verifyAssistDataNullness(false, false, false, false);
 
         // verify that we have only the root window and not its children.
         verifyAssistStructure(Utils.getTestAppComponent(TEST_CASE_TYPE), true);