Test onHandleScreenshot for approximate pixel equality to expected view.

Set up mechanism to wait for the third party app to resume fully before
launching assist on it to ensure the view has finished loading.
Screenshot equality tested with solid color views. A percentage of
pixels of that color in the screenshot above a certain threshold passes
the test.

Bug: 21668302

Change-Id: Ibe1826e6ff0ea510e1d5f0d1987947fa303fbe81
diff --git a/tests/expectations/knownfailures.txt b/tests/expectations/knownfailures.txt
index 29c5035..409e1a2 100644
--- a/tests/expectations/knownfailures.txt
+++ b/tests/expectations/knownfailures.txt
@@ -287,5 +287,12 @@
     "com.android.cts.app.os.OsHostTests#testNonExportedActivities"
   ],
   bug: 23779168
+},
+{
+  description: "New assist tests that do not yet have a track record.",
+  names: [
+    "android.assist.cts.ScreenshotTest"
+  ],
+  bug: 21668302
 }
 ]
diff --git a/tests/tests/assist/AndroidManifest.xml b/tests/tests/assist/AndroidManifest.xml
index fefdf54..ac41e44 100644
--- a/tests/tests/assist/AndroidManifest.xml
+++ b/tests/tests/assist/AndroidManifest.xml
@@ -20,17 +20,18 @@
 
     <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
     <uses-permission android:name="android.permission.BIND_VOICE_INTERACTION" />
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
 
     <application>
       <uses-library android:name="android.test.runner" />
       <activity android:name="android.assist.cts.TestStartActivity"
-                android:label="Assist Structure Test App"
-                android:theme="@android:style/Theme.Material.Light">
+                android:label="Assist Test Start Activity">
           <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" />
               <action android:name="android.intent.action.TEST_START_ACTIVITY_LIFECYCLE" />
+              <action android:name="android.intent.action.TEST_START_ACTIVITY_SCREENSHOT" />
               <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 4bf9412..0d4120e 100644
--- a/tests/tests/assist/common/src/android/assist/common/Utils.java
+++ b/tests/tests/assist/common/src/android/assist/common/Utils.java
@@ -29,13 +29,17 @@
     public static final String BROADCAST_ASSIST_DATA_INTENT = ACTION_PREFIX + "ASSIST_DATA";
     public static final String BROADCAST_INTENT_START_ASSIST = ACTION_PREFIX + "START_ASSIST";
     public static final String ASSIST_RECEIVER_REGISTERED = ACTION_PREFIX + "ASSIST_READY";
+    public static final String ACTION_INVALIDATE = "invalidate_action";
     public static final String TEST_ERROR = "Error In Test:";
 
     public static final String ASSIST_STRUCTURE_KEY = "assist_structure";
     public static final String ASSIST_CONTENT_KEY = "assist_content";
     public static final String ASSIST_BUNDLE_KEY = "assist_bundle";
     public static final String ASSIST_SCREENSHOT_KEY = "assist_screenshot";
-
+    public static final String SCREENSHOT_COLOR_KEY = "set_screenshot_color";
+    public static final String COMPARE_SCREENSHOT_KEY = "compare_screenshot";
+    public static final String DISPLAY_WIDTH_KEY = "display_width";
+    public static final String DISPLAY_HEIGHT_KEY = "dislay_height";
 
     /** Lifecycle Test intent constants */
     public static final String LIFECYCLE_PREFIX = ACTION_PREFIX + "lifecycle_";
@@ -46,12 +50,15 @@
 
     /** Flag Secure Test intent constants */
     public static final String FLAG_SECURE_HASRESUMED = ACTION_PREFIX + "flag_secure_hasResumed";
+    public static final String SCREENSHOT_HASRESUMED = ACTION_PREFIX + "screenshot_hasResumed";
     public static final String ASSIST_STRUCTURE_HASRESUMED = ACTION_PREFIX
             + "assist_structure_hasResumed";
 
     /** Two second timeout for getting back assist context */
     public static final int TIMEOUT_MS = 2 * 1000;
+    /** Four second timeout for an activity to resume */
     public static final int ACTIVITY_ONRESUME_TIMEOUT_MS = 4000;
+
     public static final String EXTRA_REGISTER_RECEIVER = "register_receiver";
 
     /** Test name suffixes */
@@ -59,20 +66,22 @@
     public static final String DISABLE_CONTEXT = "DISABLE_CONTEXT";
     public static final String FLAG_SECURE = "FLAG_SECURE";
     public static final String LIFECYCLE = "LIFECYCLE";
+    public static final String SCREENSHOT = "SCREENSHOT";
 
     /** Session intent constants */
     public static final String HIDE_SESSION = "android.intent.action.hide_session";
 
-    /**
-     * The shim activity that starts the service associated with each test.
-     */
+    /** The shim activity that starts the service associated with each test. */
     public static final String getTestActivity(String testCaseType) {
         switch (testCaseType) {
             case DISABLE_CONTEXT:
+                // doesn't need to wait for activity to resume
+                // can be activated on top of any non-secure activity.
                 return "service.DisableContextActivity";
             case ASSIST_STRUCTURE:
             case FLAG_SECURE:
             case LIFECYCLE:
+            case SCREENSHOT:
                 return "service.DelayedAssistantActivity";
             default:
                 return "";
@@ -85,22 +94,41 @@
     public static final ComponentName getTestAppComponent(String testCaseType) {
         switch (testCaseType) {
             case ASSIST_STRUCTURE:
-                return new ComponentName(
-                        "android.assist.testapp", "android.assist.testapp.TestApp");
             case DISABLE_CONTEXT:
                 return new ComponentName(
-                        "android.assist.testapp", "android.assist.testapp.DisableContextActivity");
+                        "android.assist.testapp", "android.assist.testapp.TestApp");
             case FLAG_SECURE:
                 return new ComponentName(
                         "android.assist.testapp", "android.assist.testapp.SecureActivity");
             case LIFECYCLE:
                 return new ComponentName(
                         "android.assist.testapp", "android.assist.testapp.LifecycleActivity");
+            case SCREENSHOT:
+                return new ComponentName(
+                        "android.assist.testapp", "android.assist.testapp.ScreenshotActivity");
             default:
                 return new ComponentName("","");
         }
     }
 
+    /**
+     * Returns the amount of time to wait for assist data.
+     */
+    public static final int getAssistDataTimeout(String testCaseType) {
+        switch (testCaseType) {
+            case ASSIST_STRUCTURE:
+            case FLAG_SECURE:
+            case DISABLE_CONTEXT:
+            case LIFECYCLE:
+                return TIMEOUT_MS;
+            case SCREENSHOT:
+                // needs to wait for 3p activity to resume before receiving assist data.
+                return TIMEOUT_MS + ACTIVITY_ONRESUME_TIMEOUT_MS;
+            default:
+                return 0;
+        }
+    }
+
     public static final String toBundleString(Bundle bundle) {
         if (bundle == null) {
             return "*** Bundle is null ****";
diff --git a/tests/tests/assist/res/layout/screenshot_activity.xml b/tests/tests/assist/res/layout/screenshot_activity.xml
new file mode 100644
index 0000000..05051dc
--- /dev/null
+++ b/tests/tests/assist/res/layout/screenshot_activity.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<RelativeLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/screenshot_activity"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+</RelativeLayout>
\ No newline at end of file
diff --git a/tests/tests/assist/res/values/strings.xml b/tests/tests/assist/res/values/strings.xml
index ae4f16e..a84c743 100644
--- a/tests/tests/assist/res/values/strings.xml
+++ b/tests/tests/assist/res/values/strings.xml
@@ -15,4 +15,6 @@
 -->
 <resources>
     <string name="welcome">Hello there!</string>
+     <string name="testAppTitle">Assist Structure Test Activity</string>
+     <string name="screenshotActivityTitle">Screenshot Test Activity</string>
 </resources>
diff --git a/tests/tests/assist/service/AndroidManifest.xml b/tests/tests/assist/service/AndroidManifest.xml
index 5a22d31..b577be7 100644
--- a/tests/tests/assist/service/AndroidManifest.xml
+++ b/tests/tests/assist/service/AndroidManifest.xml
@@ -18,6 +18,8 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="android.assist.service">
 
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+
     <application>
       <uses-library android:name="android.test.runner" />
       <service android:name=".MainInteractionService"
@@ -43,6 +45,7 @@
               <action android:name="android.intent.action.START_TEST_ASSIST_STRUCTURE" />
               <action android:name="android.intent.action.START_TEST_LIFECYCLE" />
               <action android:name="android.intent.action.START_TEST_FLAG_SECURE" />
+              <action android:name="android.intent.action.START_TEST_SCREENSHOT" />
               <category android:name="android.intent.category.DEFAULT" />
           </intent-filter>
       </activity>
diff --git a/tests/tests/assist/service/src/android/voiceinteraction/service/DelayedAssistantActivity.java b/tests/tests/assist/service/src/android/voiceinteraction/service/DelayedAssistantActivity.java
index b7d67f1..ddf43bd 100644
--- a/tests/tests/assist/service/src/android/voiceinteraction/service/DelayedAssistantActivity.java
+++ b/tests/tests/assist/service/src/android/voiceinteraction/service/DelayedAssistantActivity.java
@@ -26,11 +26,17 @@
 public class DelayedAssistantActivity extends Activity {
     static final String TAG = "DelayedAssistantActivity";
 
+    @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         Intent intent = new Intent();
         intent.setComponent(new ComponentName(this, MainInteractionService.class));
         intent.putExtra(Utils.EXTRA_REGISTER_RECEIVER, true);
+        intent.putExtra(Utils.TESTCASE_TYPE, getIntent().getStringExtra(Utils.TESTCASE_TYPE));
+        intent.putExtra(Utils.DISPLAY_WIDTH_KEY,
+                getIntent().getIntExtra(Utils.DISPLAY_WIDTH_KEY, 0));
+        intent.putExtra(Utils.DISPLAY_HEIGHT_KEY,
+                getIntent().getIntExtra(Utils.DISPLAY_HEIGHT_KEY, 0));
         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 fc19e1c..aa5316c 100644
--- a/tests/tests/assist/service/src/android/voiceinteraction/service/MainInteractionService.java
+++ b/tests/tests/assist/service/src/android/voiceinteraction/service/MainInteractionService.java
@@ -30,11 +30,17 @@
 import android.service.voice.VoiceInteractionSession;
 import android.util.Log;
 
+import java.lang.Exception;
+import java.lang.Override;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
 public class MainInteractionService extends VoiceInteractionService {
     static final String TAG = "MainInteractionService";
     private Intent mIntent;
     private boolean mReady = false;
-    private BroadcastReceiver mBroadcastReceiver;
+    private BroadcastReceiver mBroadcastReceiver, mResumeReceiver;
+    private CountDownLatch mResumeLatch;
 
     @Override
     public void onReady() {
@@ -57,17 +63,27 @@
         } else {
             if (isActiveService(this, new ComponentName(this, getClass()))) {
                 if (mIntent.getBooleanExtra(Utils.EXTRA_REGISTER_RECEIVER, false)) {
-                    Log.i(TAG, "Registering receiver to start session later");
+                    mResumeLatch = new CountDownLatch(1);
                     if (mBroadcastReceiver == null) {
                         mBroadcastReceiver = new MainInteractionServiceBroadcastReceiver();
-                        registerReceiver(mBroadcastReceiver,
-                                new IntentFilter(Utils.BROADCAST_INTENT_START_ASSIST));
+                        IntentFilter filter = new IntentFilter();
+                        filter.addAction(Utils.BROADCAST_INTENT_START_ASSIST);
+                        registerReceiver(mBroadcastReceiver, filter);
+                        Log.i(TAG, "Registered receiver to start session later");
+
+                        IntentFilter resumeFilter = new IntentFilter(Utils.SCREENSHOT_HASRESUMED);
+                        mResumeReceiver = new MainServiceAppResumeReceiver();
+                        registerReceiver(mResumeReceiver, resumeFilter);
+                        Log.i(TAG, "Registered receiver for resuming activity");
                     }
                     sendBroadcast(new Intent(Utils.ASSIST_RECEIVER_REGISTERED));
               } else {
                   Log.i(TAG, "Yay! about to start session");
-                  showSession(new Bundle(), VoiceInteractionSession.SHOW_WITH_ASSIST |
-                          VoiceInteractionSession.SHOW_WITH_SCREENSHOT);
+                  Bundle bundle = new Bundle();
+                  bundle.putString(Utils.TESTCASE_TYPE,
+                          mIntent.getStringExtra(Utils.TESTCASE_TYPE));
+                  showSession(bundle, VoiceInteractionSession.SHOW_WITH_ASSIST |
+                      VoiceInteractionSession.SHOW_WITH_SCREENSHOT);
               }
             } else {
                 Log.wtf(TAG, "**** Not starting MainInteractionService because" +
@@ -81,7 +97,49 @@
         public void onReceive(Context context, Intent intent) {
             Log.i(MainInteractionService.TAG, "Recieved broadcast to start session now.");
             if (intent.getAction().equals(Utils.BROADCAST_INTENT_START_ASSIST)) {
-                showSession(new Bundle(), SHOW_WITH_ASSIST | SHOW_WITH_SCREENSHOT);
+                String testCaseName = intent.getStringExtra(Utils.TESTCASE_TYPE);
+                Log.i(MainInteractionService.TAG, "trying to start 3p activity: " + testCaseName);
+                Bundle extras = intent.getExtras();
+                if (extras == null) {
+                    extras = new Bundle();
+                }
+                if (testCaseName.equals(Utils.SCREENSHOT)) {
+                    try {
+                        // extra info to pass along to 3p activity.
+
+                        Intent intent3p = new Intent();
+                        Log.i(TAG, "starting the 3p app again");
+                        intent3p.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                        intent3p.setAction("android.intent.action.TEST_APP_" + testCaseName);
+                        intent3p.setComponent(Utils.getTestAppComponent(testCaseName));
+                        intent3p.putExtras(extras);
+                        startActivity(intent3p);
+                        if (!MainInteractionService.this.mResumeLatch
+                                .await(Utils.ACTIVITY_ONRESUME_TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
+                            Log.i(TAG, "waited for 3p activity to resume");
+                        }
+                    } catch (Exception e) {
+                        Log.i(TAG, "failed so reload 3p app: " + e.toString());
+                    }
+                }
+                extras.putString(Utils.TESTCASE_TYPE, mIntent.getStringExtra(Utils.TESTCASE_TYPE));
+                MainInteractionService.this.showSession(
+                        extras, SHOW_WITH_ASSIST | SHOW_WITH_SCREENSHOT);
+            }
+        }
+    }
+
+    private class MainServiceAppResumeReceiver extends BroadcastReceiver {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            if (intent.getAction().equals(Utils.SCREENSHOT_HASRESUMED)) {
+                Log.i(MainInteractionService.TAG,
+                    "screenshot activity has resumed in this new receiver");
+                if (MainInteractionService.this.mResumeLatch != null) {
+                    MainInteractionService.this.mResumeLatch.countDown();
+                } else {
+                    Log.i(TAG, "mResumeLatch was null");
+                }
             }
         }
     }
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 38d03f8..8fd8271 100644
--- a/tests/tests/assist/service/src/android/voiceinteraction/service/MainInteractionSession.java
+++ b/tests/tests/assist/service/src/android/voiceinteraction/service/MainInteractionSession.java
@@ -24,15 +24,21 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.graphics.Bitmap;
+import android.graphics.Color;
+import android.graphics.Point;
 import android.os.Bundle;
 import android.service.voice.VoiceInteractionSession;
+import android.util.DisplayMetrics;
 import android.util.Log;
+import android.view.Display;
 import android.view.LayoutInflater;
 import android.view.View;
 
 import java.io.ByteArrayOutputStream;
+import java.util.Date;
 
 import android.assist.common.Utils;
+import android.view.WindowManager;
 
 public class MainInteractionSession extends VoiceInteractionSession {
     static final String TAG = "MainInteractionSession";
@@ -43,7 +49,12 @@
 
     private boolean hasReceivedAssistData = false;
     private boolean hasReceivedScreenshot = false;
+    private int mCurColor;
+    private int mDisplayHeight;
+    private int mDisplayWidth;
+    private Bitmap mScreenshot;
     private BroadcastReceiver mReceiver;
+    private String mTestName;
 
     MainInteractionSession(Context context) {
         super(context);
@@ -78,12 +89,13 @@
 
     @Override
     public void onShow(Bundle args, int showFlags) {
-        // set some content view.
-        // TODO: check that the view takes up the whole screen.
-        // check that interactor mode is for assist
         if ((showFlags & SHOW_WITH_ASSIST) == 0) {
             return;
         }
+        mTestName = args.getString(Utils.TESTCASE_TYPE, "");
+        mCurColor = args.getInt(Utils.SCREENSHOT_COLOR_KEY);
+        mDisplayHeight = args.getInt(Utils.DISPLAY_HEIGHT_KEY);
+        mDisplayWidth = args.getInt(Utils.DISPLAY_WIDTH_KEY);
         super.onShow(args, showFlags);
     }
 
@@ -107,17 +119,52 @@
     public void onHandleScreenshot(/*@Nullable*/ Bitmap screenshot) {
         Log.i(TAG, String.format("onHandleScreenshot - Screenshot: %s", screenshot));
         super.onHandleScreenshot(screenshot);
-        ByteArrayOutputStream bs = new ByteArrayOutputStream();
+
         if (screenshot != null) {
-            screenshot.compress(Bitmap.CompressFormat.PNG, 50, bs);
-            mAssistData.putByteArray(Utils.ASSIST_SCREENSHOT_KEY, bs.toByteArray());
+            mAssistData.putBoolean(Utils.ASSIST_SCREENSHOT_KEY, true);
+
+            if (mTestName.equals(Utils.SCREENSHOT)) {
+                boolean screenshotMatches = compareScreenshot(screenshot, mCurColor);
+                Log.i(TAG, "this is a screenshot test. Matches? " + screenshotMatches);
+                mAssistData.putBoolean(
+                    Utils.COMPARE_SCREENSHOT_KEY, screenshotMatches);
+            }
         } else {
-            mAssistData.putByteArray(Utils.ASSIST_SCREENSHOT_KEY, null);
+            mAssistData.putBoolean(Utils.ASSIST_SCREENSHOT_KEY, false);
         }
         hasReceivedScreenshot = true;
         maybeBroadcastResults();
     }
 
+    private boolean compareScreenshot(Bitmap screenshot, int color) {
+        Point size = new Point(mDisplayWidth, mDisplayHeight);
+
+        if (screenshot.getWidth() != size.x || screenshot.getHeight() != size.y) {
+            Log.i(TAG, "width  or height didn't match: " + size + " vs " + screenshot.getWidth()
+                    + "," + screenshot.getHeight());
+            return false;
+        }
+        int[] pixels = new int[size.x * size.y];
+        screenshot.getPixels(pixels, 0, size.x, 0, 0, size.x, size.y);
+
+        int expectedColor = 0;
+        int wrongColor = 0;
+        for (int pixel : pixels) {
+            if (pixel == color) {
+                expectedColor += 1;
+            } else {
+                wrongColor += 1;
+            }
+        }
+
+        double colorRatio = (double) expectedColor / (expectedColor + wrongColor);
+        Log.i(TAG, "the ratio is " + colorRatio);
+        if (colorRatio < 0.6) {
+            return false;
+        }
+        return true;
+    }
+
     private void maybeBroadcastResults() {
         if (!hasReceivedAssistData) {
             Log.i(TAG, "waiting for assist data before broadcasting results");
@@ -143,11 +190,4 @@
         }
         return f.inflate(R.layout.assist_layer,null);
     }
-
-    class DoneReceiver extends BroadcastReceiver {
-        @Override
-        public void onReceive(Context context, Intent intent) {
-            Log.i(TAG, "Done_broadcast " + intent.getAction());
-        }
-    }
 }
diff --git a/tests/tests/assist/src/android/assist/cts/AssistStructureTest.java b/tests/tests/assist/src/android/assist/cts/AssistStructureTest.java
index 8ff235b..6f255bf 100644
--- a/tests/tests/assist/src/android/assist/cts/AssistStructureTest.java
+++ b/tests/tests/assist/src/android/assist/cts/AssistStructureTest.java
@@ -95,9 +95,13 @@
         public void onReceive(Context context, Intent intent) {
             String action = intent.getAction();
             if (action.equals(Utils.ASSIST_STRUCTURE_HASRESUMED)) {
-                mHasResumedLatch.countDown();
+                if (mHasResumedLatch != null) {
+                    mHasResumedLatch.countDown();
+                }
             } else if (action.equals(Utils.ASSIST_RECEIVER_REGISTERED)) {
-                mAssistantReadyLatch.countDown();
+                if (mAssistantReadyLatch != null) {
+                    mAssistantReadyLatch.countDown();
+                }
             }
         }
     }
diff --git a/tests/tests/assist/src/android/assist/cts/AssistTestBase.java b/tests/tests/assist/src/android/assist/cts/AssistTestBase.java
index 25460e5..fd7bd27 100644
--- a/tests/tests/assist/src/android/assist/cts/AssistTestBase.java
+++ b/tests/tests/assist/src/android/assist/cts/AssistTestBase.java
@@ -33,10 +33,13 @@
 import android.cts.util.SystemUtil;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
+import android.graphics.Color;
+import android.graphics.Point;
 import android.os.Bundle;
 import android.provider.Settings;
 import android.test.ActivityInstrumentationTestCase2;
 import android.util.Log;
+import android.view.Display;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -52,12 +55,14 @@
     protected TestStartActivity mTestActivity;
     protected AssistContent mAssistContent;
     protected AssistStructure mAssistStructure;
-    protected Bitmap mScreenshot;
+    protected boolean mScreenshot;
+    protected Bitmap mAppScreenshot;
     protected BroadcastReceiver mReceiver;
     protected Bundle mAssistBundle;
     protected Context mContext;
-    protected CountDownLatch mLatch, mAssistantReadyLatch;
-
+    protected CountDownLatch mLatch, mAssistantReadyLatch, mScreenshotLatch, mHasResumedLatch;
+    protected boolean mScreenshotMatches;
+    private Point mDisplaySize;
     private String mTestName;
     private View mView;
 
@@ -75,22 +80,35 @@
         SystemUtil.runShellCommand(getInstrumentation(),
                 "settings put secure assist_screenshot_enabled 1");
         logContextAndScreenshotSetting();
+        // reset old values
+        mScreenshotMatches = false;
+        mScreenshot = false;
+        mAssistStructure = null;
+        mAssistContent = null;
+        mAssistBundle = null;
     }
 
     @Override
     protected void tearDown() throws Exception {
-        mContext.unregisterReceiver(mReceiver);
         mTestActivity.finish();
-        super.tearDown();
         mContext.sendBroadcast(new Intent(Utils.HIDE_SESSION));
+        if (mReceiver != null) {
+            mContext.unregisterReceiver(mReceiver);
+            mReceiver = null;
+        }
+        super.tearDown();
     }
 
+    /**
+     * Starts the shim service activity
+     */
     protected void startTestActivity(String testName) {
         Intent intent = new Intent();
         mTestName = testName;
         intent.setAction("android.intent.action.TEST_START_ACTIVITY_" + testName);
         intent.setComponent(new ComponentName(getInstrumentation().getContext(),
                 TestStartActivity.class));
+        intent.putExtra(Utils.TESTCASE_TYPE, testName);
         setActivityIntent(intent);
         mTestActivity = getActivity();
     }
@@ -109,11 +127,33 @@
      * Send broadcast to MainInteractionService to start a session
      */
     protected void startSession() {
-        mContext.sendBroadcast(new Intent(Utils.BROADCAST_INTENT_START_ASSIST));
+        startSession(mTestName, new Bundle());
+    }
+
+    protected void startSession(String testName, Bundle extras) {
+        Intent intent = new Intent(Utils.BROADCAST_INTENT_START_ASSIST);
+        Log.i(TAG, "passed in class test name is: " + testName);
+        intent.putExtra(Utils.TESTCASE_TYPE, testName);
+        addDimensionsToIntent(intent);
+        intent.putExtras(extras);
+        mContext.sendBroadcast(intent);
     }
 
     /**
-     * Called after startTestActivity
+     * Calculate display dimensions (including navbar) to pass along in the given intent.
+     */
+    private void addDimensionsToIntent(Intent intent) {
+        if (mDisplaySize == null) {
+            Display display = mTestActivity.getWindowManager().getDefaultDisplay();
+            mDisplaySize = new Point();
+            display.getRealSize(mDisplaySize);
+        }
+        intent.putExtra(Utils.DISPLAY_WIDTH_KEY, mDisplaySize.x);
+        intent.putExtra(Utils.DISPLAY_HEIGHT_KEY, mDisplaySize.y);
+    }
+
+    /**
+     * Called after startTestActivity. Includes check for receiving context.
      */
     protected boolean waitForBroadcast() throws Exception {
         mTestActivity.start3pApp(mTestName);
@@ -123,15 +163,16 @@
 
     protected boolean waitForContext() throws Exception {
         mLatch = new CountDownLatch(1);
+
         if (mReceiver != null) {
             mContext.unregisterReceiver(mReceiver);
         }
         mReceiver = new TestResultsReceiver();
-        mContext.registerReceiver(mReceiver,
-            new IntentFilter(Utils.BROADCAST_ASSIST_DATA_INTENT));
-
-        if (!mLatch.await(Utils.TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
-            fail("Failed to receive broadcast in " + Utils.TIMEOUT_MS + "msec");
+        IntentFilter filter = new IntentFilter();
+        filter.addAction(Utils.BROADCAST_ASSIST_DATA_INTENT);
+        mContext.registerReceiver(mReceiver, filter);
+        if (!mLatch.await(Utils.getAssistDataTimeout(mTestName), TimeUnit.MILLISECONDS)) {
+            fail("Fail to receive broadcast in " + Utils.getAssistDataTimeout(mTestName) + "msec");
         }
         Log.i(TAG, "Received broadcast with all information.");
         return true;
@@ -163,7 +204,7 @@
                     isBundleNull? "":"not", mAssistBundle));
         }
 
-        if ((mScreenshot == null) != isScreenshotNull) {
+        if (mScreenshot == isScreenshotNull) {
             fail(String.format("Should %s have been null - Screenshot: %s",
                     isScreenshotNull? "":"not", mScreenshot));
         }
@@ -187,7 +228,7 @@
 
     protected void logContextAndScreenshotSetting() {
         Log.i(TAG, "Context is: " + Settings.Secure.getString(
-            mContext.getContentResolver(), "assist_structure_enabled"));
+                mContext.getContentResolver(), "assist_structure_enabled"));
         Log.i(TAG, "Screenshot is: " + Settings.Secure.getString(
                 mContext.getContentResolver(), "assist_screenshot_enabled"));
     }
@@ -260,7 +301,7 @@
         }
         numNodeChildren = parentNode.getChildCount();
 
-        if  (isSecureWindow) {
+        if (isSecureWindow) {
             assertEquals("Secure window should only traverse root node.", 0, numNodeChildren);
             isSecureWindow = false;
             return;
@@ -304,6 +345,11 @@
             assertNull("View Node should not have an ID.", parentNode.getIdEntry());
         }
 
+        Log.i(TAG, "parent text: " + parentNode.getText());
+        if (parentView instanceof TextView) {
+            Log.i(TAG, "view text: " + ((TextView) parentView).getText());
+        }
+
         assertEquals("Scroll X does not match.",
                 parentView.getScrollX(), parentNode.getScrollX());
 
@@ -336,17 +382,20 @@
                 AssistTestBase.this.mAssistContent = assistData.getParcelable(
                         Utils.ASSIST_CONTENT_KEY);
 
-                byte[] bitmapArray = assistData.getByteArray(Utils.ASSIST_SCREENSHOT_KEY);
-                if (bitmapArray != null) {
-                    AssistTestBase.this.mScreenshot = BitmapFactory.decodeByteArray(
-                            bitmapArray, 0, bitmapArray.length);
-                } else {
-                    AssistTestBase.this.mScreenshot = null;
-                }
+                AssistTestBase.this.mScreenshot =
+                        assistData.getBoolean(Utils.ASSIST_SCREENSHOT_KEY, false);
+
+                AssistTestBase.this.mScreenshotMatches = assistData.getBoolean(
+                        Utils.COMPARE_SCREENSHOT_KEY, false);
 
                 if (mLatch != null) {
+                    Log.i(AssistTestBase.TAG, "counting down latch. received assist data.");
                     mLatch.countDown();
                 }
+            } else if (intent.getAction().equals(Utils.SCREENSHOT_HASRESUMED)) {
+                if (mHasResumedLatch != null) {
+                    mHasResumedLatch.countDown();
+                }
             }
         }
     }
diff --git a/tests/tests/assist/src/android/assist/cts/DisableContextTest.java b/tests/tests/assist/src/android/assist/cts/DisableContextTest.java
index dc28879..5c8aa19 100644
--- a/tests/tests/assist/src/android/assist/cts/DisableContextTest.java
+++ b/tests/tests/assist/src/android/assist/cts/DisableContextTest.java
@@ -30,6 +30,7 @@
 import android.os.Bundle;
 import android.provider.Settings;
 import android.test.ActivityInstrumentationTestCase2;
+import android.util.Log;
 
 import java.lang.Override;
 import java.util.concurrent.CountDownLatch;
@@ -63,6 +64,7 @@
 
     public void testContextAndScreenshotOff() throws Exception {
         // Both settings off
+        Log.i(TAG, "DisableContext: Screenshot OFF, Context OFF");
         SystemUtil.runShellCommand(getInstrumentation(),
             "settings put secure assist_structure_enabled 0");
         SystemUtil.runShellCommand(getInstrumentation(),
@@ -74,6 +76,7 @@
         verifyAssistDataNullness(true, true, true, true);
 
         // Screenshot off, context on
+        Log.i(TAG, "DisableContext: Screenshot OFF, Context ON");
         SystemUtil.runShellCommand(getInstrumentation(),
             "settings put secure assist_structure_enabled 1");
         SystemUtil.runShellCommand(getInstrumentation(),
@@ -85,6 +88,7 @@
         verifyAssistDataNullness(false, false, false, true);
 
         // Context off, screenshot on
+        Log.i(TAG, "DisableContext: Screenshot ON, Context OFF");
         SystemUtil.runShellCommand(getInstrumentation(),
             "settings put secure assist_structure_enabled 0");
         SystemUtil.runShellCommand(getInstrumentation(),
@@ -95,4 +99,4 @@
 
         verifyAssistDataNullness(true, true, true, true);
     }
-}
\ No newline at end of file
+}
diff --git a/tests/tests/assist/src/android/assist/cts/LifecycleTest.java b/tests/tests/assist/src/android/assist/cts/LifecycleTest.java
index 7451017..cea685f 100644
--- a/tests/tests/assist/src/android/assist/cts/LifecycleTest.java
+++ b/tests/tests/assist/src/android/assist/cts/LifecycleTest.java
@@ -108,16 +108,18 @@
         @Override
         public void onReceive(Context context, Intent intent) {
             String action = intent.getAction();
-            if (action.equals(action_hasResumed)) {
-                mHasResumedLatch.countDown();
-            } else if (action.equals(action_onPause)) {
+            if (action.equals(action_hasResumed) && mHasResumedLatch != null) {
+                    mHasResumedLatch.countDown();
+            } else if (action.equals(action_onPause) && mActivityLifecycleLatch != null) {
                 mActivityLifecycleLatch.countDown();
-            } else if (action.equals(action_onStop)) {
+            } else if (action.equals(action_onStop) && mActivityLifecycleLatch != null) {
                 mActivityLifecycleLatch.countDown();
-            } else if (action.equals(action_onDestroy)) {
+            } else if (action.equals(action_onDestroy) && mActivityLifecycleLatch != null) {
                 mActivityLifecycleLatch.countDown();
             } else if (action.equals(Utils.ASSIST_RECEIVER_REGISTERED)) {
-                mAssistantReadyLatch.countDown();
+                if (mAssistantReadyLatch != null) {
+                    mAssistantReadyLatch.countDown();
+                }
             }
         }
     }
diff --git a/tests/tests/assist/src/android/assist/cts/ScreenshotTest.java b/tests/tests/assist/src/android/assist/cts/ScreenshotTest.java
new file mode 100644
index 0000000..a6a571e
--- /dev/null
+++ b/tests/tests/assist/src/android/assist/cts/ScreenshotTest.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2014 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 android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.database.DatabaseUtils;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.util.Log;
+
+import junit.framework.Test;
+
+import java.lang.Exception;
+import java.lang.Override;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+public class ScreenshotTest extends AssistTestBase {
+    static final String TAG = "ScreenshotTest";
+
+    private static final String TEST_CASE_TYPE = Utils.SCREENSHOT;
+
+    private BroadcastReceiver mScreenshotActivityReceiver;
+    private CountDownLatch mHasResumedLatch;
+
+    public ScreenshotTest() {
+        super();
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // set up receiver
+        mScreenshotActivityReceiver = new ScreenshotTestReceiver();
+        IntentFilter filter = new IntentFilter();
+        filter.addAction(Utils.ASSIST_RECEIVER_REGISTERED);
+        filter.addAction(Utils.SCREENSHOT_HASRESUMED);
+        mContext.registerReceiver(mScreenshotActivityReceiver, filter);
+
+        // start test start activity
+        startTestActivity(TEST_CASE_TYPE);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        if (mScreenshotActivityReceiver != null) {
+            mContext.unregisterReceiver(mScreenshotActivityReceiver);
+        }
+        super.tearDown();
+    }
+
+    public void testRedScreenshot() throws Exception {
+        Log.i(TAG, "Starting screenshot test");
+        mTestActivity.startTest(TEST_CASE_TYPE);
+        Log.i(TAG, "start waitForAssistantToBeReady()");
+        waitForAssistantToBeReady();
+
+        waitForActivityResumeAndAssist(Color.RED);
+        verifyAssistDataNullness(false, false, false, false);
+        assertTrue(mScreenshotMatches);
+    }
+
+    public void testGreenScreenshot() throws Exception {
+        Log.i(TAG, "Starting screenshot test");
+        mTestActivity.startTest(TEST_CASE_TYPE);
+        Log.i(TAG, "start waitForAssistantToBeReady()");
+        waitForAssistantToBeReady();
+
+        waitForActivityResumeAndAssist(Color.GREEN);
+        verifyAssistDataNullness(false, false, false, false);
+        assertTrue(mScreenshotMatches);
+    }
+
+    public void testBlueScreenshot() throws Exception {
+        Log.i(TAG, "Starting screenshot test");
+        mTestActivity.startTest(TEST_CASE_TYPE);
+        Log.i(TAG, "start waitForAssistantToBeReady()");
+        waitForAssistantToBeReady();
+
+        waitForActivityResumeAndAssist(Color.BLUE);
+        verifyAssistDataNullness(false, false, false, false);
+        assertTrue(mScreenshotMatches);
+    }
+
+    private void waitForActivityResumeAndAssist(int color) throws Exception {
+        mHasResumedLatch = new CountDownLatch(1);
+        Bundle extras = new Bundle();
+        extras.putInt(Utils.SCREENSHOT_COLOR_KEY, color);
+        startSession(TEST_CASE_TYPE, extras);
+        Log.i(TAG, "waiting for onResume() before continuing.");
+        if (!mHasResumedLatch.await(Utils.ACTIVITY_ONRESUME_TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
+            fail("activity failed to resume in " + Utils.ACTIVITY_ONRESUME_TIMEOUT_MS + "msec");
+        }
+        waitForContext();
+    }
+
+    private class ScreenshotTestReceiver extends BroadcastReceiver {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            String action = intent.getAction();
+            Log.i(ScreenshotTest.TAG, "Got some broadcast: " + action);
+            if (action.equals(Utils.ASSIST_RECEIVER_REGISTERED)) {
+                Log.i(ScreenshotTest.TAG, "Received assist receiver is registered.");
+                mAssistantReadyLatch.countDown();
+            } else if (action.equals(Utils.SCREENSHOT_HASRESUMED)) {
+                if (mHasResumedLatch != null) {
+                    mHasResumedLatch.countDown();
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/tests/tests/assist/src/android/assist/cts/TestStartActivity.java b/tests/tests/assist/src/android/assist/cts/TestStartActivity.java
index 16c924f..601b101 100644
--- a/tests/tests/assist/src/android/assist/cts/TestStartActivity.java
+++ b/tests/tests/assist/src/android/assist/cts/TestStartActivity.java
@@ -37,7 +37,15 @@
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         Log.i(TAG, " in onCreate");
-        setContentView(R.layout.test_app);
+
+        // Set the respective view we want compared with the test activity
+        String testCaseName = getIntent().getStringExtra(Utils.TESTCASE_TYPE);
+        switch (testCaseName) {
+            case Utils.ASSIST_STRUCTURE:
+                setContentView(R.layout.test_app);
+                setTitle(R.string.testAppTitle);
+                return;
+        }
     }
 
     @Override
@@ -63,6 +71,14 @@
         startActivity(intent);
     }
 
+    public void start3pAppWithColor(String testCaseName, int color) {
+        Intent intent = new Intent();
+        intent.setAction("android.intent.action.TEST_APP_" + testCaseName);
+        intent.putExtra(Utils.SCREENSHOT_COLOR_KEY, color);
+        intent.setComponent(Utils.getTestAppComponent(testCaseName));
+        startActivity(intent);
+    }
+
     @Override protected void onPause() {
         Log.i(TAG, " in onPause");
         super.onPause();
diff --git a/tests/tests/assist/testapp/AndroidManifest.xml b/tests/tests/assist/testapp/AndroidManifest.xml
index f14cf22..168a0ae 100644
--- a/tests/tests/assist/testapp/AndroidManifest.xml
+++ b/tests/tests/assist/testapp/AndroidManifest.xml
@@ -22,7 +22,7 @@
         <uses-library android:name="android.test.runner" />
 
         <activity android:name="TestApp"
-                android:label="Assist Structure Test App"
+                android:label="Assist Structure Test Activity"
                 android:theme="@android:style/Theme.Material.Light">
           <intent-filter>
               <action android:name="android.intent.action.TEST_APP_ASSIST_STRUCTURE" />
@@ -53,6 +53,15 @@
             <intent-filter>
                 <action android:name="android.intent.action.TEST_APP_LIFECYCLE" />
                 <category android:name="android.intent.category.DEFAULT" />
+                <category android:name="android.intent.category.VOICE" />
+            </intent-filter>
+        </activity>
+        <activity android:name="ScreenshotActivity"
+                  android:label="Screenshot Test Activity">
+            <intent-filter>
+                <action android:name="android.intent.action.TEST_APP_SCREENSHOT" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <category android:name="android.intent.category.VOICE" />
             </intent-filter>
         </activity>
     </application>
diff --git a/tests/tests/assist/testapp/res/layout/screenshot_activity.xml b/tests/tests/assist/testapp/res/layout/screenshot_activity.xml
new file mode 100644
index 0000000..05051dc
--- /dev/null
+++ b/tests/tests/assist/testapp/res/layout/screenshot_activity.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<RelativeLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/screenshot_activity"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+</RelativeLayout>
\ No newline at end of file
diff --git a/tests/tests/assist/testapp/src/android/voiceinteraction/testapp/DisableContextActivity.java b/tests/tests/assist/testapp/src/android/voiceinteraction/testapp/DisableContextActivity.java
deleted file mode 100644
index ae570d8..0000000
--- a/tests/tests/assist/testapp/src/android/voiceinteraction/testapp/DisableContextActivity.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.content.Intent;
-import android.os.Bundle;
-import android.util.Log;
-
-public class DisableContextActivity extends Activity {
-    static final String TAG = "TestApp";
-
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        Log.i(TAG, "TestApp created");
-        setContentView(R.layout.test_app);
-    }
-
-    @Override
-    public void onResume() {
-        super.onResume();
-    }
-}
\ No newline at end of file
diff --git a/tests/tests/assist/testapp/src/android/voiceinteraction/testapp/ScreenshotActivity.java b/tests/tests/assist/testapp/src/android/voiceinteraction/testapp/ScreenshotActivity.java
new file mode 100644
index 0000000..2d0d849
--- /dev/null
+++ b/tests/tests/assist/testapp/src/android/voiceinteraction/testapp/ScreenshotActivity.java
@@ -0,0 +1,63 @@
+/*
+ * 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.assist.common.Utils;
+
+import android.app.Activity;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+
+import java.lang.Override;
+
+public class ScreenshotActivity extends Activity {
+    static final String TAG = "ScreenshotActivity";
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        Log.i(TAG, "ScreenshotActivity created");
+        setContentView(R.layout.screenshot_activity);
+    }
+
+    @Override
+    public void onResume() {
+        Log.i(TAG, " in onResume");
+        super.onResume();
+        int backgroundColor = getIntent().getIntExtra(Utils.SCREENSHOT_COLOR_KEY, Color.WHITE);
+        View view = findViewById(R.id.screenshot_activity);
+        view.setBackgroundColor(backgroundColor);
+        view.requestLayout();
+
+        // Tell service activity is in foreground.
+        Intent intent = new Intent(Utils.SCREENSHOT_HASRESUMED);
+        sendBroadcast(intent);
+        Log.i(TAG, "Resumed broadcast sent.");
+    }
+
+    @Override
+    public void onPause() {
+        Log.i(TAG, "onPause");
+        finish();
+        super.onPause();
+    }
+}
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 ff56ea8..79bd811c 100644
--- a/tests/tests/assist/testapp/src/android/voiceinteraction/testapp/TestApp.java
+++ b/tests/tests/assist/testapp/src/android/voiceinteraction/testapp/TestApp.java
@@ -20,6 +20,16 @@
 
 import android.app.Activity;
 import android.content.Intent;
+import android.graphics.Bitmap;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.view.View.MeasureSpec;
+import android.view.ViewGroup;
+import android.view.ViewTreeObserver;
+import android.view.ViewTreeObserver.OnGlobalLayoutListener;
+
+import java.io.ByteArrayOutputStream;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.View;
@@ -31,7 +41,6 @@
 public class TestApp extends Activity {
     static final String TAG = "TestApp";
 
-
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
diff --git a/tools/utils/buildCts.py b/tools/utils/buildCts.py
index 375b1a0..b6f5812 100755
--- a/tools/utils/buildCts.py
+++ b/tools/utils/buildCts.py
@@ -470,6 +470,9 @@
           'android.alarmclock.cts.SetAlarmTest#testAll',
           'android.alarmclock.cts.SnoozeAlarmTest#testAll',
       ],
+      'android.assist' : [
+          'android.assist.cts.ScreenshotTest',
+      ],
       'android.calllog' : [
           'android.calllog.cts.CallLogBackupTest#testSingleCallBackup',
       ],