Merge "VTS treble test for vendor manifest."
diff --git a/treble/__init__.py b/treble/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/treble/__init__.py
diff --git a/treble/platform_version/Android.mk b/treble/platform_version/Android.mk
new file mode 100644
index 0000000..7d1e096
--- /dev/null
+++ b/treble/platform_version/Android.mk
@@ -0,0 +1,25 @@
+#
+# 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 $(call all-subdir-makefiles)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := VtsTreblePlatformVersionTest
+VTS_CONFIG_SRC_DIR := testcases/hal/treble/platform_version
+include test/vts/tools/build/Android.host_config.mk
diff --git a/treble/platform_version/AndroidTest.xml b/treble/platform_version/AndroidTest.xml
new file mode 100644
index 0000000..2779d6a
--- /dev/null
+++ b/treble/platform_version/AndroidTest.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<configuration description="Config for VTS VtsTreblePlatformVersionTest test cases">
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
+        <option name="push-group" value="HostDrivenTest.push" />
+    </target_preparer>
+    <target_preparer class="com.android.tradefed.targetprep.VtsPythonVirtualenvPreparer">
+    </target_preparer>
+    <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
+        <option name="test-module-name" value="VtsTreblePlatformVersionTest" />
+        <option name="test-case-path" value="vts/testcases/hal/treble/platform_version/VtsTreblePlatformVersionTest" />
+    </test>
+</configuration>
diff --git a/treble/platform_version/VtsTreblePlatformVersionTest.py b/treble/platform_version/VtsTreblePlatformVersionTest.py
new file mode 100644
index 0000000..4441897
--- /dev/null
+++ b/treble/platform_version/VtsTreblePlatformVersionTest.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python3.4
+#
+# 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.
+#
+
+import logging
+
+from vts.runners.host import asserts
+from vts.runners.host import base_test
+from vts.runners.host import const
+from vts.runners.host import test_runner
+from vts.utils.python.controllers import android_device
+
+ANDROID_O_API_VERSION = 26
+
+class VtsTreblePlatformVersionTest(base_test.BaseTestClass):
+    """VTS should run on devices launched with O or later."""
+
+    def setUpClass(self):
+        self.dut = self.registerController(android_device)[0]
+        self.dut.shell.InvokeTerminal("VtsTreblePlatformVersionTest")
+
+    def testPlatformVersion(self):
+        """Test that device launched with O or later."""
+
+        results = self.dut.shell.VtsTreblePlatformVersionTest.Execute(
+            "getprop ro.product.first_api_level")
+        asserts.assertEqual(results[const.EXIT_CODE][0], 0,
+            "getprop must succeed")
+
+        try:
+            firstApiLevel = int(results[const.STDOUT][0].strip())
+            logging.info("Device first API level is {}".format(firstApiLevel))
+            asserts.assertTrue(firstApiLevel >= ANDROID_O_API_VERSION,
+                "VTS can only be run for new launches in O or above")
+        except ValueError:
+            asserts.fail("Unexpected value returned from getprop")
+
+if __name__ == "__main__":
+    test_runner.main()
diff --git a/treble/platform_version/__init__.py b/treble/platform_version/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/treble/platform_version/__init__.py