1package {
2    default_applicable_licenses: ["Android-Apache-2.0"],
3}
4
5java_library_static {
6    name: "TestApp_JavaProtos",
7    host_supported: true,
8    proto: {
9        type: "lite",
10    },
11    srcs: ["src/library/main/proto/testapp_protos.proto"]
12}
13
14android_library {
15    name: "TestApp_TestApps",
16    sdk_version: "test_current",
17    srcs: [
18        "src/testapps/main/java/**/*.java"
19    ],
20    static_libs: [
21        "EventLib",
22        "TestApp_Annotations",
23        "ConnectedAppsSDK",
24        "ConnectedAppsSDK_Annotations",
25        "androidx.annotation_annotation",
26        "RemoteFrameworkClasses"
27    ],
28    manifest: "src/testapps/main/AndroidManifest.xml",
29    min_sdk_version: "28",
30    plugins: ["ConnectedAppsSDK_Processor", "TestApp_Processor"],
31}
32
33android_library {
34    name: "TestApp",
35    sdk_version: "test_current",
36    srcs: [
37        "src/library/main/java/**/*.java"
38    ],
39    static_libs: [
40        "Nene",
41        "EventLib",
42        "Queryable",
43        "TestApp_Annotations",
44        "ConnectedAppsSDK",
45        "ConnectedAppsSDK_Annotations",
46        "androidx.annotation_annotation",
47        "TestApp_TestApps",
48        "TestApp_JavaProtos"
49    ],
50    manifest: "src/library/main/AndroidManifest.xml",
51    min_sdk_version: "28",
52    resource_zips: [":TestApp_Apps"],
53    plugins: ["ConnectedAppsSDK_Processor", "TestApp_Processor"],
54}
55
56android_test {
57    name: "TestAppTest",
58    srcs: [
59        "src/test/java/**/*.java"
60    ],
61    test_suites: [
62        "general-tests",
63    ],
64    static_libs: [
65        "Nene",
66        "TestApp",
67        "TestApp_TestApps",
68        "Harrier",
69        "EventLib",
70        "androidx.test.ext.junit",
71        "truth-prebuilt",
72        "testng" // for assertThrows
73    ],
74    manifest: "src/test/AndroidManifest.xml",
75    min_sdk_version: "28"
76}
77
78python_binary_host {
79    name: "index_testapps",
80    version: {
81        py2: {
82            enabled: false,
83            embedded_launcher: false,
84        },
85        py3: {
86            enabled: true,
87            embedded_launcher: true,
88        },
89    },
90    main: "tools/index/index_testapps.py",
91    srcs: [
92        "tools/index/index_testapps.py",
93        "src/library/main/proto/testapp_protos.proto"
94    ],
95    proto: {
96        canonical_path_from_root: false,
97    }
98}
99
100java_genrule {
101    name: "TestApp_Apps",
102    srcs: [":EmptyTestApp", ":EmptyTestApp2", ":DeviceAdminTestApp", ":LockTaskApp", ":DelegateTestApp", ":RemoteDPCTestApp", ":SmsApp", ":AccountManagementApp"],
103    out: ["TestApp_Apps.res.zip"],
104    tools: ["soong_zip", "index_testapps", "aapt2"],
105    cmd: "mkdir -p $(genDir)/res/raw"
106         + " && cp $(location :EmptyTestApp) $(genDir)/res/raw"
107         + " && cp $(location :EmptyTestApp2) $(genDir)/res/raw"
108         + " && cp $(location :DeviceAdminTestApp) $(genDir)/res/raw"
109         + " && cp $(location :LockTaskApp) $(genDir)/res/raw"
110         + " && cp $(location :DelegateTestApp) $(genDir)/res/raw"
111         + " && cp $(location :RemoteDPCTestApp) $(genDir)/res/raw"
112         + " && cp $(location :SmsApp) $(genDir)/res/raw"
113         + " && cp $(location :AccountManagementApp) $(genDir)/res/raw"
114         + " && $(location index_testapps) --directory $(genDir)/res/raw --aapt2 $(location aapt2)"
115         + " && $(location soong_zip) -o $(out) -C $(genDir)/res -D $(genDir)/res/raw"
116}
117
118android_test_helper_app {
119    name: "EmptyTestApp",
120    static_libs: [
121        "TestApp_TestApps"
122    ],
123    manifest: "manifests/EmptyTestAppManifest.xml",
124    min_sdk_version: "28"
125}
126
127android_test_helper_app {
128    name: "EmptyTestApp2",
129    static_libs: [
130        "TestApp_TestApps"
131    ],
132    manifest: "manifests/EmptyTestApp2Manifest.xml",
133    min_sdk_version: "28"
134}
135
136android_test_helper_app {
137    name: "DeviceAdminTestApp",
138    static_libs: [
139        "TestApp_TestApps",
140        "DeviceAdminApp"
141    ],
142    manifest: "manifests/DeviceAdminManifest.xml",
143    min_sdk_version: "28"
144}
145
146android_test_helper_app {
147    name: "LockTaskApp",
148    static_libs: [
149        "TestApp_TestApps"
150    ],
151    manifest: "manifests/LockTaskAppManifest.xml",
152    min_sdk_version: "28"
153}
154
155android_test_helper_app {
156    name: "DelegateTestApp",
157    static_libs: [
158        "TestApp_TestApps"
159    ],
160    manifest: "manifests/DelegateManifest.xml",
161    min_sdk_version: "28"
162}
163
164android_test_helper_app {
165    name: "RemoteDPCTestApp",
166    static_libs: [
167        "TestApp_TestApps",
168        "DeviceAdminApp"
169    ],
170    manifest: "manifests/RemoteDPCManifest.xml",
171    min_sdk_version: "28"
172}
173
174android_test_helper_app {
175    name: "SmsApp",
176    static_libs: [
177        "TestApp_TestApps"
178    ],
179    manifest: "manifests/SmsAppManifest.xml",
180    min_sdk_version: "28"
181}
182
183android_test_helper_app {
184    name: "AccountManagementApp",
185    static_libs: [
186        "TestApp_TestApps"
187    ],
188    resource_dirs: ["src/testapps/main/res/accountmanagement"],
189    manifest: "manifests/AccountManagementManifest.xml",
190    min_sdk_version: "28"
191}
192
193java_library {
194    name: "TestApp_Annotations",
195    srcs: [
196        "src/processor/main/java/com/android/bedstead/testapp/processor/annotations/*.java"
197    ],
198    host_supported: true
199}
200
201java_plugin {
202    name: "TestApp_Processor",
203    processor_class: "com.android.bedstead.testapp.processor.Processor",
204    static_libs: [
205        "javapoet",
206        "auto_service_annotations",
207        "TestApp_Annotations",
208        "ConnectedAppsSDK_Annotations"
209    ],
210    srcs: [
211        "src/processor/main/java/com/android/bedstead/testapp/processor/Processor.java"
212    ],
213    plugins: ["auto_service_plugin"],
214    generates_api: true,
215}
216