Merge "Apply module ID formatting from go/aog/379797 to summary" into nougat-cts-dev
diff --git a/common/util/src/com/android/compatibility/common/util/ResultHandler.java b/common/util/src/com/android/compatibility/common/util/ResultHandler.java
index 64798e8..67f2298 100644
--- a/common/util/src/com/android/compatibility/common/util/ResultHandler.java
+++ b/common/util/src/com/android/compatibility/common/util/ResultHandler.java
@@ -223,7 +223,7 @@
                         String resultStatus = parser.getAttributeValue(NS, RESULT_ATTR);
                         test.setResultStatus(TestStatus.getStatus(resultStatus));
                         test.setRetry(true);
-                        if (parser.nextTag() == XmlPullParser.START_TAG) {
+                        while (parser.nextTag() == XmlPullParser.START_TAG) {
                             if (parser.getName().equals(FAILURE_TAG)) {
                                 test.setMessage(parser.getAttributeValue(NS, MESSAGE_ATTR));
                                 if (parser.nextTag() == XmlPullParser.START_TAG) {
@@ -233,19 +233,17 @@
                                     parser.nextTag();
                                 }
                                 parser.require(XmlPullParser.END_TAG, NS, FAILURE_TAG);
-                                parser.nextTag();
                             } else if (parser.getName().equals(BUGREPORT_TAG)) {
                                 test.setBugReport(parser.nextText());
-                                parser.nextTag();
+                                parser.require(XmlPullParser.END_TAG, NS, BUGREPORT_TAG);
                             } else if (parser.getName().equals(LOGCAT_TAG)) {
                                 test.setLog(parser.nextText());
-                                parser.nextTag();
+                                parser.require(XmlPullParser.END_TAG, NS, LOGCAT_TAG);
                             } else if (parser.getName().equals(SCREENSHOT_TAG)) {
                                 test.setScreenshot(parser.nextText());
-                                parser.nextTag();
+                                parser.require(XmlPullParser.END_TAG, NS, SCREENSHOT_TAG);
                             } else {
                                 test.setReportLog(ReportLog.parse(parser));
-                                parser.nextTag();
                             }
                         }
                         parser.require(XmlPullParser.END_TAG, NS, TEST_TAG);
diff --git a/common/util/tests/src/com/android/compatibility/common/util/ResultHandlerTest.java b/common/util/tests/src/com/android/compatibility/common/util/ResultHandlerTest.java
index 74784bc..3f50990 100644
--- a/common/util/tests/src/com/android/compatibility/common/util/ResultHandlerTest.java
+++ b/common/util/tests/src/com/android/compatibility/common/util/ResultHandlerTest.java
@@ -74,6 +74,9 @@
     private static final String MESSAGE = "Something small is not alright";
     private static final String STACK_TRACE = "Something small is not alright\n " +
             "at four.big.insects.Marley.sing(Marley.java:10)";
+    private static final String BUG_REPORT = "https://cnsviewer.corp.google.com/cns/bugreport.txt";
+    private static final String LOGCAT = "https://cnsviewer.corp.google.com/cns/logcat.gz";
+    private static final String SCREENSHOT = "https://cnsviewer.corp.google.com/screenshot.png";
     private static final long START_MS = 1431586801000L;
     private static final long END_MS = 1431673199000L;
     private static final String START_DISPLAY = "Fri Aug 20 15:13:03 PDT 2010";
@@ -118,6 +121,9 @@
             "        <Failure message=\"%s\">\n" +
             "          <StackTrace>%s</StackTrace>\n" +
             "        </Failure>\n" +
+            "        <BugReport>%s</BugReport>\n" +
+            "        <Logcat>%s</Logcat>\n" +
+            "        <Screenshot>%s</Screenshot>\n" +
             "      </Test>\n";
     private static final String XML_TEST_RESULT =
             "      <Test result=\"pass\" name=\"%s\">\n" +
@@ -168,6 +174,9 @@
         moduleBTest3.setResultStatus(TestStatus.FAIL);
         moduleBTest3.setMessage(MESSAGE);
         moduleBTest3.setStackTrace(STACK_TRACE);
+        moduleBTest3.setBugReport(BUG_REPORT);
+        moduleBTest3.setLog(LOGCAT);
+        moduleBTest3.setScreenshot(SCREENSHOT);
         ITestResult moduleBTest4 = moduleBCase.getOrCreateResult(METHOD_4);
         moduleBTest4.setResultStatus(TestStatus.PASS);
         ReportLog report = new ReportLog();
@@ -219,7 +228,8 @@
             String moduleACases = String.format(XML_CASE, CLASS_A, moduleATest);
             String moduleA = String.format(XML_MODULE, NAME_A, ABI, DEVICE_A, RUNTIME_A, DONE_A,
                     moduleACases);
-            String moduleBTest3 = String.format(XML_TEST_FAIL, METHOD_3, MESSAGE, STACK_TRACE);
+            String moduleBTest3 = String.format(XML_TEST_FAIL, METHOD_3, MESSAGE, STACK_TRACE,
+                    BUG_REPORT, LOGCAT, SCREENSHOT);
             String moduleBTest4 = String.format(XML_TEST_RESULT, METHOD_4,
                     SUMMARY_SOURCE, SUMMARY_MESSAGE, ResultType.HIGHER_BETTER.toReportString(),
                     ResultUnit.SCORE.toReportString(), Double.toString(SUMMARY_VALUE),
@@ -329,9 +339,9 @@
         ITestResult moduleBTest3 = moduleBResults.get(0);
         assertEquals("Incorrect name", METHOD_3, moduleBTest3.getName());
         assertEquals("Incorrect result", TestStatus.FAIL, moduleBTest3.getResultStatus());
-        assertNull("Unexpected bugreport", moduleBTest3.getBugReport());
-        assertNull("Unexpected log", moduleBTest3.getLog());
-        assertNull("Unexpected screenshot", moduleBTest3.getScreenshot());
+        assertEquals("Incorrect bugreport", BUG_REPORT, moduleBTest3.getBugReport());
+        assertEquals("Incorrect log", LOGCAT, moduleBTest3.getLog());
+        assertEquals("Incorrect screenshot", SCREENSHOT, moduleBTest3.getScreenshot());
         assertEquals("Incorrect message", MESSAGE, moduleBTest3.getMessage());
         assertEquals("Incorrect stack trace", STACK_TRACE, moduleBTest3.getStackTrace());
         assertNull("Unexpected report", moduleBTest3.getReportLog());
diff --git a/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java b/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java
index 50eb7c8..329f4a2 100644
--- a/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java
+++ b/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java
@@ -399,7 +399,7 @@
                 .createDeviceProtectedStorageContext();
         final File probe = new File(otherContext.getFilesDir(),
                 getBootCount() + "." + action);
-        for (int i = 0; i < 60; i++) {
+        for (int i = 0; i < 150; i++) {
             Log.d(TAG, "Waiting for " + probe + "...");
             if (probe.exists()) {
                 return;
diff --git a/tests/tests/security/res/raw/cve_2015_3871.mp4 b/tests/tests/security/res/raw/cve_2015_3871.mp4
new file mode 100644
index 0000000..d35674c
--- /dev/null
+++ b/tests/tests/security/res/raw/cve_2015_3871.mp4
Binary files differ
diff --git a/tests/tests/security/res/raw/cve_2015_6600.mp4 b/tests/tests/security/res/raw/cve_2015_6600.mp4
new file mode 100644
index 0000000..0b9b03c
--- /dev/null
+++ b/tests/tests/security/res/raw/cve_2015_6600.mp4
Binary files differ
diff --git a/tests/tests/security/res/raw/cve_2015_6603.mp4 b/tests/tests/security/res/raw/cve_2015_6603.mp4
new file mode 100644
index 0000000..d6a4061
--- /dev/null
+++ b/tests/tests/security/res/raw/cve_2015_6603.mp4
Binary files differ
diff --git a/tests/tests/security/res/raw/cve_2015_6604.mp3 b/tests/tests/security/res/raw/cve_2015_6604.mp3
new file mode 100644
index 0000000..930f201
--- /dev/null
+++ b/tests/tests/security/res/raw/cve_2015_6604.mp3
Binary files differ
diff --git a/tests/tests/security/res/raw/cve_2015_6608_b_23680780.mp4 b/tests/tests/security/res/raw/cve_2015_6608_b_23680780.mp4
new file mode 100644
index 0000000..6d41ebc
--- /dev/null
+++ b/tests/tests/security/res/raw/cve_2015_6608_b_23680780.mp4
Binary files differ
diff --git a/tests/tests/security/res/raw/cve_2016_2507.mp4 b/tests/tests/security/res/raw/cve_2016_2507.mp4
new file mode 100644
index 0000000..ca248e1
--- /dev/null
+++ b/tests/tests/security/res/raw/cve_2016_2507.mp4
Binary files differ
diff --git a/tests/tests/security/src/android/security/cts/StagefrightTest.java b/tests/tests/security/src/android/security/cts/StagefrightTest.java
index 640c0c5..ed28598 100644
--- a/tests/tests/security/src/android/security/cts/StagefrightTest.java
+++ b/tests/tests/security/src/android/security/cts/StagefrightTest.java
@@ -72,6 +72,10 @@
         doStagefrightTest(R.raw.bug_33137046);
     }
 
+    public void testStagefright_cve_2016_2507() throws Exception {
+        doStagefrightTest(R.raw.cve_2016_2507);
+    }
+
     public void testStagefright_bug_31647370() throws Exception {
         doStagefrightTest(R.raw.bug_31647370);
     }
@@ -144,18 +148,15 @@
         doStagefrightTest(R.raw.bug_26366256);
     }
 
+    /***********************************************************
+     to prevent merge conflicts, add M tests below this comment,
+     before any existing test methods
+     ***********************************************************/
+
     public void testStagefright_bug_25765591() throws Exception {
         doStagefrightTest(R.raw.bug_25765591);
     }
 
-    public void testStagefright_bug_25812590() throws Exception {
-        doStagefrightTest(R.raw.bug_25812590);
-    }
-
-    public void testStagefright_bug_26070014() throws Exception {
-        doStagefrightTest(R.raw.bug_26070014);
-    }
-
     public void testStagefright_cve_2015_3867() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3867);
     }
@@ -188,10 +189,38 @@
         doStagefrightTest(R.raw.cve_2015_3873_b_21814993);
     }
 
+    public void testStagefright_bug_25812590() throws Exception {
+        doStagefrightTest(R.raw.bug_25812590);
+    }
+
+    public void testStagefright_cve_2015_6600() throws Exception {
+        doStagefrightTest(R.raw.cve_2015_6600);
+    }
+
+    public void testStagefright_cve_2015_6603() throws Exception {
+        doStagefrightTest(R.raw.cve_2015_6603);
+    }
+
+    public void testStagefright_cve_2015_6604() throws Exception {
+        doStagefrightTest(R.raw.cve_2015_6604);
+    }
+
+    public void testStagefright_cve_2015_3871() throws Exception {
+        doStagefrightTest(R.raw.cve_2015_3871);
+    }
+
+    public void testStagefright_bug_26070014() throws Exception {
+        doStagefrightTest(R.raw.bug_26070014);
+    }
+
     public void testStagefright_bug_32915871() throws Exception {
         doStagefrightTest(R.raw.bug_32915871);
     }
 
+    public void testStagefright_cve_2015_6608_b_23680780() throws Exception {
+        doStagefrightTest(R.raw.cve_2015_6608_b_23680780);
+    }
+
     public void testStagefright_bug_28333006() throws Exception {
         doStagefrightTest(R.raw.bug_28333006);
     }