1# Copyright (C) 2015 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15#
16# Builds a package which can be instrumented to retrieve information about the device under test.
17#
18
19DEVICE_INFO_PACKAGE := com.android.compatibility.common.deviceinfo
20DEVICE_INFO_INSTRUMENT := com.android.compatibility.common.deviceinfo.DeviceInfoInstrument
21DEVICE_INFO_PERMISSIONS += android.permission.WRITE_EXTERNAL_STORAGE
22DEVICE_INFO_ACTIVITIES += $(DEVICE_INFO_PACKAGE).GenericDeviceInfo $(DEVICE_INFO_PACKAGE).PackageDeviceInfo
23
24# Add the base device info
25LOCAL_STATIC_JAVA_LIBRARIES += compatibility-device-info
26
27# Generator of APK manifests.
28MANIFEST_GENERATOR_JAR := $(HOST_OUT_JAVA_LIBRARIES)/compatibility-manifest-generator.jar
29MANIFEST_GENERATOR := java -jar $(MANIFEST_GENERATOR_JAR)
30
31# Generate the manifest
32manifest_xml := $(call intermediates-dir-for,APPS,$(LOCAL_PACKAGE_NAME))/AndroidManifest.xml
33$(manifest_xml): PRIVATE_INFO_PERMISSIONS := $(foreach permission, $(DEVICE_INFO_PERMISSIONS),-r $(permission))
34$(manifest_xml): PRIVATE_INFO_ACTIVITIES := $(foreach activity,$(DEVICE_INFO_ACTIVITIES),-a $(activity))
35$(manifest_xml): PRIVATE_PACKAGE := $(DEVICE_INFO_PACKAGE)
36$(manifest_xml): PRIVATE_INSTRUMENT := $(DEVICE_INFO_INSTRUMENT)
37
38# Regenerate manifest.xml if the generator jar, */cts-device-info/Android.mk, or this file is changed.
39$(manifest_xml): $(MANIFEST_GENERATOR_JAR) $(LOCAL_PATH)/Android.mk cts/build/device_info_package.mk
40	$(hide) echo Generating manifest for $(PRIVATE_NAME)
41	$(hide) mkdir -p $(dir $@)
42	$(hide) $(MANIFEST_GENERATOR) \
43						$(PRIVATE_INFO_PERMISSIONS) \
44						$(PRIVATE_INFO_ACTIVITIES) \
45						-p $(PRIVATE_PACKAGE) \
46						-i $(PRIVATE_INSTRUMENT) \
47						-o $@
48
49# Reset variables
50DEVICE_INFO_PACKAGE :=
51DEVICE_INFO_INSTRUMENT :=
52DEVICE_INFO_PERMISSIONS :=
53DEVICE_INFO_ACTIVITIES :=
54
55LOCAL_FULL_MANIFEST_FILE := $(manifest_xml)
56# Disable by default
57LOCAL_DEX_PREOPT := false
58LOCAL_PROGUARD_ENABLED := disabled
59
60# Don't include this package in any target
61LOCAL_MODULE_TAGS := optional
62# And when built explicitly put it in the data partition
63LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
64
65LOCAL_SDK_VERSION := current
66
67include $(BUILD_CTS_SUPPORT_PACKAGE)
68