1#
2# Copyright (C) 2010 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17LOCAL_PATH:= $(call my-dir)
18# Build CTS verifier framework as a libary.
19
20include $(CLEAR_VARS)
21
22define java-files-in
23$(sort $(patsubst ./%,%, \
24  $(shell cd $(LOCAL_PATH) ; \
25          find -L $(1) -maxdepth 1 -name *.java -and -not -name ".*") \
26 ))
27endef
28
29LOCAL_MODULE := cts-verifier-framework
30LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD SPDX-license-identifier-CC-BY
31LOCAL_LICENSE_CONDITIONS := notice
32LOCAL_AAPT_FLAGS := --auto-add-overlay --extra-packages android.support.v4
33LOCAL_SDK_VERSION := current
34LOCAL_MIN_SDK_VERSION := 19
35LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
36LOCAL_SRC_FILES := \
37    $(call java-files-in, src/com/android/cts/verifier) \
38    $(call all-Iaidl-files-under, src)
39
40LOCAL_STATIC_JAVA_LIBRARIES := androidx.legacy_legacy-support-v4 \
41                               compatibility-common-util-devicesidelib \
42                               compatibility-device-util-axt
43
44# Disable dexpreopt and <uses-library> check for test.
45LOCAL_ENFORCE_USES_LIBRARIES := false
46LOCAL_DEX_PREOPT := false
47
48include $(BUILD_STATIC_JAVA_LIBRARY)
49
50pre-installed-apps := \
51    CtsEmptyDeviceAdmin \
52    CtsEmptyDeviceOwner \
53    CtsPermissionApp \
54    CtsForceStopHelper \
55    NotificationBot \
56    CrossProfileTestApp \
57    CtsTtsEngineSelectorTestHelper \
58    CtsTtsEngineSelectorTestHelper2
59
60# Apps to be installed as Instant App using adb install --instant
61pre-installed-instant-app := CtsVerifierInstantApp
62
63other-required-apps := \
64    CtsVerifierUSBCompanion \
65    CtsVpnFirewallAppApi23 \
66    CtsVpnFirewallAppApi24 \
67    CtsVpnFirewallAppNotAlwaysOn
68
69apps-to-include := \
70    $(pre-installed-apps) \
71    $(pre-installed-instant-app) \
72    $(other-required-apps)
73
74define apk-location-for
75    $(call intermediates-dir-for,APPS,$(1))/package.apk
76endef
77
78# Builds and launches CTS Verifier on a device.
79.PHONY: cts-verifier
80cts-verifier: CtsVerifier adb $(pre-installed-apps) $(pre-installed-instant-app)
81	adb install -r $(PRODUCT_OUT)/data/app/CtsVerifier/CtsVerifier.apk \
82		$(foreach app,$(pre-installed-apps), \
83		    && adb install -r -t $(call apk-location-for,$(app))) \
84		&& adb install -r --instant $(call apk-location-for,$(pre-installed-instant-app)) \
85		&& adb shell "am start -n com.android.cts.verifier/.CtsVerifierActivity"
86
87#
88# Creates a "cts-verifier" directory that will contain:
89#
90# 1. Out directory with a "android-cts-verifier" containing the CTS Verifier
91#    and other binaries it needs.
92#
93# 2. Zipped version of the android-cts-verifier directory to be included with
94#    the build distribution.
95#
96cts-dir := $(HOST_OUT)/cts-verifier
97verifier-dir-name := android-cts-verifier
98verifier-dir := $(cts-dir)/$(verifier-dir-name)
99verifier-zip-name := $(verifier-dir-name).zip
100verifier-zip := $(cts-dir)/$(verifier-zip-name)
101
102# turned off sensor power tests in initial L release
103#$(PRODUCT_OUT)/data/app/CtsVerifier.apk $(verifier-zip): $(verifier-dir)/power/execute_power_tests.py
104#$(PRODUCT_OUT)/data/app/CtsVerifier.apk $(verifier-zip): $(verifier-dir)/power/power_monitors/monsoon.py
105
106# Copy the necessary host-side scripts to include in the zip file:
107#$(verifier-dir)/power/power_monitors/monsoon.py: cts/apps/CtsVerifier/assets/scripts/power_monitors/monsoon.py | $(ACP)
108#	$(hide) mkdir -p $(verifier-dir)/power/power_monitors
109#	$(hide) $(ACP) -fp cts/apps/CtsVerifier/assets/scripts/power_monitors/*.py $(verifier-dir)/power/power_monitors/.
110#
111#$(verifier-dir)/power/execute_power_tests.py: cts/apps/CtsVerifier/assets/scripts/execute_power_tests.py | $(ACP)
112#	$(hide) mkdir -p $(verifier-dir)/power
113#	$(hide) $(ACP) -fp cts/apps/CtsVerifier/assets/scripts/execute_power_tests.py $@
114
115cts : $(verifier-zip)
116$(verifier-zip) : $(HOST_OUT)/CameraITS/build_stamp
117$(verifier-zip) : $(foreach app,$(apps-to-include),$(call apk-location-for,$(app)))
118$(verifier-zip) : $(call intermediates-dir-for,APPS,CtsVerifier)/package.apk | $(ACP)
119		$(hide) mkdir -p $(verifier-dir)
120		$(hide) $(ACP) -fp $< $(verifier-dir)/CtsVerifier.apk
121		$(foreach app,$(apps-to-include), \
122		    $(ACP) -fp $(call apk-location-for,$(app)) $(verifier-dir)/$(app).apk;)
123		$(hide) $(ACP) -fpr $(HOST_OUT)/CameraITS $(verifier-dir)
124		$(hide) cd $(cts-dir) && zip -rq $(verifier-dir-name) $(verifier-dir-name)
125
126$(call dist-for-goals, cts, $(verifier-zip):$(verifier-zip-name))
127
128include $(call all-makefiles-under,$(LOCAL_PATH))
129