Merge "CtsVerifier: Add new stage for ACTION_IMAGE_CAPTURE_SECURE" am: 98279b8aba am: 7f7bac62f5 am: c69ca3ecc3

Change-Id: Ic46680224ce10af7690d0579ee8076fb5eea7c7a
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 24ec5b2..672ffc1 100755
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -1363,6 +1363,13 @@
     4. Pass button will light up if intent and URI trigger were NOT received.\n
     5. Click "Pass" if possible, otherwise open settings app, allow location again and click "Fail".
     </string>
+    <string name="ci_instruction_text_intent_picture_secure_label">\n
+    1. Click Start Test.\n
+    2. Camera app will launch, prompting to take photo.\n
+    3. Capture/confirm photo using camera app controls within 1 minute.\n
+    4. Pass button will light up if intent and URI trigger were NOT received.\n
+    5. Click "Pass" if possible, otherwise open settings app, allow location again and click "Fail".
+    </string>
     <string name="ci_instruction_text_intent_video_label">\n
     1. Click Start Test.\n
     2. Camera app will launch, prompting to take video.\n
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/intents/CameraIntentsActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/intents/CameraIntentsActivity.java
index b7a80de..72499e0 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/intents/CameraIntentsActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/camera/intents/CameraIntentsActivity.java
@@ -91,14 +91,16 @@
     private static final int STAGE_APP_PICTURE = 0;
     private static final int STAGE_APP_VIDEO = 1;
     private static final int STAGE_INTENT_PICTURE = 2;
-    private static final int STAGE_INTENT_VIDEO = 3;
-    private static final int NUM_STAGES = 4;
+    private static final int STAGE_INTENT_PICTURE_SECURE = 3;
+    private static final int STAGE_INTENT_VIDEO = 4;
+    private static final int NUM_STAGES = 5;
     private static final String STAGE_INDEX_EXTRA = "stageIndex";
 
     private static String[]  EXPECTED_INTENTS = new String[] {
         Camera.ACTION_NEW_PICTURE,
         Camera.ACTION_NEW_VIDEO,
         null,
+        null,
         Camera.ACTION_NEW_VIDEO
     };
 
@@ -136,6 +138,7 @@
         JOB_TYPE_IMAGE,
         JOB_TYPE_VIDEO,
         JOB_TYPE_IMAGE,
+        JOB_TYPE_IMAGE,
         JOB_TYPE_VIDEO
     };
 
@@ -230,6 +233,9 @@
         if (stageIndex == STAGE_INTENT_PICTURE) {
             return "Intent Picture";
         }
+        if (stageIndex == STAGE_INTENT_PICTURE_SECURE) {
+            return "Intent Picture Secure";
+        }
         if (stageIndex == STAGE_INTENT_VIDEO) {
             return "Intent Video";
         }
@@ -248,6 +254,9 @@
         if (stageIndex == STAGE_INTENT_PICTURE) {
             return android.hardware.Camera.ACTION_NEW_PICTURE;
         }
+        if (stageIndex == STAGE_INTENT_PICTURE_SECURE) {
+            return android.hardware.Camera.ACTION_NEW_PICTURE + " (Secure)";
+        }
         if (stageIndex == STAGE_INTENT_VIDEO) {
             return android.hardware.Camera.ACTION_NEW_VIDEO;
         }
@@ -266,6 +275,9 @@
         if (stageIndex == STAGE_INTENT_PICTURE) {
             return getString(R.string.ci_instruction_text_intent_picture_label);
         }
+        if (stageIndex == STAGE_INTENT_PICTURE_SECURE) {
+            return getString(R.string.ci_instruction_text_intent_picture_secure_label);
+        }
         if (stageIndex == STAGE_INTENT_VIDEO) {
             return getString(R.string.ci_instruction_text_intent_video_label);
         }
@@ -405,6 +417,7 @@
         the intents by taking a photo/video
         */
         if (getStageIndex() == STAGE_INTENT_PICTURE ||
+            getStageIndex() == STAGE_INTENT_PICTURE_SECURE ||
             getStageIndex() == STAGE_INTENT_VIDEO) {
 
             if (mActivityResult && mState == STATE_STARTED) {
@@ -426,6 +439,7 @@
                 if (mState != STATE_FAILED) {
                     switch (stageIndex) {
                         case STAGE_INTENT_PICTURE:
+                        case STAGE_INTENT_PICTURE_SECURE:
                             handleIntentPictureResult();
                             break;
                         case STAGE_INTENT_VIDEO:
@@ -532,8 +546,9 @@
 
                         // For STAGE_INTENT_PICTURE test, if EXTRA_OUTPUT is not assigned in intent,
                         // file should NOT be saved so triggering this is a test failure.
-                        if (getStageIndex() == STAGE_INTENT_PICTURE) {
-                            Log.e(TAG, "FAIL: STAGE_INTENT_PICTURE test should not create file");
+                        if (getStageIndex() == STAGE_INTENT_PICTURE ||
+                            getStageIndex() == STAGE_INTENT_PICTURE_SECURE) {
+                            Log.e(TAG, "FAIL: STAGE_INTENT_PICTURE or STAGE_INTENT_PICTURE_SECURE test should not create file");
                             mState = STATE_FAILED;
                         }
 
@@ -548,8 +563,9 @@
                 e.printStackTrace();
             }
 
-            if (getStageIndex() == STAGE_INTENT_PICTURE) {
-                // STAGE_INTENT_PICTURE should timeout
+            if (getStageIndex() == STAGE_INTENT_PICTURE ||
+                getStageIndex() == STAGE_INTENT_PICTURE_SECURE) {
+                // STAGE_INTENT_PICTURE or STAGE_INTENT_PICTURE_SECURE should timeout
                 return true;
             } else {
                 Log.e(TAG, "FAIL: timeout waiting for URI trigger");
@@ -594,7 +610,9 @@
              * Video intents do not need to wait on a ContentProvider broadcast since we're starting
              * the intent activity with EXTRA_OUTPUT set
              */
-            if (stageIndex != STAGE_INTENT_VIDEO && stageIndex != STAGE_INTENT_PICTURE) {
+            if (stageIndex != STAGE_INTENT_VIDEO &&
+                stageIndex != STAGE_INTENT_PICTURE &&
+                stageIndex != STAGE_INTENT_PICTURE_SECURE) {
                 JobInfo job = makeJobInfo(TEST_JOB_TYPES[stageIndex]);
                 jobScheduler.schedule(job);
                 new WaitForTriggerTask().execute();
@@ -614,6 +632,9 @@
             if (stageIndex == STAGE_INTENT_PICTURE) {
                 intentStr = android.provider.MediaStore.ACTION_IMAGE_CAPTURE;
             }
+            else if (stageIndex == STAGE_INTENT_PICTURE_SECURE) {
+                intentStr = android.provider.MediaStore.ACTION_IMAGE_CAPTURE_SECURE;
+            }
             else if (stageIndex == STAGE_INTENT_VIDEO) {
                 intentStr = android.provider.MediaStore.ACTION_VIDEO_CAPTURE;
             }
@@ -633,6 +654,7 @@
                 String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
                 switch (stageIndex) {
                     case STAGE_INTENT_PICTURE:
+                    case STAGE_INTENT_PICTURE_SECURE:
                         mImageTarget = new File(mDebugFolder, timeStamp + "capture.jpg");
                         targetFile = mImageTarget;
                         break;