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)
18include $(CLEAR_VARS)
19
20LOCAL_MODULE_TAGS := optional
21
22LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
23
24LOCAL_MULTILIB := both
25
26LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-Iaidl-files-under, src)
27
28LOCAL_AIDL_INCLUDES := \
29    frameworks/native/aidl/gui
30
31LOCAL_USE_AAPT2 := true
32
33LOCAL_STATIC_JAVA_LIBRARIES := android-ex-camera2 \
34                               compatibility-common-util-devicesidelib \
35                               cts-sensors-tests \
36                               cts-location-tests \
37                               ctstestrunner \
38                               apache-commons-math \
39                               androidplot \
40                               ctsverifier-opencv \
41                               core-tests-support \
42                               androidx.legacy_legacy-support-v4  \
43                               mockito-target-minus-junit4 \
44                               mockwebserver \
45                               compatibility-device-util \
46                               platform-test-annotations \
47                               cts-security-test-support-library
48
49LOCAL_STATIC_ANDROID_LIBRARIES := \
50    androidx.legacy_legacy-support-v4
51
52LOCAL_JAVA_LIBRARIES += telephony-common
53LOCAL_JAVA_LIBRARIES += android.test.runner.stubs
54LOCAL_JAVA_LIBRARIES += android.test.base.stubs
55LOCAL_JAVA_LIBRARIES += android.test.mock.stubs
56LOCAL_JAVA_LIBRARIES += bouncycastle
57LOCAL_JAVA_LIBRARIES += voip-common
58
59LOCAL_PACKAGE_NAME := CtsVerifier
60LOCAL_PRIVATE_PLATFORM_APIS := true
61
62LOCAL_JNI_SHARED_LIBRARIES := libctsverifier_jni \
63		libaudioloopback_jni \
64
65LOCAL_PROGUARD_FLAG_FILES := proguard.flags
66
67LOCAL_DEX_PREOPT := false
68-include cts/error_prone_rules_tests.mk
69include $(BUILD_PACKAGE)
70
71# Build CTS verifier framework as a libary.
72
73include $(CLEAR_VARS)
74
75define java-files-in
76$(sort $(patsubst ./%,%, \
77  $(shell cd $(LOCAL_PATH) ; \
78          find -L $(1) -maxdepth 1 -name *.java -and -not -name ".*") \
79 ))
80endef
81
82LOCAL_MODULE := cts-verifier-framework
83LOCAL_AAPT_FLAGS := --auto-add-overlay --extra-packages android.support.v4
84LOCAL_SDK_VERSION := current
85LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
86LOCAL_SRC_FILES := \
87    $(call java-files-in, src/com/android/cts/verifier) \
88    $(call all-Iaidl-files-under, src)
89
90LOCAL_STATIC_JAVA_LIBRARIES := androidx.legacy_legacy-support-v4 \
91                               compatibility-common-util-devicesidelib \
92                               compatibility-device-util \
93
94include $(BUILD_STATIC_JAVA_LIBRARY)
95
96# opencv library
97include $(CLEAR_VARS)
98
99LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \
100        ctsverifier-opencv:libs/opencv3-android.jar
101
102include $(BUILD_MULTI_PREBUILT)
103
104pre-installed-apps := \
105    CtsEmptyDeviceAdmin \
106    CtsEmptyDeviceOwner \
107    CtsPermissionApp \
108    NotificationBot
109
110other-required-apps := \
111    CtsVerifierUSBCompanion \
112    CtsVpnFirewallAppApi23 \
113    CtsVpnFirewallAppApi24 \
114    CtsVpnFirewallAppNotAlwaysOn
115
116apps-to-include := \
117    $(pre-installed-apps) \
118    $(other-required-apps)
119
120define apk-location-for
121    $(call intermediates-dir-for,APPS,$(1))/package.apk
122endef
123
124# Builds and launches CTS Verifier on a device.
125.PHONY: cts-verifier
126cts-verifier: CtsVerifier adb $(pre-installed-apps)
127	adb install -r $(PRODUCT_OUT)/data/app/CtsVerifier/CtsVerifier.apk \
128		$(foreach app,$(pre-installed-apps), \
129		    && adb install -r -t $(call apk-location-for,$(app))) \
130		&& adb shell "am start -n com.android.cts.verifier/.CtsVerifierActivity"
131
132#
133# Creates a "cts-verifier" directory that will contain:
134#
135# 1. Out directory with a "android-cts-verifier" containing the CTS Verifier
136#    and other binaries it needs.
137#
138# 2. Zipped version of the android-cts-verifier directory to be included with
139#    the build distribution.
140#
141cts-dir := $(HOST_OUT)/cts-verifier
142verifier-dir-name := android-cts-verifier
143verifier-dir := $(cts-dir)/$(verifier-dir-name)
144verifier-zip-name := $(verifier-dir-name).zip
145verifier-zip := $(cts-dir)/$(verifier-zip-name)
146
147# turned off sensor power tests in initial L release
148#$(PRODUCT_OUT)/data/app/CtsVerifier.apk $(verifier-zip): $(verifier-dir)/power/execute_power_tests.py
149#$(PRODUCT_OUT)/data/app/CtsVerifier.apk $(verifier-zip): $(verifier-dir)/power/power_monitors/monsoon.py
150
151# Copy the necessary host-side scripts to include in the zip file:
152#$(verifier-dir)/power/power_monitors/monsoon.py: cts/apps/CtsVerifier/assets/scripts/power_monitors/monsoon.py | $(ACP)
153#	$(hide) mkdir -p $(verifier-dir)/power/power_monitors
154#	$(hide) $(ACP) -fp cts/apps/CtsVerifier/assets/scripts/power_monitors/*.py $(verifier-dir)/power/power_monitors/.
155#
156#$(verifier-dir)/power/execute_power_tests.py: cts/apps/CtsVerifier/assets/scripts/execute_power_tests.py | $(ACP)
157#	$(hide) mkdir -p $(verifier-dir)/power
158#	$(hide) $(ACP) -fp cts/apps/CtsVerifier/assets/scripts/execute_power_tests.py $@
159
160cts : $(verifier-zip)
161$(verifier-zip) : $(HOST_OUT)/CameraITS
162$(verifier-zip) : $(foreach app,$(apps-to-include),$(call apk-location-for,$(app)))
163$(verifier-zip) : $(call intermediates-dir-for,APPS,CtsVerifier)/package.apk | $(ACP)
164		$(hide) mkdir -p $(verifier-dir)
165		$(hide) $(ACP) -fp $< $(verifier-dir)/CtsVerifier.apk
166		$(foreach app,$(apps-to-include), \
167		    $(ACP) -fp $(call apk-location-for,$(app)) $(verifier-dir)/$(app).apk;)
168		$(hide) $(ACP) -fpr $(HOST_OUT)/CameraITS $(verifier-dir)
169		$(hide) cd $(cts-dir) && zip -rq $(verifier-dir-name) $(verifier-dir-name)
170
171$(call dist-for-goals, cts, $(verifier-zip):$(verifier-zip-name))
172
173include $(call all-makefiles-under,$(LOCAL_PATH))
174