Snap for 4373604 from fdd085a469cd71ac84924de4e1e6247fc6011f9f to oc-mr1-release

Change-Id: Ieca12d3e7df43fcf64038427e2b414d82c2fe1f8
diff --git a/manifests/install/AndroidManifest.xml b/manifests/install/AndroidManifest.xml
deleted file mode 100644
index 45a8003..0000000
--- a/manifests/install/AndroidManifest.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?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.
- -->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-          package="com.android.timezone.data.placeholder_for_aapt_override">
-
-    <application
-        android:allowBackup="false"
-        android:label="@string/app_name">
-
-        <provider
-                android:name="com.android.timezone.data.TimeZoneRulesDataProvider"
-                android:authorities="com.android.timezone"
-                android:grantUriPermissions="true"
-                android:readPermission="android.permission.UPDATE_TIME_ZONE_RULES"
-                android:exported="true">
-            <meta-data android:name="android.timezoneprovider.OPERATION"
-                     android:value="INSTALL"/>
-        </provider>
-    </application>
-</manifest>
diff --git a/manifests/uninstall/AndroidManifest.xml b/manifests/uninstall/AndroidManifest.xml
deleted file mode 100644
index 598a2be..0000000
--- a/manifests/uninstall/AndroidManifest.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?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.
- -->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-          package="com.android.timezone.data.placeholder_for_aapt_override">
-
-    <application
-        android:allowBackup="false"
-        android:label="@string/app_name">
-
-        <provider
-                android:name="com.android.timezone.data.TimeZoneRulesDataProvider"
-                android:authorities="com.android.timezone"
-                android:grantUriPermissions="true"
-                android:readPermission="android.permission.UPDATE_TIME_ZONE_RULES"
-                android:exported="true">
-            <meta-data android:name="android.timezoneprovider.OPERATION"
-                     android:value="UNINSTALL"/>
-        </provider>
-    </application>
-</manifest>
diff --git a/oem_template/data_app/AndroidManifest.xml b/oem_template/data_app/AndroidManifest.xml
new file mode 100644
index 0000000..1f4046c
--- /dev/null
+++ b/oem_template/data_app/AndroidManifest.xml
@@ -0,0 +1,62 @@
+<?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.
+ -->
+<!-- OEM-INSTRUCTION: Change the package attribute to something OEM-specific. -->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+          package="CHANGE">
+
+    <!--
+      OEM-INSTRUCTION: Change these to match the platform release the app is
+      for and update for every platform release to ensure the app is only
+      installed on the release it is targeted for. Typically, all values should
+      be the same unless two Android releases use the same distro format
+      version.
+
+      Your app version code strategy and the version of the app included in the
+      system image should be chosen to prevent older versions of the app being
+      installed on newer Android devices.
+      minSdkVersion will prevent newer versions of the app being installed on
+      older devices.
+      maxSdkVersion is not used by the device, but can be used by app stores to
+      prevent the app being shown to users of newer devices.
+      -->
+    <uses-sdk android:minSdkVersion="CHANGE"
+              android:targetSdkVersion="CHANGE"
+              android:maxSdkVersion="CHANGE" />
+
+    <!--
+      OEM-INSTRUCTION: Optionally restrict the app to an OEM-specific feature,
+      or remove the element entirely.
+      -->
+    <uses-feature
+            android:name="CHANGE"
+            android:required="true"/>
+
+    <application
+        android:allowBackup="false"
+        android:label="@string/app_name">
+
+        <provider
+                android:name="com.android.timezone.data.TimeZoneRulesDataProvider"
+                android:authorities="com.android.timezone"
+                android:grantUriPermissions="true"
+                android:readPermission="android.permission.UPDATE_TIME_ZONE_RULES"
+                android:exported="true">
+            <meta-data android:name="android.timezoneprovider.OPERATION"
+                     android:value="INSTALL"/>
+        </provider>
+    </application>
+</manifest>
diff --git a/oem_template/data_app/README.oem b/oem_template/data_app/README.oem
index e3dbe37..f288adf 100644
--- a/oem_template/data_app/README.oem
+++ b/oem_template/data_app/README.oem
@@ -5,10 +5,24 @@
 This directory contains a suggested structure for building an OEM version of Time Zone Data app
 (real and test versions).
 
-e.g. You can copy it
+For example, you can copy it
 
-cp -r data_app ${ANDROID_BUILD_TOP}/vendor/oemcorp/apps/TimeZoneDataOemCorp
+cp -r data_app ${ANDROID_BUILD_TOP}/vendor/oemcorp/apps/TimeZoneData
 
 Where <oemcorp> is your company name.
 
-...then read / change all the things marked with OEM-INSTRUCTION.
\ No newline at end of file
+...then read / change all the things marked with OEM-INSTRUCTION.
+
+The intended use is for inclusion in a tapas build to generate .apks. The targets define the
+real version of the app, and some test versions that can be used by the supplied xTS tests.
+
+The generated .apks are expected to be signed and checked in as "prebuilts" for the system
+image and for xTS testing.
+
+The main, signed .apk can also be uploaded to an app store and used to update existing
+devices.
+
+See oem_template/data_app_prebuilts for rules that can be used to include the prebuilts in
+the system image and tests.
+
+See oem_template/xts for rules that can be used for xTS testing.
diff --git a/oem_template/data_app/build_oem_data_app.mk b/oem_template/data_app/build_oem_data_app.mk
index 7d9e611..f31e5d1 100644
--- a/oem_template/data_app/build_oem_data_app.mk
+++ b/oem_template/data_app/build_oem_data_app.mk
@@ -32,16 +32,15 @@
 # All resources come from the vendor-specific dirs.
 LOCAL_RESOURCE_DIR := $(OEM_APP_PATH)/res
 
-LOCAL_FULL_MANIFEST_FILE := packages/apps/TimeZoneData/manifests/install/AndroidManifest.xml
+# Ensure the app can be unbundled by only depending on System APIs.
+LOCAL_SDK_VERSION := system_current
+
+LOCAL_FULL_MANIFEST_FILE := $(OEM_APP_PATH)/AndroidManifest.xml
 
 LOCAL_PACKAGE_NAME := TimeZoneData$(TIME_ZONE_DATA_APP_SUFFIX)
 
 LOCAL_AAPT_FLAGS := --version-code $(TIME_ZONE_DATA_APP_VERSION_CODE) \
-                    --version-name $(TIME_ZONE_DATA_APP_VERSION_NAME) \
-                    --min-sdk-version $(PLATFORM_SDK_VERSION)
-
-# OEM-INSTRUCTION: Modify the name, s/oemcorp/<Your company name>/
-LOCAL_AAPT_FLAGS += --rename-manifest-package com.oemcorp.android.timezone.data
+                    --version-name $(TIME_ZONE_DATA_APP_VERSION_NAME)
 
 # OEM-INSTRUCTION: Modify the name, s/oemcorp/<Your company name>/
 LOCAL_MODULE_OWNER := oemcorp
@@ -50,6 +49,4 @@
 # OEM-INSTRUCTION: Configure your own certificate.
 LOCAL_CERTIFICATE :=
 
-# If LOCAL_COMPATIBILITY_SUITE is unset this is the same as BUILD_PACKAGE so
-# can be used for building test or production packages.
-include $(BUILD_CTS_PACKAGE)
+include $(BUILD_PACKAGE)
diff --git a/oem_template/data_app/testing/build_oem_test_data_app.mk b/oem_template/data_app/testing/build_oem_test_data_app.mk
index 4ed18ef..309c726 100644
--- a/oem_template/data_app/testing/build_oem_test_data_app.mk
+++ b/oem_template/data_app/testing/build_oem_test_data_app.mk
@@ -23,8 +23,4 @@
 #
 
 OEM_APP_PATH := $(LOCAL_PATH)/..
-
-# OEM-INSTRUCTION: Change this to the appropriate test suite(s).
-LOCAL_COMPATIBILITY_SUITE := xts
-
 include $(OEM_APP_PATH)/build_oem_data_app.mk
diff --git a/oem_template/data_app_prebuilt/Android.mk b/oem_template/data_app_prebuilt/Android.mk
new file mode 100644
index 0000000..ab09e4d
--- /dev/null
+++ b/oem_template/data_app_prebuilt/Android.mk
@@ -0,0 +1,24 @@
+# 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.
+
+# Targets for including the real signed versions of the time zone data app.
+
+LOCAL_PATH := $(call my-dir)
+
+# Defines the TimeZoneDataPrebuilt prebuilt target.
+include $(CLEAR_VARS)
+TIME_ZONE_DATA_APP_SUFFIX :=
+include $(LOCAL_PATH)/include_app_prebuilt.mk
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/oem_template/data_app_prebuilt/README.oem b/oem_template/data_app_prebuilt/README.oem
new file mode 100644
index 0000000..0ce548f
--- /dev/null
+++ b/oem_template/data_app_prebuilt/README.oem
@@ -0,0 +1,21 @@
+This file originates from package/apps/TimeZoneData/oem_template/data_app_prebuilt.
+
+OEM-INSTRUCTION See below for the purpose of this directory and changes OEMs must make.
+
+This directory contains a suggested structure for including prebuilt .apks in the
+system image and tests.
+
+For example, you can copy it
+
+cp -r data_app_prebuilt ${ANDROID_BUILD_TOP}/vendor/oemcorp/apps/TimeZoneDataPrebuilt
+
+Where <oemcorp> is your company name.
+
+...then read / change all the things marked with OEM-INSTRUCTION.
+
+The intended use is to include .apk artifacts built using the oem_template/data_app.
+
+The targets define includes the real version of the app, and some test versions that can be
+used by the supplied xTS tests.
+
+See oem_template/xts for rules that can be used for xTS testing.
diff --git a/oem_template/data_app_prebuilt/include_app_prebuilt.mk b/oem_template/data_app_prebuilt/include_app_prebuilt.mk
new file mode 100644
index 0000000..f4c6be9
--- /dev/null
+++ b/oem_template/data_app_prebuilt/include_app_prebuilt.mk
@@ -0,0 +1,40 @@
+# 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.
+
+# An .mk include file that contains the boilerplate needed to include real and
+# test, OEM-specific Time Zone Data app prebuilts.
+#
+# Users should set:
+#   TIME_ZONE_DATA_APP_SUFFIX - the suffix to apply to the package name. Can be
+#       empty, or contain things like _test1 for test .apk files.
+#   LOCAL_COMPATIBILITY_SUITE - if the package is to be included in xTS tests.
+#
+
+LOCAL_MODULE := TimeZoneDataPrebuilt$(TIME_ZONE_DATA_APP_SUFFIX)
+LOCAL_SRC_FILES := TimeZoneData$(TIME_ZONE_DATA_APP_SUFFIX).apk
+LOCAL_OVERRIDES_PACKAGES := TimeZoneData$(TIME_ZONE_DATA_APP_SUFFIX)
+LOCAL_MODULE_TAGS := optional
+
+# OEM-INSTRUCTION: Change this
+LOCAL_MODULE_OWNER := oemcorp
+LOCAL_PRIVILEGED_MODULE := true
+
+LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
+LOCAL_MODULE_CLASS := APPS
+# OEM-INSTRUCTION: Change this to match your app-specific signing certificate.
+LOCAL_CERTIFICATE :=
+
+# If LOCAL_COMPATIBILITY_SUITE is set this also copies the APK to the appropriate xTS directory
+# and so this .mk can be used for prod and test targets.
+include $(BUILD_PREBUILT)
diff --git a/oem_template/data_app_prebuilt/testing/Android.mk b/oem_template/data_app_prebuilt/testing/Android.mk
new file mode 100644
index 0000000..9096088
--- /dev/null
+++ b/oem_template/data_app_prebuilt/testing/Android.mk
@@ -0,0 +1,26 @@
+# 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.
+
+# Targets for including testing versions of the time zone data app needed
+# by xTS tests.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+TIME_ZONE_DATA_APP_SUFFIX := _test1
+include $(LOCAL_PATH)/include_test_prebuilt.mk
+
+include $(CLEAR_VARS)
+TIME_ZONE_DATA_APP_SUFFIX := _test2
+include $(LOCAL_PATH)/include_test_prebuilt.mk
diff --git a/oem_template/data_app_prebuilt/testing/include_test_prebuilt.mk b/oem_template/data_app_prebuilt/testing/include_test_prebuilt.mk
new file mode 100644
index 0000000..b3b5b7c
--- /dev/null
+++ b/oem_template/data_app_prebuilt/testing/include_test_prebuilt.mk
@@ -0,0 +1,37 @@
+# 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.
+#
+# An .mk include file that contains the boilerplate needed to include test,
+# OEM-specific Time Zone Data app prebuilts.
+#
+# Users should set:
+#   TIME_ZONE_DATA_APP_SUFFIX - the suffix to apply to the package name.
+#       Should contain things like _test1 for test .apk files.
+#
+
+PREBUILT_PATH := $(LOCAL_PATH)/..
+
+# Turn off pre-opting. We want these to be installable.
+LOCAL_DEX_PREOPT := false
+
+# OEM-INSTRUCTION: Change this to match your OEM-specific test suite.
+# If a value is here the .apk will automatically be included in the associated
+# test suite build, e.g. if there is an oem-specific tradefed suite called "OTS",
+# then put ots here.
+# Required for the xTS TimeZoneUpdateHostTest to pass because it needs correctly
+# signed OEM-specific apks available to work.
+LOCAL_COMPATIBILITY_SUITE :=
+
+include $(PREBUILT_PATH)/include_app_prebuilt.mk
+
diff --git a/oem_template/xts/AndroidTest.xml b/oem_template/xts/AndroidTest.xml
index 1ef5206..cd86156 100644
--- a/oem_template/xts/AndroidTest.xml
+++ b/oem_template/xts/AndroidTest.xml
@@ -20,6 +20,12 @@
         <option name="jar" value="XtsTimeZoneTestCases.jar" />
         <!-- OEM-INSTRUCTION: Change this to match the package name of the data app -->
         <option name="set-option" value="oem-data-app-package-name:com.oemcorp.android.timezone.data" />
+        <!-- OEM-INSTRUCTION: Change this to match the name of the target used to include the test .apks -->
+	<!--
+	   This has to match the name of the .apk files included in the test
+           suite. For example, if the value below is "oem-data-app-apk-prefix:TimeZoneData"
+           the test will look for TimeZoneData_test1.apk and TimeZoneData_test2.apk, etc. during tests.
+          -->
         <option name="set-option" value="oem-data-app-apk-prefix:TimeZoneData" />
     </test>
 </configuration>
diff --git a/oem_template/xts/README.oem b/oem_template/xts/README.oem
index 8921d2a..307724d 100644
--- a/oem_template/xts/README.oem
+++ b/oem_template/xts/README.oem
@@ -2,8 +2,8 @@
 
 OEM-INSTRUCTION See below for the purpose of this directory and changes to make.
 
-This directory contains a suggested structure for CTS-like host-side tests for checking the default
+This directory contains a suggested structure for CTS-like host-side tests for checking the
 time zone update feature has been integrated properly.
 
-These tests are not CTS tests because the OEM must perform their own integration and provide their
-own OEM-specific signed time zone data app implementation under their own package.
+These tests are not included in CTS because the OEM must perform their own integration and
+provide their own OEM-specific signed time zone data app .apks under their own package.