am 90a0691d: Merge "Add test for flag secure app" into mnc-dev

* commit '90a0691d5a39ce82bf1f8c76d4feb083e2178f47':
  Add test for flag secure app
diff --git a/tests/tests/assist/AndroidManifest.xml b/tests/tests/assist/AndroidManifest.xml
index c5772ad..b6cd684 100644
--- a/tests/tests/assist/AndroidManifest.xml
+++ b/tests/tests/assist/AndroidManifest.xml
@@ -28,6 +28,7 @@
           <intent-filter>
               <action android:name="android.intent.action.TEST_START_ACTIVITY_ASSIST_STRUCTURE" />
               <action android:name="android.intent.action.TEST_START_ACTIVITY_DISABLE_CONTEXT" />
+              <action android:name="android.intent.action.TEST_START_ACTIVITY_FLAG_SECURE" />
               <category android:name="android.intent.category.LAUNCHER" />
               <category android:name="android.intent.category.DEFAULT" />
           </intent-filter>
diff --git a/tests/tests/assist/common/src/android/assist/common/Utils.java b/tests/tests/assist/common/src/android/assist/common/Utils.java
index 1831182..bf051c0 100644
--- a/tests/tests/assist/common/src/android/assist/common/Utils.java
+++ b/tests/tests/assist/common/src/android/assist/common/Utils.java
@@ -15,18 +15,11 @@
  */
 package android.assist.common;
 
-import android.app.VoiceInteractor;
-import android.app.VoiceInteractor.PickOptionRequest.Option;
-import android.content.BroadcastReceiver;
+import android.R;
 import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
 import android.os.Bundle;
-import android.util.Log;
 
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.concurrent.CountDownLatch;
 
 public class Utils {
     public static final String TESTCASE_TYPE = "testcase_type";
@@ -42,8 +35,10 @@
 
     public static final int TIMEOUT_MS = 2 * 1000; // TODO(awlee): what is the timeout
 
+    /** Test name suffixes */
     public static final String ASSIST_STRUCTURE = "ASSIST_STRUCTURE";
     public static final String DISABLE_CONTEXT = "DISABLE_CONTEXT";
+    public static final String FLAG_SECURE = "FLAG_SECURE";
 
     /**
      * The shim activity that starts the service associated with each test.
@@ -51,6 +46,7 @@
     public static final String getTestActivity(String testCaseType) {
         switch (testCaseType) {
             case ASSIST_STRUCTURE:
+            case FLAG_SECURE:
                 return "service.AssistStructureActivity";
             case DISABLE_CONTEXT:
                 return "service.DisableContextActivity";
@@ -65,8 +61,12 @@
     public static final ComponentName getTestAppComponent(String testCaseType) {
         switch (testCaseType) {
             case ASSIST_STRUCTURE:
+            case DISABLE_CONTEXT:
                 return new ComponentName(
                         "android.assist.testapp", "android.assist.testapp.TestApp");
+            case FLAG_SECURE:
+                return new ComponentName(
+                        "android.assist.testapp", "android.assist.testapp.SecureActivity");
             default:
                 return new ComponentName("","");
         }
@@ -90,19 +90,6 @@
         return buf.toString();
     }
 
-    public static final String toOptionsString(Option[] options) {
-        StringBuilder sb = new StringBuilder();
-        sb.append("{");
-        for (int i = 0; i < options.length; i++) {
-            if (i >= 1) {
-                sb.append(", ");
-            }
-            sb.append(options[i].getLabel());
-        }
-        sb.append("}");
-        return sb.toString();
-    }
-
     public static final void addErrorResult(final Bundle testinfo, final String msg) {
         testinfo.getStringArrayList(testinfo.getString(Utils.TESTCASE_TYPE))
             .add(TEST_ERROR + " " + msg);
diff --git a/tests/tests/assist/service/AndroidManifest.xml b/tests/tests/assist/service/AndroidManifest.xml
index 543568d..2c5206a 100644
--- a/tests/tests/assist/service/AndroidManifest.xml
+++ b/tests/tests/assist/service/AndroidManifest.xml
@@ -34,6 +34,7 @@
       <activity android:name=".AssistStructureActivity" >
           <intent-filter>
               <action android:name="android.intent.action.START_TEST_ASSIST_STRUCTURE" />
+              <action android:name="android.intent.action.START_TEST_FLAG_SECURE" />
               <category android:name="android.intent.category.DEFAULT" />
           </intent-filter>
       </activity>
diff --git a/tests/tests/assist/service/src/android/voiceinteraction/service/DisableContextActivity.java b/tests/tests/assist/service/src/android/voiceinteraction/service/DisableContextActivity.java
index 0db7ec1..52ba7ac 100644
--- a/tests/tests/assist/service/src/android/voiceinteraction/service/DisableContextActivity.java
+++ b/tests/tests/assist/service/src/android/voiceinteraction/service/DisableContextActivity.java
@@ -38,6 +38,7 @@
         super.onStart();
         Intent intent = new Intent();
         intent.setComponent(new ComponentName(this, MainInteractionService.class));
+        finish();
         ComponentName serviceName = startService(intent);
         Log.i(TAG, "Started service: " + serviceName);
     }
diff --git a/tests/tests/assist/service/src/android/voiceinteraction/service/MainInteractionService.java b/tests/tests/assist/service/src/android/voiceinteraction/service/MainInteractionService.java
index 684c817..85bd6ea 100644
--- a/tests/tests/assist/service/src/android/voiceinteraction/service/MainInteractionService.java
+++ b/tests/tests/assist/service/src/android/voiceinteraction/service/MainInteractionService.java
@@ -17,7 +17,6 @@
 package android.assist.service;
 
 import android.content.ComponentName;
-import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
 import android.service.voice.VoiceInteractionService;
diff --git a/tests/tests/assist/service/src/android/voiceinteraction/service/MainInteractionSession.java b/tests/tests/assist/service/src/android/voiceinteraction/service/MainInteractionSession.java
index 7b77ea0..9a835c2 100644
--- a/tests/tests/assist/service/src/android/voiceinteraction/service/MainInteractionSession.java
+++ b/tests/tests/assist/service/src/android/voiceinteraction/service/MainInteractionSession.java
@@ -16,27 +16,19 @@
 
 package android.assist.service;
 
-import android.app.VoiceInteractor;
-import android.app.VoiceInteractor.Prompt;
 import android.app.assist.AssistContent;
 import android.app.assist.AssistStructure;
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
 import android.graphics.Bitmap;
-import android.os.AsyncTask;
 import android.os.Bundle;
 import android.service.voice.VoiceInteractionSession;
-import android.service.voice.VoiceInteractionSession.ConfirmationRequest;
-import android.service.voice.VoiceInteractionSession.PickOptionRequest;
 import android.util.Log;
 
 import java.io.ByteArrayOutputStream;
-import java.util.ArrayList;
-import java.util.List;
 
 import android.assist.common.Utils;
-import android.webkit.URLUtil;
 
 public class MainInteractionSession extends VoiceInteractionSession {
     static final String TAG = "MainInteractionSession";
@@ -93,7 +85,7 @@
 
     @Override
     public void onHandleScreenshot(/*@Nullable*/ Bitmap screenshot) {
-        Log.i(TAG, "onHandleScreenshot");
+        Log.i(TAG, String.format("onHandleScreenshot - Screenshot: %s", screenshot));
         super.onHandleScreenshot(screenshot);
         ByteArrayOutputStream bs = new ByteArrayOutputStream();
         if (screenshot != null) {
diff --git a/tests/tests/assist/src/android/assist/TestStartActivity.java b/tests/tests/assist/src/android/assist/TestStartActivity.java
index c0549c6..df9b534 100644
--- a/tests/tests/assist/src/android/assist/TestStartActivity.java
+++ b/tests/tests/assist/src/android/assist/TestStartActivity.java
@@ -21,12 +21,9 @@
 import android.app.Activity;
 import android.content.Intent;
 import android.content.ComponentName;
-import android.content.Context;
 import android.os.Bundle;
 import android.util.Log;
 
-import android.assist.common.Utils;
-
 public class TestStartActivity extends Activity {
     static final String TAG = "TestStartActivity";
 
@@ -42,22 +39,21 @@
         Log.i(TAG, " in onResume");
     }
 
-    public void startTest(String testCaseType) {
-        Log.i(TAG, "Starting test activity for TestCaseType = " + testCaseType);
+    public void startTest(String testCaseName) {
+        Log.i(TAG, "Starting test activity for TestCaseType = " + testCaseName);
         Intent intent = new Intent();
-        intent.putExtra(Utils.TESTCASE_TYPE, testCaseType);
-        intent.setAction("android.intent.action.START_TEST_" + testCaseType);
+        intent.putExtra(Utils.TESTCASE_TYPE, testCaseName);
+        intent.setAction("android.intent.action.START_TEST_" + testCaseName);
         intent.setComponent(new ComponentName("android.assist.service",
-                "android.assist." + Utils.getTestActivity(testCaseType)));
+                "android.assist." + Utils.getTestActivity(testCaseName)));
         startActivity(intent);
     }
 
-    public void start3pApp() {
+    public void start3pApp(String testCaseName) {
         Intent intent = new Intent();
-        intent.setComponent(new ComponentName("android.assist.testapp",
-                "android.assist.testapp.TestApp"));
+        intent.setAction("android.intent.action.TEST_APP_" + testCaseName);
+        intent.setComponent(Utils.getTestAppComponent(testCaseName));
         startActivity(intent);
-
     }
 
     @Override protected void onPause() {
diff --git a/tests/tests/assist/src/android/assist/cts/AssistStructureTest.java b/tests/tests/assist/src/android/assist/cts/AssistStructureTest.java
index d113774..97ab290 100644
--- a/tests/tests/assist/src/android/assist/cts/AssistStructureTest.java
+++ b/tests/tests/assist/src/android/assist/cts/AssistStructureTest.java
@@ -16,25 +16,10 @@
 
 package android.assist.cts;
 
-import android.assist.TestStartActivity;
 import android.assist.common.Utils;
 
-import android.app.assist.AssistContent;
-import android.app.assist.AssistStructure;
-import android.content.BroadcastReceiver;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.cts.util.SystemUtil;
-import android.os.Bundle;
-import android.test.ActivityInstrumentationTestCase2;
-import android.util.Log;
+import android.provider.Settings;
 
-import java.lang.Exception;
-import java.lang.Override;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
 
 /**
  *  Test that the AssistStructure returned is properly formatted.
@@ -57,22 +42,11 @@
     }
 
     public void testAssistStructure() throws Exception {
-        // TODO(awlee): verify that the context/screenshot setting is on if appropriate
-        if (mAssistContent == null) {
-            fail("Received null assistBundle or assistContent.");
-            return;
-        }
-        if (mAssistBundle == null) {
-            fail("Received null assistBundle.");
-            return;
-        }
+        assertEquals("1", Settings.Secure.getString(
+            mContext.getContentResolver(), "assist_structure_enabled"));
 
-        if (mAssistStructure == null) {
-            fail("Received null assistStructure");
-            return;
-        } else {
-            verifyAssistStructure(Utils.getTestAppComponent(TEST_CASE_TYPE),
+        verifyAssistDataNullness(false, false, false, false);
+        verifyAssistStructure(Utils.getTestAppComponent(TEST_CASE_TYPE),
                     false /*FLAG_SECURE set*/);
-        }
     }
 }
\ No newline at end of file
diff --git a/tests/tests/assist/src/android/assist/cts/AssistTestBase.java b/tests/tests/assist/src/android/assist/cts/AssistTestBase.java
index b2ec739..e6d08cf 100644
--- a/tests/tests/assist/src/android/assist/cts/AssistTestBase.java
+++ b/tests/tests/assist/src/android/assist/cts/AssistTestBase.java
@@ -19,7 +19,6 @@
 import android.assist.TestStartActivity;
 import android.assist.common.Utils;
 
-import android.app.Activity;
 import android.app.assist.AssistContent;
 import android.app.assist.AssistStructure;
 import android.content.BroadcastReceiver;
@@ -27,9 +26,11 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
+import android.content.res.XmlResourceParser;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.os.Bundle;
+import android.provider.Settings;
 import android.test.ActivityInstrumentationTestCase2;
 import android.util.Log;
 
@@ -57,6 +58,11 @@
     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"));
+        logContextAndScreenshotSetting();
     }
 
     @Override
@@ -71,7 +77,7 @@
         mTestName = testName;
         intent.setAction("android.intent.action.TEST_START_ACTIVITY_" + testName);
         intent.setComponent(new ComponentName(getInstrumentation().getContext(),
-                TestStartActivity.class));
+            TestStartActivity.class));
         setActivityIntent(intent);
         mTestActivity = getActivity();
     }
@@ -86,9 +92,9 @@
         }
         mReceiver = new TestResultsReceiver();
         mContext.registerReceiver(mReceiver,
-                new IntentFilter(Utils.BROADCAST_ASSIST_DATA_INTENT));
+            new IntentFilter(Utils.BROADCAST_ASSIST_DATA_INTENT));
 
-        mTestActivity.start3pApp();
+        mTestActivity.start3pApp(mTestName);
         mTestActivity.startTest(mTestName);
         if (!mLatch.await(Utils.TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
             fail("Failed to receive broadcast in " + Utils.TIMEOUT_MS + "msec");
@@ -97,6 +103,43 @@
         return true;
     }
 
+    /**
+     * Checks that the nullness of values are what we expect.
+     * @param isBundleNull True if assistBundle should be null.
+     * @param isStructureNull True if assistStructure should be null.
+     * @param isContentNull True if assistContent should be null.
+     * @param isScreenshotNull True if screenshot should be null.
+     */
+    protected void verifyAssistDataNullness(boolean isBundleNull, boolean isStructureNull,
+            boolean isContentNull, boolean isScreenshotNull) {
+
+        if ((mAssistContent == null) != isContentNull) {
+            fail(String.format("Should %s have been null - AssistContent: %s",
+                    isContentNull? "":"not", mAssistContent));
+        }
+
+        if ((mAssistStructure == null) != isStructureNull) {
+            fail(String.format("Should %s have been null - AssistStructure: %s",
+                isStructureNull ? "" : "not", mAssistStructure));
+        }
+
+        if ((mAssistBundle == null) != isBundleNull) {
+            fail(String.format("Should %s have been null - AssistBundle: %s",
+                    isBundleNull? "":"not", mAssistBundle));
+        }
+
+        if ((mScreenshot == null) != isScreenshotNull) {
+            fail(String.format("Should %s have been null - Screenshot: %s",
+                    isScreenshotNull? "":"not", mScreenshot));
+        }
+    }
+
+    /**
+     * Traverses and compares the view heirarchy of the backgroundApp and the view we expect.
+     *
+     * @param backgroundApp ComponentName of app the assistant is invoked upon
+     * @param isSecureWindow Denotes whether the activity has FLAG_SECURE set
+     */
     protected void verifyAssistStructure(ComponentName backgroundApp, boolean isSecureWindow) {
         // Check component name matches
         assertEquals(backgroundApp.flattenToString(),
@@ -106,10 +149,18 @@
         assertEquals(1, numWindows);
         for (int i = 0; i < numWindows; i++) {
             AssistStructure.ViewNode node = mAssistStructure.getWindowNodeAt(i).getRootViewNode();
-            // TODO: traverse view heirarchy and verify it matches what we expect
+            // TODO: Actually traverse the view heirarchy and verify it matches what we expect
+            // If isSecureWindow, will not have any children.
         }
     }
 
+    protected void logContextAndScreenshotSetting() {
+        Log.i(TAG, "Context is: " + Settings.Secure.getString(
+            mContext.getContentResolver(), "assist_structure_enabled"));
+        Log.i(TAG, "Screenshot is: " + Settings.Secure.getString(
+            mContext.getContentResolver(), "assist_screenshot_enabled"));
+    }
+
     class TestResultsReceiver extends BroadcastReceiver {
         @Override
         public void onReceive(Context context, Intent intent) {
diff --git a/tests/tests/assist/src/android/assist/cts/DisableContextTest.java b/tests/tests/assist/src/android/assist/cts/DisableContextTest.java
index 6801737..9407ec5 100644
--- a/tests/tests/assist/src/android/assist/cts/DisableContextTest.java
+++ b/tests/tests/assist/src/android/assist/cts/DisableContextTest.java
@@ -53,8 +53,8 @@
         SystemUtil.runShellCommand(getInstrumentation(),
                 "settings put secure assist_structure_enabled 0");
         SystemUtil.runShellCommand(getInstrumentation(),
-                "settings put secure assist_screenshot_enabled 0");
-
+            "settings put secure assist_screenshot_enabled 0");
+        logContextAndScreenshotSetting();
         startTestActivity(TEST_CASE_TYPE);
         waitForBroadcast();
     }
@@ -64,20 +64,14 @@
         SystemUtil.runShellCommand(getInstrumentation(),
                 "settings put secure assist_structure_enabled 1");
         SystemUtil.runShellCommand(getInstrumentation(),
-                "settings put secure assist_screenshot_enabled 1");
+            "settings put secure assist_screenshot_enabled 1");
+        logContextAndScreenshotSetting();
         super.tearDown();
     }
 
     public void testContextAndScreenshotOff() throws Exception {
         // Both settings off
-        if (mAssistContent != null || mAssistBundle != null || mAssistStructure != null) {
-            fail(String.format("Should have all been null - Bundle: %s, Structure: %s, Content: %s",
-                    mAssistBundle, mAssistStructure, mAssistContent));
-        }
-
-        if (mScreenshot != null) {
-            fail(String.format("Should have been null - Screenshot: %s", mScreenshot));
-        }
+        verifyAssistDataNullness(true, true, true, true);
 
         // Screenshot off, context on
         SystemUtil.runShellCommand(getInstrumentation(),
@@ -86,29 +80,19 @@
             "settings put secure assist_screenshot_enabled 0");
         waitForBroadcast();
 
-        if (mScreenshot != null) {
-            fail(String.format("Should have been null - Screenshot: %s", mScreenshot));
-        }
+        logContextAndScreenshotSetting();
 
-        if (mAssistContent == null || mAssistBundle == null) {
-            fail(String.format("Should not have been null - Bundle: %s, Content: %s",
-                mAssistBundle, mAssistContent));
-        }
+        verifyAssistDataNullness(false, false, false, true);
 
         // Context off, screenshot on
         SystemUtil.runShellCommand(getInstrumentation(),
-            "settings put secure assist_screenshot_enabled 1");
-        SystemUtil.runShellCommand(getInstrumentation(),
             "settings put secure assist_structure_enabled 0");
+        SystemUtil.runShellCommand(getInstrumentation(),
+            "settings put secure assist_screenshot_enabled 1");
         waitForBroadcast();
 
-        if (mScreenshot == null) {
-            fail(String.format("Should not have been null - Screenshot: %s", mScreenshot));
-        }
+        logContextAndScreenshotSetting();
 
-        if (mAssistContent != null || mAssistBundle != null || mAssistStructure != null) {
-            fail(String.format("Should have all been null - Bundle: %s, Structure: %s, Content: %s",
-                mAssistBundle, mAssistStructure, mAssistContent));
-        }
+        verifyAssistDataNullness(true, true, true, false);
     }
 }
\ 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
new file mode 100644
index 0000000..0e79d9d
--- /dev/null
+++ b/tests/tests/assist/src/android/assist/cts/FlagSecureTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.assist.cts;
+
+import android.assist.common.Utils;
+
+import java.util.concurrent.CountDownLatch;
+
+/**
+ * Test we receive proper assist data (root assistStructure with no children) when the assistant is
+ * invoked on an app with FLAG_SECURE set.
+ */
+public class FlagSecureTest extends AssistTestBase {
+
+    static final String TAG = "DisableContextTest";
+
+    private static final String TEST_CASE_TYPE = Utils.FLAG_SECURE;
+
+    public FlagSecureTest() {
+        super();
+    }
+
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        startTestActivity(TEST_CASE_TYPE);
+        waitForBroadcast();
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testSecureActivity() throws Exception {
+        verifyAssistDataNullness(false, false, false, true);
+
+        // verify that we have only the root window and not its children.
+        verifyAssistStructure(Utils.getTestAppComponent(TEST_CASE_TYPE), true);
+    }
+}
\ No newline at end of file
diff --git a/tests/tests/assist/testapp/AndroidManifest.xml b/tests/tests/assist/testapp/AndroidManifest.xml
index 5b16ed7..371ae7b 100644
--- a/tests/tests/assist/testapp/AndroidManifest.xml
+++ b/tests/tests/assist/testapp/AndroidManifest.xml
@@ -19,16 +19,25 @@
     package="android.assist.testapp">
 
     <application>
-      <uses-library android:name="android.test.runner" />
+        <uses-library android:name="android.test.runner" />
 
-      <activity android:name="TestApp"
+        <activity android:name="TestApp"
                 android:label="Assist Test App"
                 android:theme="@android:style/Theme.Material.Light">
           <intent-filter>
-              <action android:name="android.intent.action.TEST_APP" />
+              <action android:name="android.intent.action.TEST_APP_ASSIST_STRUCTURE" />
               <category android:name="android.intent.category.DEFAULT" />
               <category android:name="android.intent.category.VOICE" />
           </intent-filter>
-      </activity>
+        </activity>
+        <activity android:name="SecureActivity"
+                  android:label="Secure Test App"
+                  android:theme="@android:style/Theme.Material.Light">
+            <intent-filter>
+                <action android:name="android.intent.action.TEST_APP_FLAG_SECURE" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <category android:name="android.intent.category.VOICE" />
+            </intent-filter>
+        </activity>
     </application>
 </manifest>
diff --git a/tests/tests/assist/testapp/res/layout/voice_interaction_main.xml b/tests/tests/assist/testapp/res/layout/secure_app.xml
similarity index 100%
rename from tests/tests/assist/testapp/res/layout/voice_interaction_main.xml
rename to tests/tests/assist/testapp/res/layout/secure_app.xml
diff --git a/tests/tests/assist/testapp/res/layout/voice_interaction_main.xml b/tests/tests/assist/testapp/res/layout/test_app.xml
similarity index 100%
copy from tests/tests/assist/testapp/res/layout/voice_interaction_main.xml
copy to tests/tests/assist/testapp/res/layout/test_app.xml
diff --git a/tests/tests/assist/testapp/src/android/voiceinteraction/testapp/SecureActivity.java b/tests/tests/assist/testapp/src/android/voiceinteraction/testapp/SecureActivity.java
new file mode 100644
index 0000000..83f7549
--- /dev/null
+++ b/tests/tests/assist/testapp/src/android/voiceinteraction/testapp/SecureActivity.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.assist.testapp;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.util.Log;
+
+import android.view.WindowManager;
+
+public class SecureActivity extends Activity {
+    static final String TAG = "SecureActivity";
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        Log.i(TAG, "SecureActivity created");
+        setContentView(R.layout.secure_app);
+        getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
+            WindowManager.LayoutParams.FLAG_SECURE);
+    }
+}
\ No newline at end of file
diff --git a/tests/tests/assist/testapp/src/android/voiceinteraction/testapp/TestApp.java b/tests/tests/assist/testapp/src/android/voiceinteraction/testapp/TestApp.java
index 7fa9653..85a9342 100644
--- a/tests/tests/assist/testapp/src/android/voiceinteraction/testapp/TestApp.java
+++ b/tests/tests/assist/testapp/src/android/voiceinteraction/testapp/TestApp.java
@@ -17,17 +17,9 @@
 package android.assist.testapp;
 
 import android.app.Activity;
-import android.content.BroadcastReceiver;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
 import android.os.Bundle;
 import android.util.Log;
 
-import java.util.ArrayList;
-
-import android.assist.common.Utils;
-
 public class TestApp extends Activity {
     static final String TAG = "TestApp";
 
@@ -38,7 +30,7 @@
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         Log.i(TAG, "TestApp created");
-        getLayoutInflater().inflate(R.layout.voice_interaction_main, null);
+        getLayoutInflater().inflate(R.layout.test_app, null);
     }
 
     @Override