STS test for Android Security CVE-2021-0636

Test: sts-tradefed run sts-engbuild-no-spl-lock -m CtsSecurityBulletinHostTestCases -t android.security.cts.CVE_2021_0636
Bug: 193153501
Bug: 189392423
Change-Id: I95b8858a662b8d364bb59d6bb85f03f0e6118d96
diff --git a/hostsidetests/securitybulletin/res/cve_2021_0636_1.avi b/hostsidetests/securitybulletin/res/cve_2021_0636_1.avi
new file mode 100644
index 0000000..18edf22
--- /dev/null
+++ b/hostsidetests/securitybulletin/res/cve_2021_0636_1.avi
Binary files differ
diff --git a/hostsidetests/securitybulletin/res/cve_2021_0636_2.avi b/hostsidetests/securitybulletin/res/cve_2021_0636_2.avi
new file mode 100644
index 0000000..12c77ef
--- /dev/null
+++ b/hostsidetests/securitybulletin/res/cve_2021_0636_2.avi
Binary files differ
diff --git a/hostsidetests/securitybulletin/res/cve_2021_0636_3.avi b/hostsidetests/securitybulletin/res/cve_2021_0636_3.avi
new file mode 100644
index 0000000..bc685eb
--- /dev/null
+++ b/hostsidetests/securitybulletin/res/cve_2021_0636_3.avi
Binary files differ
diff --git a/hostsidetests/securitybulletin/res/cve_2021_0636_4.avi b/hostsidetests/securitybulletin/res/cve_2021_0636_4.avi
new file mode 100644
index 0000000..9491607
--- /dev/null
+++ b/hostsidetests/securitybulletin/res/cve_2021_0636_4.avi
Binary files differ
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2021_0636.java b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2021_0636.java
new file mode 100644
index 0000000..d4bbfb3
--- /dev/null
+++ b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2021_0636.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2021 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.security.cts;
+
+import android.platform.test.annotations.AsbSecurityTest;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
+public class CVE_2021_0636 extends SecurityTestCase {
+
+    public void testPocCVE_2021_0636(String mediaFileName) throws Exception {
+        /*
+         * Non StageFright test.
+         */
+        AdbUtils.pushResource(
+                "/" + mediaFileName, "/sdcard/" + mediaFileName, getDevice());
+        AdbUtils.runCommandLine("logcat -c", getDevice());
+        AdbUtils.runCommandLine(
+                "am start -a android.intent.action.VIEW -t video/avi -d file:///sdcard/"
+                    + mediaFileName, getDevice());
+        Thread.sleep(4000); // Delay to run the media file and capture output in logcat
+        AdbUtils.runCommandLine("rm -rf /sdcard/" + mediaFileName, getDevice());
+        AdbUtils.assertNoCrashes(getDevice(), "mediaserver");
+    }
+
+    @Test
+    @AsbSecurityTest(cveBugId = 189392423)
+    public void testPocCVE_2021_0636() throws Exception {
+        testPocCVE_2021_0636("cve_2021_0636_1.avi");
+        testPocCVE_2021_0636("cve_2021_0636_2.avi");
+        testPocCVE_2021_0636("cve_2021_0636_3.avi");
+        testPocCVE_2021_0636("cve_2021_0636_4.avi");
+    }
+}