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 := androidx.test.runner.AndroidJUnitRunner
21DEVICE_INFO_USES_LIBRARY := android.test.runner
22DEVICE_INFO_PERMISSIONS += \
23  android.permission.READ_PHONE_STATE \
24  android.permission.WRITE_EXTERNAL_STORAGE
25DEVICE_INFO_ACTIVITIES += \
26  $(DEVICE_INFO_PACKAGE).AppStandbyDeviceInfo \
27  $(DEVICE_INFO_PACKAGE).ClientIdDeviceInfo \
28  $(DEVICE_INFO_PACKAGE).ConfigurationDeviceInfo \
29  $(DEVICE_INFO_PACKAGE).CpuDeviceInfo \
30  $(DEVICE_INFO_PACKAGE).FeatureDeviceInfo \
31  $(DEVICE_INFO_PACKAGE).GenericDeviceInfo \
32  $(DEVICE_INFO_PACKAGE).GlesStubActivity \
33  $(DEVICE_INFO_PACKAGE).GraphicsDeviceInfo \
34  $(DEVICE_INFO_PACKAGE).LocaleDeviceInfo \
35  $(DEVICE_INFO_PACKAGE).MediaDeviceInfo \
36  $(DEVICE_INFO_PACKAGE).MemoryDeviceInfo \
37  $(DEVICE_INFO_PACKAGE).PackageDeviceInfo \
38  $(DEVICE_INFO_PACKAGE).PropertyDeviceInfo \
39  $(DEVICE_INFO_PACKAGE).ScreenDeviceInfo \
40  $(DEVICE_INFO_PACKAGE).StorageDeviceInfo \
41  $(DEVICE_INFO_PACKAGE).UserDeviceInfo \
42  $(DEVICE_INFO_PACKAGE).VintfDeviceInfo
43
44ifeq ($(DEVICE_INFO_MIN_SDK),)
45DEVICE_INFO_MIN_SDK := 8
46endif
47
48ifeq ($(DEVICE_INFO_TARGET_SDK),)
49DEVICE_INFO_TARGET_SDK := 17
50endif
51
52# Add the base device info
53LOCAL_STATIC_JAVA_LIBRARIES += compatibility-device-info compatibility-device-util-axt
54
55# Generator of APK manifests.
56MANIFEST_GENERATOR_JAR := $(HOST_OUT_JAVA_LIBRARIES)/compatibility-manifest-generator.jar
57MANIFEST_GENERATOR := $(JAVA) -jar $(MANIFEST_GENERATOR_JAR)
58
59# Generate the manifest
60manifest_xml := $(call intermediates-dir-for,APPS,$(LOCAL_PACKAGE_NAME))/AndroidManifest.xml
61$(manifest_xml): PRIVATE_INFO_PERMISSIONS := $(foreach permission, $(DEVICE_INFO_PERMISSIONS),-r $(permission))
62$(manifest_xml): PRIVATE_INFO_ACTIVITIES := $(foreach activity,$(DEVICE_INFO_ACTIVITIES),-a $(activity))
63$(manifest_xml): PRIVATE_USES_LIBRARY := $(DEVICE_INFO_USES_LIBRARY)
64$(manifest_xml): PRIVATE_PACKAGE := $(DEVICE_INFO_PACKAGE)
65$(manifest_xml): PRIVATE_INSTRUMENT := $(DEVICE_INFO_INSTRUMENT)
66$(manifest_xml): PRIVATE_MIN_SDK := $(DEVICE_INFO_MIN_SDK)
67$(manifest_xml): PRIVATE_TARGET_SDK := $(DEVICE_INFO_TARGET_SDK)
68
69# Regenerate manifest.xml if the generator jar, */cts-device-info/Android.mk, or this file is changed.
70$(manifest_xml): $(MANIFEST_GENERATOR_JAR) $(LOCAL_PATH)/Android.mk cts/build/device_info_package.mk
71	$(hide) echo Generating manifest for $(PRIVATE_NAME)
72	$(hide) mkdir -p $(dir $@)
73	$(hide) $(MANIFEST_GENERATOR) \
74						$(PRIVATE_INFO_PERMISSIONS) \
75						$(PRIVATE_INFO_ACTIVITIES) \
76						-l $(PRIVATE_USES_LIBRARY) \
77						-p $(PRIVATE_PACKAGE) \
78						-i $(PRIVATE_INSTRUMENT) \
79						-s $(PRIVATE_MIN_SDK) \
80						-t $(PRIVATE_TARGET_SDK) \
81						-o $@
82
83# Reset variables
84DEVICE_INFO_MIN_SDK :=
85DEVICE_INFO_TARGET_SDK :=
86DEVICE_INFO_PACKAGE :=
87DEVICE_INFO_INSTRUMENT :=
88DEVICE_INFO_PERMISSIONS :=
89DEVICE_INFO_ACTIVITIES :=
90
91LOCAL_FULL_MANIFEST_FILE := $(manifest_xml)
92# Disable by default
93LOCAL_DEX_PREOPT := false
94LOCAL_PROGUARD_ENABLED := disabled
95
96# Don't include this package in any target
97LOCAL_MODULE_TAGS := optional
98# And when built explicitly put it in the data partition
99LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
100
101
102#TODO(b/72620511) remove this condition when AtsDeviceInfo can be built with SDK again
103ifneq ($(LOCAL_PRIVATE_PLATFORM_APIS),true)
104LOCAL_SDK_VERSION := current
105endif
106
107include $(BUILD_CTS_SUPPORT_PACKAGE)
108