summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlmaz Mingaleev <mingaleev@google.com>2022-05-30 17:16:35 +0100
committerAlmaz Mingaleev <mingaleev@google.com>2022-06-13 11:44:59 +0000
commit29f985b97805978351ac6ec418284df95a96daeb (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904
parent4ccdfc0e80c85413cad83b660d74718d351b5635 (diff)
downloadTimeZoneData-master.tar.gz
Remove TimeZoneData.HEADmastermain
This repo is part of TZUvA feature, which was superseded by tzdata mainline module(s). Bug: 148144561 Test: see system/timezone Change-Id: I26d10482bd045cfde8888e1e9aa72669db350e1f Merged-In: I26d10482bd045cfde8888e1e9aa72669db350e1f
-rw-r--r--Android.bp32
-rw-r--r--Android.mk15
-rw-r--r--OWNERS2
-rw-r--r--README9
-rw-r--r--oem_template/README.oem8
-rw-r--r--oem_template/data_app/Android.mk32
-rw-r--r--oem_template/data_app/AndroidManifest.xml62
-rw-r--r--oem_template/data_app/README.oem28
-rw-r--r--oem_template/data_app/build_oem_data_app.mk59
-rw-r--r--oem_template/data_app/res/values/strings.xml23
-rw-r--r--oem_template/data_app/testing/Android.mk55
-rw-r--r--oem_template/data_app/testing/build_oem_test_data_app.mk26
-rw-r--r--oem_template/data_app_prebuilt/Android.mk24
-rw-r--r--oem_template/data_app_prebuilt/README.oem21
-rw-r--r--oem_template/data_app_prebuilt/include_app_prebuilt.mk43
-rw-r--r--oem_template/data_app_prebuilt/testing/Android.mk26
-rw-r--r--oem_template/data_app_prebuilt/testing/include_test_prebuilt.mk37
-rw-r--r--oem_template/xts/Android.mk31
-rw-r--r--oem_template/xts/AndroidTest.xml31
-rw-r--r--oem_template/xts/README.oem13
-rw-r--r--proguard.cfg3
-rw-r--r--src/main/com/android/timezone/data/TimeZoneRulesDataProvider.java336
-rw-r--r--testing/README4
-rw-r--r--testing/xts/Android.bp31
-rw-r--r--testing/xts/src/com/android/timezone/xts/TimeZoneUpdateHostTest.java431
25 files changed, 0 insertions, 1382 deletions
diff --git a/Android.bp b/Android.bp
deleted file mode 100644
index 0ac28da..0000000
--- a/Android.bp
+++ /dev/null
@@ -1,32 +0,0 @@
-// 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.
-
-// A static library containing all the source needed by a Time Zone Data app.
-package {
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-java_library {
- name: "time_zone_distro_provider",
-
- srcs: ["src/main/**/*.java"],
- optimize: {
- proguard_flags_files: ["proguard.cfg"],
- },
- static_libs: [
- "time_zone_distro_unbundled",
- "androidx.annotation_annotation",
- ],
- sdk_version: "system_current",
-}
diff --git a/Android.mk b/Android.mk
deleted file mode 100644
index 4c33620..0000000
--- a/Android.mk
+++ /dev/null
@@ -1,15 +0,0 @@
-# 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.
-
-# Intentionally left empty to hide oem_template/*/Android.mk
diff --git a/OWNERS b/OWNERS
deleted file mode 100644
index 96c7ad4..0000000
--- a/OWNERS
+++ /dev/null
@@ -1,2 +0,0 @@
-# Bug component: 25699
-include platform/libcore:/OWNERS
diff --git a/README b/README
deleted file mode 100644
index 87d0a62..0000000
--- a/README
+++ /dev/null
@@ -1,9 +0,0 @@
-This directory contains code associated with the "Time Zone Data" app, which is a mechanism
-for updating time zone rules data on device without needing a full OTA: it is delivered via
-OEM-specific signed .apk files.
-
-The code/files beneath this directory are maintained by Android developers and intended to be
-OEM-independent.
-
-See the oem_template directory for files / directory structures that OEMs are expected to copy
-elsewhere and configure.
diff --git a/oem_template/README.oem b/oem_template/README.oem
deleted file mode 100644
index 94c0e4d..0000000
--- a/oem_template/README.oem
+++ /dev/null
@@ -1,8 +0,0 @@
-This directory contains an example / suggested structure for OEMs.
-Contained within is code for implementing the time zone update feature.
-
-OEMs are expected to copy the sub-dirs under this directory to appropriate places in their own repos
-and customize.
-
-Further instructions for OEMs can be found by searching for the string "OEM-INSTRUCTION" in the files
-beneath this directory.
diff --git a/oem_template/data_app/Android.mk b/oem_template/data_app/Android.mk
deleted file mode 100644
index dc53ee3..0000000
--- a/oem_template/data_app/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# 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 creating the real signed versions of the time zone data app.
-
-LOCAL_PATH := $(call my-dir)
-
-OEM_APP_PATH := $(LOCAL_PATH)
-
-# Target to build the "real" time zone data app.
-include $(CLEAR_VARS)
-LOCAL_ASSET_DIR := system/timezone/output_data/distro
-TIME_ZONE_DATA_APP_SUFFIX :=
-
-# OEM-INSTRUCTION: OEMs should come up with a suitable versioning strategy.
-TIME_ZONE_DATA_APP_VERSION_CODE := 10
-TIME_ZONE_DATA_APP_VERSION_NAME := 10
-
-include $(OEM_APP_PATH)/build_oem_data_app.mk
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/oem_template/data_app/AndroidManifest.xml b/oem_template/data_app/AndroidManifest.xml
deleted file mode 100644
index 1f4046c..0000000
--- a/oem_template/data_app/AndroidManifest.xml
+++ /dev/null
@@ -1,62 +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.
- -->
-<!-- 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
deleted file mode 100644
index f288adf..0000000
--- a/oem_template/data_app/README.oem
+++ /dev/null
@@ -1,28 +0,0 @@
-This file originates from package/apps/TimeZoneData/oem_template/data_app.
-
-OEM-INSTRUCTION See below for the purpose of this directory and changes OEMs must make.
-
-This directory contains a suggested structure for building an OEM version of Time Zone Data app
-(real and test versions).
-
-For example, you can copy it
-
-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.
-
-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
deleted file mode 100644
index 0cb2bc0..0000000
--- a/oem_template/data_app/build_oem_data_app.mk
+++ /dev/null
@@ -1,59 +0,0 @@
-# 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 build real and
-# test, OEM-specific Time Zone Data apps.
-#
-# Users should set:
-# OEM_APP_PATH - the location of the OEM directory for the app, e.g. one that
-# contains the app res/ dir.
-# 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.
-# TIME_ZONE_DATA_APP_VERSION_CODE - the version code for the .apk.
-# TIME_ZONE_DATA_APP_VERSION_NAME - the version name for the .apk.
-# LOCAL_COMPATIBILITY_SUITE - if the package is to be included in xTS tests.
-#
-LOCAL_MODULE_TAGS := optional
-
-# All src comes from an AOSP static library.
-LOCAL_STATIC_JAVA_LIBRARIES := time_zone_distro_provider
-
-# All resources come from the vendor-specific dirs.
-LOCAL_RESOURCE_DIR := $(OEM_APP_PATH)/res
-
-# 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_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-
-LOCAL_AAPT_FLAGS := --version-code $(TIME_ZONE_DATA_APP_VERSION_CODE) \
- --version-name $(TIME_ZONE_DATA_APP_VERSION_NAME)
-
-# OEM-INSTRUCTION: Modify the name, s/oemcorp/<Your company name>/
-LOCAL_MODULE_OWNER := oemcorp
-
-# The app build is expected to generate a prebuilt, so do not place the app in
-# the system image.
-LOCAL_UNINSTALLABLE_MODULE := true
-
-LOCAL_PRODUCT_MODULE := true
-
-# OEM-INSTRUCTION: Configure your own certificate.
-LOCAL_CERTIFICATE :=
-
-include $(BUILD_PACKAGE)
diff --git a/oem_template/data_app/res/values/strings.xml b/oem_template/data_app/res/values/strings.xml
deleted file mode 100644
index 19a5e45..0000000
--- a/oem_template/data_app/res/values/strings.xml
+++ /dev/null
@@ -1,23 +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.
- -->
-
-<resources>
- <!-- OEM-INSTRUCTION: Modify the name. This will appear in Settings / apps and app stores.
- OEMs will usually want to provide translations too.
- -->
- <string name="app_name">OEM Corp Time Zone Data</string>
-</resources>
diff --git a/oem_template/data_app/testing/Android.mk b/oem_template/data_app/testing/Android.mk
deleted file mode 100644
index f82f1db..0000000
--- a/oem_template/data_app/testing/Android.mk
+++ /dev/null
@@ -1,55 +0,0 @@
-# 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 creating signed test versions of the time zone data app that can be used for
-# manual testing and / or xts-type tests.
-
-LOCAL_PATH := $(call my-dir)
-
-# Paths used to find files shared with AOSP.
-aosp_test_data_path := system/timezone/testing/data
-
-# Target to build the "test 1" time zone data app.
-include $(CLEAR_VARS)
-LOCAL_ASSET_DIR := $(aosp_test_data_path)/test1/output_data/distro
-TIME_ZONE_DATA_APP_SUFFIX := _test1
-
-# OEM-INSTRUCTION: OEMs should come up with a suitable versioning strategy and this version should
-# be guaranteed newer than the "real" app.
-TIME_ZONE_DATA_APP_VERSION_CODE := 15
-TIME_ZONE_DATA_APP_VERSION_NAME := test1
-
-# When built, explicitly put it in the data partition since this is for tests, not the system image.
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-include $(LOCAL_PATH)/build_oem_test_data_app.mk
-
-
-# Target to build the "test 2" time zone data app.
-include $(CLEAR_VARS)
-LOCAL_ASSET_DIR := $(aosp_test_data_path)/test2/output_data/distro
-TIME_ZONE_DATA_APP_SUFFIX := _test2
-
-# OEM-INSTRUCTION: OEMs should come up with a suitable versioning strategy and this version should
-# be guaranteed newer than the "real" app.
-TIME_ZONE_DATA_APP_VERSION_CODE := 20
-TIME_ZONE_DATA_APP_VERSION_NAME := test2
-
-# When built, explicitly put it in the data partition since this is for tests, not the system image.
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-include $(LOCAL_PATH)/build_oem_test_data_app.mk
-
-# Tidy up variables.
-aosp_test_data_path :=
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
deleted file mode 100644
index 309c726..0000000
--- a/oem_template/data_app/testing/build_oem_test_data_app.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-# 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 build test,
-# OEM-specific Time Zone Data apps.
-#
-# 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.
-# TIME_ZONE_DATA_APP_VERSION_CODE - the version code for the .apk.
-# TIME_ZONE_DATA_APP_VERSION_NAME - the version name for the .apk.
-#
-
-OEM_APP_PATH := $(LOCAL_PATH)/..
-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
deleted file mode 100644
index ab09e4d..0000000
--- a/oem_template/data_app_prebuilt/Android.mk
+++ /dev/null
@@ -1,24 +0,0 @@
-# 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
deleted file mode 100644
index 0ce548f..0000000
--- a/oem_template/data_app_prebuilt/README.oem
+++ /dev/null
@@ -1,21 +0,0 @@
-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
deleted file mode 100644
index ec9939a..0000000
--- a/oem_template/data_app_prebuilt/include_app_prebuilt.mk
+++ /dev/null
@@ -1,43 +0,0 @@
-# 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_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-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_PRODUCT_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
deleted file mode 100644
index 9096088..0000000
--- a/oem_template/data_app_prebuilt/testing/Android.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-# 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
deleted file mode 100644
index b3b5b7c..0000000
--- a/oem_template/data_app_prebuilt/testing/include_test_prebuilt.mk
+++ /dev/null
@@ -1,37 +0,0 @@
-# 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/Android.mk b/oem_template/xts/Android.mk
deleted file mode 100644
index d5ceeeb..0000000
--- a/oem_template/xts/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright (C) 2017 Google Inc.
-#
-# 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_TAGS := tests
-
-# OEM-INSTRUCTION: OEMs should change this.
-LOCAL_COMPATIBILITY_SUITE := xts
-
-# OEM-INSTRUCTION: OEMs should change this
-LOCAL_MODULE := XtsTimeZoneTestCases
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-
-LOCAL_STATIC_JAVA_LIBRARIES := time_zone_data_app_testing
-
-include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/oem_template/xts/AndroidTest.xml b/oem_template/xts/AndroidTest.xml
deleted file mode 100644
index 5fa472a..0000000
--- a/oem_template/xts/AndroidTest.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (c) 2017 Google Inc.
-
- 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 PTS Time Zone test cases">
- <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
- <!-- OEM-INSTRUCTION: Change this to match the target name in Android.mk -->
- <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
deleted file mode 100644
index a20045b..0000000
--- a/oem_template/xts/README.oem
+++ /dev/null
@@ -1,13 +0,0 @@
-This file originates from package/apps/TimeZoneData/oem_template/xts.
-
-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
-time zone update feature has been integrated properly.
-
-These tests are not included in CTS because the OEM must perform their own feature
-integration and sign their own TimeZoneData app; no CTS-provided TimeZoneData app would be
-installable on an OEM's device.
-
-To pass, OEMs must provide their own OEM-specific signed time zone data app .apks under the
-correct package name and configure the test config.
diff --git a/proguard.cfg b/proguard.cfg
deleted file mode 100644
index 714cc85..0000000
--- a/proguard.cfg
+++ /dev/null
@@ -1,3 +0,0 @@
--keep class com.android.timezone.data.** { *; }
--dontobfuscate
--verbose
diff --git a/src/main/com/android/timezone/data/TimeZoneRulesDataProvider.java b/src/main/com/android/timezone/data/TimeZoneRulesDataProvider.java
deleted file mode 100644
index b524fce..0000000
--- a/src/main/com/android/timezone/data/TimeZoneRulesDataProvider.java
+++ /dev/null
@@ -1,336 +0,0 @@
-/*
- * 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 com.android.timezone.data;
-
-import com.android.timezone.distro.DistroException;
-import com.android.timezone.distro.DistroVersion;
-import com.android.timezone.distro.TimeZoneDistro;
-
-import android.content.ContentProvider;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.content.pm.ProviderInfo;
-import android.content.res.AssetManager;
-import android.database.AbstractCursor;
-import android.database.Cursor;
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.ParcelFileDescriptor;
-import android.os.UserHandle;
-import android.provider.TimeZoneRulesDataContract;
-import android.provider.TimeZoneRulesDataContract.Operation;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static android.content.res.AssetManager.ACCESS_STREAMING;
-
-/**
- * A basic implementation of a time zone data provider that can be used by OEMs to implement
- * an APK asset-based solution for time zone updates.
- */
-public final class TimeZoneRulesDataProvider extends ContentProvider {
-
- static final String TAG = "TimeZoneRulesDataProvider";
-
- private static final String METADATA_KEY_OPERATION = "android.timezoneprovider.OPERATION";
-
- private static final Set<String> KNOWN_COLUMN_NAMES;
- private static final Map<String, Class<?>> KNOWN_COLUMN_TYPES;
-
- static {
- Set<String> columnNames = new HashSet<>();
- columnNames.add(Operation.COLUMN_TYPE);
- columnNames.add(Operation.COLUMN_DISTRO_MAJOR_VERSION);
- columnNames.add(Operation.COLUMN_DISTRO_MINOR_VERSION);
- columnNames.add(Operation.COLUMN_RULES_VERSION);
- columnNames.add(Operation.COLUMN_REVISION);
- KNOWN_COLUMN_NAMES = Collections.unmodifiableSet(columnNames);
-
- Map<String, Class<?>> columnTypes = new HashMap<>();
- columnTypes.put(Operation.COLUMN_TYPE, String.class);
- columnTypes.put(Operation.COLUMN_DISTRO_MAJOR_VERSION, Integer.class);
- columnTypes.put(Operation.COLUMN_DISTRO_MINOR_VERSION, Integer.class);
- columnTypes.put(Operation.COLUMN_RULES_VERSION, String.class);
- columnTypes.put(Operation.COLUMN_REVISION, Integer.class);
- KNOWN_COLUMN_TYPES = Collections.unmodifiableMap(columnTypes);
- }
-
- private final Map<String, Object> mColumnData = new HashMap<>();
-
- @Override
- public boolean onCreate() {
- return true;
- }
-
- @Override
- public void attachInfo(Context context, ProviderInfo info) {
- super.attachInfo(context, info);
-
- // The time zone update process should run as the system user exclusively as it's a
- // system feature, not user dependent.
- UserHandle currentUserHandle = android.os.Process.myUserHandle();
- if (!currentUserHandle.isSystem()) {
- throw new SecurityException("ContentProvider is supposed to run as the system user,"
- + " instead user=" + currentUserHandle);
- }
-
- // Confirm our security
- if (!TimeZoneRulesDataContract.AUTHORITY.equals(info.authority)) {
- // The authority looked for by the time zone updater is fixed.
- throw new SecurityException(
- "android:authorities must be \"" + TimeZoneRulesDataContract.AUTHORITY + "\"");
- }
- if (!info.grantUriPermissions) {
- throw new SecurityException("Provider must grant uri permissions");
- }
- if (!info.exported) {
- // The content provider is accessed directly so must be exported.
- throw new SecurityException("android:exported must be \"true\"");
- }
- if (info.pathPermissions != null || info.writePermission != null) {
- // Use readPermission only to implement permissions.
- throw new SecurityException("Use android:readPermission only");
- }
- if (!android.Manifest.permission.UPDATE_TIME_ZONE_RULES.equals(info.readPermission)) {
- // Writing is not supported.
- throw new SecurityException("android:readPermission must be set to \""
- + android.Manifest.permission.UPDATE_TIME_ZONE_RULES
- + "\" is: " + info.readPermission);
- }
-
- // info.metadata is not filled in by default. Must ask for it again.
- final ProviderInfo infoWithMetadata = context.getPackageManager()
- .resolveContentProvider(info.authority, PackageManager.GET_META_DATA);
- Bundle metaData = infoWithMetadata.metaData;
- if (metaData == null) {
- throw new SecurityException("meta-data must be set");
- }
-
- // Work out what the operation type is.
- String type;
- try {
- type = getMandatoryMetaDataString(metaData, METADATA_KEY_OPERATION);
- mColumnData.put(Operation.COLUMN_TYPE, type);
- } catch (IllegalArgumentException e) {
- throw new SecurityException(METADATA_KEY_OPERATION + " meta-data not set.");
- }
-
- // Fill in version information if this is an install operation.
- if (Operation.TYPE_INSTALL.equals(type)) {
- // Extract the version information from the distro.
- InputStream distroBytesInputStream;
- try {
- distroBytesInputStream = context.getAssets().open(TimeZoneDistro.FILE_NAME);
- } catch (IOException e) {
- throw new SecurityException(
- "Unable to open asset: " + TimeZoneDistro.FILE_NAME, e);
- }
- TimeZoneDistro distro = new TimeZoneDistro(distroBytesInputStream);
- try {
- DistroVersion distroVersion = distro.getDistroVersion();
- mColumnData.put(Operation.COLUMN_DISTRO_MAJOR_VERSION,
- distroVersion.formatMajorVersion);
- mColumnData.put(Operation.COLUMN_DISTRO_MINOR_VERSION,
- distroVersion.formatMinorVersion);
- mColumnData.put(Operation.COLUMN_RULES_VERSION, distroVersion.rulesVersion);
- mColumnData.put(Operation.COLUMN_REVISION, distroVersion.revision);
- } catch (IOException | DistroException e) {
- throw new SecurityException("Invalid asset: " + TimeZoneDistro.FILE_NAME, e);
- }
-
- }
- }
-
- @Override
- public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection,
- @Nullable String[] selectionArgs, @Nullable String sortOrder) {
- if (!Operation.CONTENT_URI.equals(uri)) {
- return null;
- }
- final List<String> projectionList = Arrays.asList(projection);
- if (projection != null && !KNOWN_COLUMN_NAMES.containsAll(projectionList)) {
- throw new UnsupportedOperationException(
- "Only " + KNOWN_COLUMN_NAMES + " columns supported.");
- }
-
- return new AbstractCursor() {
- @Override
- public int getCount() {
- return 1;
- }
-
- @Override
- public String[] getColumnNames() {
- return projectionList.toArray(new String[0]);
- }
-
- @Override
- public int getType(int column) {
- String columnName = projectionList.get(column);
- Class<?> columnJavaType = KNOWN_COLUMN_TYPES.get(columnName);
- if (columnJavaType == String.class) {
- return Cursor.FIELD_TYPE_STRING;
- } else if (columnJavaType == Integer.class) {
- return Cursor.FIELD_TYPE_INTEGER;
- } else {
- throw new UnsupportedOperationException(
- "Unsupported type: " + columnJavaType + " for " + columnName);
- }
- }
-
- @Override
- public String getString(int column) {
- checkPosition();
- String columnName = projectionList.get(column);
- if (KNOWN_COLUMN_TYPES.get(columnName) != String.class) {
- throw new UnsupportedOperationException();
- }
- return (String) mColumnData.get(columnName);
- }
-
- @Override
- public short getShort(int column) {
- checkPosition();
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int getInt(int column) {
- checkPosition();
- String columnName = projectionList.get(column);
- if (KNOWN_COLUMN_TYPES.get(columnName) != Integer.class) {
- throw new UnsupportedOperationException();
- }
- return (Integer) mColumnData.get(columnName);
- }
-
- @Override
- public long getLong(int column) {
- return getInt(column);
- }
-
- @Override
- public float getFloat(int column) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public double getDouble(int column) {
- checkPosition();
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isNull(int column) {
- checkPosition();
- return column != 0;
- }
- };
- }
-
- @Override
- public ParcelFileDescriptor openFile(@NonNull Uri uri, @NonNull String mode)
- throws FileNotFoundException {
- if (!Operation.CONTENT_URI.equals(uri)) {
- throw new FileNotFoundException("Unknown URI: " + uri);
- }
- if (!"r".equals(mode)) {
- throw new FileNotFoundException("Only read-only access supported.");
- }
-
- // We cannot return the asset ParcelFileDescriptor from
- // assets.openFd(name).getParcelFileDescriptor() here as the receiver in the reading
- // process gets a ParcelFileDescriptor pointing at the whole .apk. Instead, we extract
- // the asset file we want to storage then wrap that in a ParcelFileDescriptor.
- File distroFile = null;
- try {
- distroFile = File.createTempFile("distro", null, getContext().getFilesDir());
-
- AssetManager assets = getContext().getAssets();
- try (InputStream is = assets.open(TimeZoneDistro.FILE_NAME, ACCESS_STREAMING);
- FileOutputStream fos = new FileOutputStream(distroFile, false /* append */)) {
- copy(is, fos);
- }
-
- return ParcelFileDescriptor.open(distroFile, ParcelFileDescriptor.MODE_READ_ONLY);
- } catch (IOException e) {
- throw new RuntimeException("Unable to copy distro asset file", e);
- } finally {
- if (distroFile != null) {
- // Even if we have an open file descriptor pointing at the file it should be safe to
- // delete because of normal Unix file behavior. Deleting here avoids leaking any
- // storage.
- distroFile.delete();
- }
- }
- }
-
- @Override
- public String getType(@NonNull Uri uri) {
- return null;
- }
-
- @Override
- public Uri insert(@NonNull Uri uri, @Nullable ContentValues values) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int delete(@NonNull Uri uri, @Nullable String selection,
- @Nullable String[] selectionArgs) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection,
- @Nullable String[] selectionArgs) {
- throw new UnsupportedOperationException();
- }
-
- private static String getMandatoryMetaDataString(Bundle metaData, String key) {
- if (!metaData.containsKey(key)) {
- throw new SecurityException("No metadata with key " + key + " found.");
- }
- return metaData.getString(key);
- }
-
- /**
- * Copies all of the bytes from {@code in} to {@code out}. Neither stream is closed.
- */
- private static void copy(InputStream in, OutputStream out) throws IOException {
- byte[] buffer = new byte[8192];
- int c;
- while ((c = in.read(buffer)) != -1) {
- out.write(buffer, 0, c);
- }
- }
-}
diff --git a/testing/README b/testing/README
deleted file mode 100644
index d4ebe2e..0000000
--- a/testing/README
+++ /dev/null
@@ -1,4 +0,0 @@
-This directory contains files associated with testing the Time Zone update feature.
-
-xts/ - Libraries to support automated testing of the Time Zone update feature.
-
diff --git a/testing/xts/Android.bp b/testing/xts/Android.bp
deleted file mode 100644
index 735a1c5..0000000
--- a/testing/xts/Android.bp
+++ /dev/null
@@ -1,31 +0,0 @@
-// 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.
-
-// A testing support library for testing time zone updates on real devices.
-// OEMs can include this as a "_STATIC_" dependency and anything else needed to integrate with their
-// own test suite. At runtime the libs below (or a superset) must be present.
-
-package {
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-java_library_host {
- name: "time_zone_data_app_testing",
- srcs: ["src/**/*.java"],
- libs: [
- "cts-tradefed",
- "tradefed",
- "compatibility-host-util",
- ],
-}
diff --git a/testing/xts/src/com/android/timezone/xts/TimeZoneUpdateHostTest.java b/testing/xts/src/com/android/timezone/xts/TimeZoneUpdateHostTest.java
deleted file mode 100644
index 6cd63a9..0000000
--- a/testing/xts/src/com/android/timezone/xts/TimeZoneUpdateHostTest.java
+++ /dev/null
@@ -1,431 +0,0 @@
-/*
- * 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 com.android.timezone.xts;
-
-import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.Option;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil;
-import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
-import com.android.tradefed.testtype.IBuildReceiver;
-import com.android.tradefed.testtype.IDeviceTest;
-import com.android.tradefed.util.FileUtil;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.io.File;
-import java.util.function.BooleanSupplier;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Class for host-side tests that the time zone rules update feature works as intended. This is
- * intended to give confidence to OEMs that they have implemented / configured the OEM parts of the
- * feature correctly.
- *
- * <p>There are two main operations involved in time zone updates:
- * <ol>
- * <li>Package installs/uninstalls - asynchronously stage operations for install</li>
- * <li>Reboots - perform the staged operations / delete bad installed data</li>
- * </ol>
- * Both these operations are time consuming and there's a degree of non-determinism involved.
- *
- * <p>A "clean" device can also be in one of two main states depending on whether it has been wiped
- * and/or rebooted before this test runs:
- * <ul>
- * <li>A device may have nothing staged / installed in /data/misc/zoneinfo at all.</li>
- * <li>A device may have the time zone data from the default system image version of the time
- * zone data app staged or installed.</li>
- * </ul>
- * This test attempts to handle both of these cases.
- *
- */
-@RunWith(DeviceJUnit4ClassRunner.class)
-public class TimeZoneUpdateHostTest implements IDeviceTest, IBuildReceiver {
-
- // These must match equivalent values in RulesManagerService dumpsys code.
- private static final String STAGED_OPERATION_NONE = "None";
- private static final String STAGED_OPERATION_INSTALL = "Install";
- private static final String STAGED_OPERATION_UNINSTALL = "Uninstall";
- private static final String INSTALL_STATE_INSTALLED = "Installed";
-
- private IBuildInfo mBuildInfo;
- private ITestDevice mDevice;
- private File mTempDir;
-
- @Option(name = "oem-data-app-package-name",
- description="The OEM-specific package name for the data app",
- mandatory = true)
- private String mOemDataAppPackageName;
-
- private String getTimeZoneDataPackageName() {
- assertNotNull(mOemDataAppPackageName);
- return mOemDataAppPackageName;
- }
-
- @Option(name = "oem-data-app-apk-prefix",
- description="The OEM-specific APK name for the data app test files, e.g."
- + "for TimeZoneDataOemCorp_test1.apk the prefix would be"
- + "\"TimeZoneDataOemCorp\"",
- mandatory = true)
- private String mOemDataAppApkPrefix;
-
- private String getTimeZoneDataApkName(String testId) {
- assertNotNull(mOemDataAppApkPrefix);
- return mOemDataAppApkPrefix + "_" + testId + ".apk";
- }
-
- @Override
- public void setBuild(IBuildInfo buildInfo) {
- mBuildInfo = buildInfo;
- }
-
- @Override
- public void setDevice(ITestDevice device) {
- mDevice = device;
- }
-
- @Override
- public ITestDevice getDevice() {
- return mDevice;
- }
-
- @Before
- public void setUp() throws Exception {
- createTempDir();
- resetDeviceToClean();
- }
-
- @After
- public void tearDown() throws Exception {
- resetDeviceToClean();
- deleteTempDir();
- }
-
- private void createTempDir() throws Exception {
- mTempDir = File.createTempFile("timeZoneUpdateTest", null);
- assertTrue(mTempDir.delete());
- assertTrue(mTempDir.mkdir());
- }
-
- private void deleteTempDir() throws Exception {
- FileUtil.recursiveDelete(mTempDir);
- }
-
- /**
- * Reset the device to having no installed time zone data outside of the /system/priv-app
- * version that came with the system image.
- */
- private void resetDeviceToClean() throws Exception {
- // If this fails the data app isn't present on device. No point in starting.
- assertTrue(getTimeZoneDataPackageName() + " not installed",
- isPackageInstalled(getTimeZoneDataPackageName()));
-
- // Reboot as needed to apply any staged operation.
- if (!STAGED_OPERATION_NONE.equals(getStagedOperationType())) {
- rebootDeviceAndWaitForRestart();
- }
-
- // A "clean" device means no time zone data .apk installed in /data at all, try to get to
- // that state.
- for (int i = 0; i < 2; i++) {
- logDeviceTimeZoneState();
-
- // Even if there's no distro installed, there may be an updated APK installed, so try to
- // remove it unconditionally.
- String errorCode = uninstallPackage(getTimeZoneDataPackageName());
- if (errorCode != null) {
- // Failed to uninstall, which we take to mean the device is "clean".
- break;
- }
- // Success, meaning there was an APK that could be uninstalled.
- // If there is a distro installed we need wait for the distro uninstall that should now
- // become staged.
- boolean distroIsInstalled = INSTALL_STATE_INSTALLED.equals(getCurrentInstallState());
- if (distroIsInstalled) {
- // It may take a short while before we can detect anything: the package manager
- // should have triggered an intent, and the PackageTracker has to receive that and
- // send its own intent, which then has to be acted on before we could detect an
- // operation in progress. We expect the device eventually to get to the staged state
- // "UNINSTALL", meaning it will try to revert to no distro installed on next boot.
- waitForStagedUninstall();
-
- rebootDeviceAndWaitForRestart();
- } else {
- // There was an apk installed, but no time zone distro was installed. It was
- // probably a "bad" .apk that was rejected. The update app will request an uninstall
- // anyway just to be sure, so we'll give it a chance to do that before continuing
- // otherwise we could get an "operation in progress" later on when we're not
- // expecting it.
- Thread.sleep(10000);
- }
- }
- assertActiveRulesVersion(getBaseRulesVersion());
- assertEquals(STAGED_OPERATION_NONE, getStagedOperationType());
- }
-
- @Test
- public void testInstallNewerRulesVersion() throws Exception {
- // This information must match the rules version in test1: IANA version=2030a, revision=1
- String test1VersionInfo = "2030a,1";
-
- // Confirm the staged / install state before we start.
- assertFalse(test1VersionInfo.equals(getCurrentInstalledVersion()));
- assertEquals(STAGED_OPERATION_NONE, getStagedOperationType());
-
- File appFile = getTimeZoneDataApkFile("test1");
- getDevice().installPackage(appFile, true /* reinstall */);
-
- waitForStagedInstall(test1VersionInfo);
-
- // Confirm the install state hasn't changed.
- assertFalse(test1VersionInfo.equals(getCurrentInstalledVersion()));
-
- // Now reboot, and the staged version should become the installed version.
- rebootDeviceAndWaitForRestart();
-
- // After reboot, check the state.
- assertEquals(STAGED_OPERATION_NONE, getStagedOperationType());
- assertEquals(INSTALL_STATE_INSTALLED, getCurrentInstallState());
- assertEquals(test1VersionInfo, getCurrentInstalledVersion());
- }
-
- @Test
- public void testInstallNewerRulesVersion_secondaryUser() throws Exception {
- ITestDevice device = getDevice();
- if (!device.isMultiUserSupported()) {
- // Just pass on non-multi-user devices.
- return;
- }
-
- int userId = device.createUser("TimeZoneTest", false /* guest */, false /* ephemeral */);
- try {
-
- // This information must match the rules version in test1: IANA version=2030a, revision=1
- String test1VersionInfo = "2030a,1";
-
- // Confirm the staged / install state before we start.
- assertFalse(test1VersionInfo.equals(getCurrentInstalledVersion()));
- assertEquals(STAGED_OPERATION_NONE, getStagedOperationType());
-
- File appFile = getTimeZoneDataApkFile("test1");
-
- // Install the app for the test user. It should still all work.
- device.installPackageForUser(appFile, true /* reinstall */, userId);
-
- waitForStagedInstall(test1VersionInfo);
-
- // Confirm the install state hasn't changed.
- assertFalse(test1VersionInfo.equals(getCurrentInstalledVersion()));
-
- // Now reboot, and the staged version should become the installed version.
- rebootDeviceAndWaitForRestart();
-
- // After reboot, check the state.
- assertEquals(STAGED_OPERATION_NONE, getStagedOperationType());
- assertEquals(INSTALL_STATE_INSTALLED, getCurrentInstallState());
- assertEquals(test1VersionInfo, getCurrentInstalledVersion());
- }
- finally {
- // If this fails, the device may be left in a bad state.
- device.removeUser(userId);
- }
- }
-
- @Test
- public void testInstallOlderRulesVersion() throws Exception {
- File appFile = getTimeZoneDataApkFile("test2");
- getDevice().installPackage(appFile, true /* reinstall */);
-
- // The attempt to install a version of the data that is older than the version in the system
- // image should be rejected and nothing should be staged. There's currently no way (short of
- // looking at logs) to tell this has happened, but combined with other tests and given a
- // suitable delay it gives us some confidence that the attempt has been made and it was
- // rejected.
-
- Thread.sleep(30000);
-
- assertEquals(STAGED_OPERATION_NONE, getStagedOperationType());
- }
-
- private void rebootDeviceAndWaitForRestart() throws Exception {
- log("Rebooting device");
- getDevice().reboot();
- }
-
- private void logDeviceTimeZoneState() throws Exception {
- log("Initial device state: " + dumpEntireTimeZoneStatusToString());
- }
-
- private static void log(String msg) {
- LogUtil.CLog.i(msg);
- }
-
- private void assertActiveRulesVersion(String expectedRulesVersion) throws Exception {
- // Dumpsys reports the version reported by ICU, ZoneInfoDb and TimeZoneFinder and they
- // should always match.
- String expectedActiveRulesVersion =
- expectedRulesVersion + "," + expectedRulesVersion + "," + expectedRulesVersion;
-
- String actualActiveRulesVersion =
- waitForNoOperationInProgressAndReturn(StateType.ACTIVE_RULES_VERSION);
- assertEquals(expectedActiveRulesVersion, actualActiveRulesVersion);
- }
-
- private String getCurrentInstalledVersion() throws Exception {
- return waitForNoOperationInProgressAndReturn(StateType.CURRENTLY_INSTALLED_VERSION);
- }
-
- private String getCurrentInstallState() throws Exception {
- return waitForNoOperationInProgressAndReturn(StateType.CURRENT_INSTALL_STATE);
- }
-
- private String getStagedInstallVersion() throws Exception {
- return waitForNoOperationInProgressAndReturn(StateType.STAGED_INSTALL_VERSION);
- }
-
- private String getStagedOperationType() throws Exception {
- return waitForNoOperationInProgressAndReturn(StateType.STAGED_OPERATION_TYPE);
- }
-
- private String getBaseRulesVersion() throws Exception {
- return waitForNoOperationInProgressAndReturn(StateType.BASE_RULES_VERSION);
- }
-
- private boolean isOperationInProgress() {
- try {
- String operationInProgressString =
- getDeviceTimeZoneState(StateType.OPERATION_IN_PROGRESS);
- return Boolean.parseBoolean(operationInProgressString);
- } catch (Exception e) {
- throw new AssertionError("Failed to read staged status", e);
- }
- }
-
- private String waitForNoOperationInProgressAndReturn(StateType stateType) throws Exception {
- waitForCondition(() -> !isOperationInProgress());
- return getDeviceTimeZoneState(stateType);
- }
-
- private void waitForStagedUninstall() throws Exception {
- waitForCondition(() -> isStagedUninstall());
- }
-
- private void waitForStagedInstall(String versionString) throws Exception {
- waitForCondition(() -> isStagedInstall(versionString));
- }
-
- private boolean isStagedUninstall() {
- try {
- return getStagedOperationType().equals(STAGED_OPERATION_UNINSTALL);
- } catch (Exception e) {
- throw new AssertionError("Failed to read staged status", e);
- }
- }
-
- private boolean isStagedInstall(String versionString) {
- try {
- return getStagedOperationType().equals(STAGED_OPERATION_INSTALL)
- && getStagedInstallVersion().equals(versionString);
- } catch (Exception e) {
- throw new AssertionError("Failed to read staged status", e);
- }
- }
-
- private static void waitForCondition(BooleanSupplier condition) throws Exception {
- int count = 0;
- boolean lastResult;
- while (!(lastResult = condition.getAsBoolean()) && count++ < 120) {
- Thread.sleep(1000);
- }
- // Some conditions may not be stable so using the lastResult instead of
- // condition.getAsBoolean() ensures we understand why we exited the loop.
- assertTrue("Failed condition: " + condition, lastResult);
- }
-
- private enum StateType {
- OPERATION_IN_PROGRESS,
- BASE_RULES_VERSION,
- CURRENT_INSTALL_STATE,
- CURRENTLY_INSTALLED_VERSION,
- STAGED_OPERATION_TYPE,
- STAGED_INSTALL_VERSION,
- ACTIVE_RULES_VERSION;
-
- public String getFormatStateChar() {
- // This switch must match values in com.android.server.timezone.RulesManagerService.
- switch (this) {
- case OPERATION_IN_PROGRESS:
- return "p";
- case BASE_RULES_VERSION:
- return "b";
- case CURRENT_INSTALL_STATE:
- return "c";
- case CURRENTLY_INSTALLED_VERSION:
- return "i";
- case STAGED_OPERATION_TYPE:
- return "o";
- case STAGED_INSTALL_VERSION:
- return "t";
- case ACTIVE_RULES_VERSION:
- return "a";
- default:
- throw new AssertionError("Unknown state type: " + this);
- }
- }
- }
-
- private String getDeviceTimeZoneState(StateType stateType) throws Exception {
- String output = getDevice().executeShellCommand(
- "dumpsys timezone -format_state " + stateType.getFormatStateChar());
- assertNotNull(output);
- // Output will be "Foo: bar\n". We want the "bar".
- String value = output.split(":")[1];
- return value.substring(1, value.length() - 1);
- }
-
- private String dumpEntireTimeZoneStatusToString() throws Exception {
- String output = getDevice().executeShellCommand("dumpsys timezone");
- assertNotNull(output);
- return output;
- }
-
- private File getTimeZoneDataApkFile(String testId) throws Exception {
- CompatibilityBuildHelper buildHelper = new CompatibilityBuildHelper(mBuildInfo);
- String fileName = getTimeZoneDataApkName(testId);
- return buildHelper.getTestFile(fileName);
- }
-
- private boolean isPackageInstalled(String pkg) throws Exception {
- for (String installedPackage : getDevice().getInstalledPackageNames()) {
- if (pkg.equals(installedPackage)) {
- return true;
- }
- }
- return false;
- }
-
- private String uninstallPackage(String packageName) throws Exception {
- return getDevice().uninstallPackage(packageName);
- }
-}