1// Copyright (C) 2019 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
15package {
16    default_applicable_licenses: ["Android-Apache-2.0"],
17}
18
19java_test_host {
20    name: "CtsStagedInstallHostTestCases",
21    defaults: ["cts_defaults"],
22    srcs:  [
23        "src/**/*.java",
24        ":apex-info-list",
25    ],
26    libs: [
27        "cts-tradefed",
28        "cts-shim-host-lib",
29        "tradefed",
30        "truth-prebuilt",
31        "hamcrest",
32        "hamcrest-library",
33    ],
34    static_libs: ["cts-install-lib-host"],
35    data:   [
36        ":StagedInstallTest",
37        ":deapexer.zip",
38    ],
39    test_suites: [
40        "cts",
41        "general-tests",
42        "mts",
43    ],
44}
45
46android_test_helper_app {
47    name: "StagedInstallTest",
48    srcs:  ["app/src/**/*.java"],
49    manifest : "app/AndroidManifest.xml",
50    java_resources:  [
51        ":ApexKeyRotationTestV2_SignedBob",
52        ":ApexKeyRotationTestV2_SignedBobRot",
53        ":ApexKeyRotationTestV2_SignedBobRotRollback",
54        ":ApexKeyRotationTestV3_SignedBob",
55        ":ApexKeyRotationTestV3_SignedBobRot",
56        ":StagedInstallTestApexV1_NotPreInstalled",
57        ":StagedInstallTestApexV2_AdditionalFile",
58        ":StagedInstallTestApexV2_AdditionalFolder",
59        ":StagedInstallTestApexV2_DifferentCertificate",
60        ":StagedInstallTestApexV2_DifferentPackageName",
61        ":StagedInstallTestApexV2_NoHashtree",
62        ":StagedInstallTestApexV2_WithPostInstallHook",
63        ":StagedInstallTestApexV2_WithPreInstallHook",
64        ":StagedInstallTestApexV2_WrongSha",
65        ":StagedInstallTestApexV2_WithoutApkInApex",
66        ":StagedInstallTestAppSamePackageNameAsApex",
67        ":StagedInstallTestApexV2_SdkTargetP",
68        ":StagedInstallTestApexV2_ApkInApexSdkTargetP",
69        ":StagedInstallTestCorruptedApex_b146895998",
70        ":StagedInstallTestApexV2_NoApkSignature",
71        ":StagedInstallTestApexV2_UnsignedPayload",
72        ":StagedInstallTestApexV2_SignPayloadWithDifferentKey",
73        ":StagedInstallTestApexV2_Rebootless",
74        ":StagedInstallTestApexV3_Rebootless",
75    ],
76    static_libs: [
77        "androidx.test.runner",
78        "androidx.test.core",
79        "truth-prebuilt",
80        "cts-install-lib",
81    ],
82    sdk_version: "test_current",
83    test_suites: ["device-tests"],
84
85}
86
87android_test_helper_app {
88    name: "StagedInstallTestAppSamePackageNameAsApex",
89
90    srcs:   ["testdata/apk/src/**/*java"],
91
92    manifest:   "testdata/apk/StagedInstallTestAppSamePackageNameAsApex.xml",
93}
94
95prebuilt_apex {
96    name: "ApexKeyRotationTestV2_SignedBob",
97    arch: {
98        arm: {
99              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_signed_bob.apex",
100        },
101        arm64: {
102              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_signed_bob.apex",
103        },
104        x86: {
105              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_signed_bob.apex",
106        },
107        x86_64: {
108              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_signed_bob.apex",
109        },
110    },
111    filename: "com.android.apex.cts.shim.v2_signed_bob.apex",
112    installable: false,
113}
114
115prebuilt_apex {
116    name: "ApexKeyRotationTestV2_SignedBobRot",
117    arch: {
118        arm: {
119              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_signed_bob_rot.apex",
120        },
121        arm64: {
122              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_signed_bob_rot.apex",
123        },
124        x86: {
125              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_signed_bob_rot.apex",
126        },
127        x86_64: {
128              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_signed_bob_rot.apex",
129        },
130    },
131    filename: "com.android.apex.cts.shim.v2_signed_bob_rot.apex",
132    installable: false,
133}
134
135prebuilt_apex {
136    name: "ApexKeyRotationTestV2_SignedBobRotRollback",
137    arch: {
138        arm: {
139              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_signed_bob_rot_rollback.apex",
140        },
141        arm64: {
142              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_signed_bob_rot_rollback.apex",
143        },
144        x86: {
145              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_signed_bob_rot_rollback.apex",
146        },
147        x86_64: {
148              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_signed_bob_rot_rollback.apex",
149        },
150    },
151    filename: "com.android.apex.cts.shim.v2_signed_bob_rot_rollback.apex",
152    installable: false,
153}
154
155prebuilt_apex {
156    name: "ApexKeyRotationTestV3_SignedBob",
157    arch: {
158        arm: {
159              src: "testdata/apex/arm/com.android.apex.cts.shim.v3_signed_bob.apex",
160        },
161        arm64: {
162              src: "testdata/apex/arm/com.android.apex.cts.shim.v3_signed_bob.apex",
163        },
164        x86: {
165              src: "testdata/apex/x86/com.android.apex.cts.shim.v3_signed_bob.apex",
166        },
167        x86_64: {
168              src: "testdata/apex/x86/com.android.apex.cts.shim.v3_signed_bob.apex",
169        },
170    },
171    filename: "com.android.apex.cts.shim.v3_signed_bob.apex",
172    installable: false,
173}
174
175prebuilt_apex {
176    name: "ApexKeyRotationTestV3_SignedBobRot",
177    arch: {
178        arm: {
179              src: "testdata/apex/arm/com.android.apex.cts.shim.v3_signed_bob_rot.apex",
180        },
181        arm64: {
182              src: "testdata/apex/arm/com.android.apex.cts.shim.v3_signed_bob_rot.apex",
183        },
184        x86: {
185              src: "testdata/apex/x86/com.android.apex.cts.shim.v3_signed_bob_rot.apex",
186        },
187        x86_64: {
188              src: "testdata/apex/x86/com.android.apex.cts.shim.v3_signed_bob_rot.apex",
189        },
190    },
191    filename: "com.android.apex.cts.shim.v3_signed_bob_rot.apex",
192    installable: false,
193}
194
195prebuilt_apex {
196    name: "StagedInstallTestApexV1",
197    arch: {
198        arm: {
199              src: "testdata/apex/arm/com.android.apex.cts.shim.v1.apex",
200        },
201        arm64: {
202              src: "testdata/apex/arm/com.android.apex.cts.shim.v1.apex",
203        },
204        x86: {
205              src: "testdata/apex/x86/com.android.apex.cts.shim.v1.apex",
206        },
207        x86_64: {
208              src: "testdata/apex/x86/com.android.apex.cts.shim.v1.apex",
209        },
210    },
211    filename: "com.android.apex.cts.shim.v1.apex",
212    installable: false,
213}
214
215prebuilt_apex {
216    name: "StagedInstallTestApexV2",
217    arch: {
218        arm: {
219              src: "testdata/apex/arm/com.android.apex.cts.shim.v2.apex",
220        },
221        arm64: {
222              src: "testdata/apex/arm/com.android.apex.cts.shim.v2.apex",
223        },
224        x86: {
225              src: "testdata/apex/x86/com.android.apex.cts.shim.v2.apex",
226        },
227        x86_64: {
228              src: "testdata/apex/x86/com.android.apex.cts.shim.v2.apex",
229        },
230    },
231    filename: "com.android.apex.cts.shim.v2.apex",
232    installable: false,
233}
234
235prebuilt_apex {
236    name: "StagedInstallTestApexV3",
237    arch: {
238        arm: {
239              src: "testdata/apex/arm/com.android.apex.cts.shim.v3.apex",
240        },
241        arm64: {
242              src: "testdata/apex/arm/com.android.apex.cts.shim.v3.apex",
243        },
244        x86: {
245              src: "testdata/apex/x86/com.android.apex.cts.shim.v3.apex",
246        },
247        x86_64: {
248              src: "testdata/apex/x86/com.android.apex.cts.shim.v3.apex",
249        },
250    },
251    filename: "com.android.apex.cts.shim.v3.apex",
252    installable: false,
253}
254
255prebuilt_apex {
256    name: "StagedInstallTestApexV2_AdditionalFile",
257    arch: {
258        arm: {
259              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_additional_file.apex",
260        },
261        arm64: {
262              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_additional_file.apex",
263        },
264        x86: {
265              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_additional_file.apex",
266        },
267        x86_64: {
268              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_additional_file.apex",
269        },
270    },
271    filename: "com.android.apex.cts.shim.v2_additional_file.apex",
272    installable: false,
273}
274
275prebuilt_apex {
276    name: "StagedInstallTestApexV2_AdditionalFolder",
277    arch: {
278        arm: {
279              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_additional_folder.apex",
280        },
281        arm64: {
282              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_additional_folder.apex",
283        },
284        x86: {
285              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_additional_folder.apex",
286        },
287        x86_64: {
288              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_additional_folder.apex",
289        },
290    },
291    filename: "com.android.apex.cts.shim.v2_additional_folder.apex",
292    installable: false,
293}
294
295prebuilt_apex {
296    name: "StagedInstallTestApexV2_WithPostInstallHook",
297    arch: {
298        arm: {
299              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_with_post_install_hook.apex",
300        },
301        arm64: {
302              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_with_post_install_hook.apex",
303        },
304        x86: {
305              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_with_post_install_hook.apex",
306        },
307        x86_64: {
308              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_with_post_install_hook.apex",
309        },
310    },
311    filename: "com.android.apex.cts.shim.v2_with_post_install_hook.apex",
312    installable: false,
313}
314
315prebuilt_apex {
316    name: "StagedInstallTestApexV2_WithPreInstallHook",
317    arch: {
318        arm: {
319              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_with_pre_install_hook.apex",
320        },
321        arm64: {
322              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_with_pre_install_hook.apex",
323        },
324        x86: {
325              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_with_pre_install_hook.apex",
326        },
327        x86_64: {
328              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_with_pre_install_hook.apex",
329        },
330    },
331    filename: "com.android.apex.cts.shim.v2_with_pre_install_hook.apex",
332    installable: false,
333}
334
335prebuilt_apex {
336    name: "StagedInstallTestApexV2_WrongSha",
337    arch: {
338        arm: {
339              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_wrong_sha.apex",
340        },
341        arm64: {
342              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_wrong_sha.apex",
343        },
344        x86: {
345              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_wrong_sha.apex",
346        },
347        x86_64: {
348              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_wrong_sha.apex",
349        },
350    },
351    filename: "com.android.apex.cts.shim.v2_wrong_sha.apex",
352    installable: false,
353}
354
355prebuilt_apex {
356    name: "StagedInstallTestApexV2_WithoutApkInApex",
357    arch: {
358        arm: {
359              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_without_apk_in_apex.apex",
360        },
361        arm64: {
362              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_without_apk_in_apex.apex",
363        },
364        x86: {
365              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_without_apk_in_apex.apex",
366        },
367        x86_64: {
368              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_without_apk_in_apex.apex",
369        },
370    },
371    filename: "com.android.apex.cts.shim.v2_without_apk_in_apex.apex",
372    installable: false,
373}
374
375prebuilt_apex {
376    name: "StagedInstallTestApexV1_NotPreInstalled",
377    arch: {
378        arm: {
379              src: "testdata/apex/arm/com.android.apex.cts.shim_not_pre_installed.apex",
380        },
381        arm64: {
382              src: "testdata/apex/arm/com.android.apex.cts.shim_not_pre_installed.apex",
383        },
384        x86: {
385              src: "testdata/apex/x86/com.android.apex.cts.shim_not_pre_installed.apex",
386        },
387        x86_64: {
388              src: "testdata/apex/x86/com.android.apex.cts.shim_not_pre_installed.apex",
389        },
390    },
391    filename: "com.android.apex.cts.shim_not_pre_installed.apex",
392    installable: false,
393}
394
395prebuilt_apex {
396    name: "StagedInstallTestApexV2_DifferentCertificate",
397    arch: {
398        arm: {
399              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_different_certificate.apex",
400        },
401        arm64: {
402              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_different_certificate.apex",
403        },
404        x86: {
405              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_different_certificate.apex",
406        },
407        x86_64: {
408              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_different_certificate.apex",
409        },
410    },
411    filename: "com.android.apex.cts.shim.v2_different_certificate.apex",
412    installable: false,
413}
414
415prebuilt_apex {
416    name: "StagedInstallTestApexV2_DifferentPackageName",
417    arch: {
418        arm: {
419              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_different_package_name.apex",
420        },
421        arm64: {
422              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_different_package_name.apex",
423        },
424        x86: {
425              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_different_package_name.apex",
426        },
427        x86_64: {
428              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_different_package_name.apex",
429        },
430    },
431    filename: "com.android.apex.cts.shim.v2_different_package_name.apex",
432    installable: false,
433}
434
435prebuilt_apex {
436    name: "StagedInstallTestApexV2_NoHashtree",
437    arch: {
438        arm: {
439              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_no_hashtree.apex",
440        },
441        arm64: {
442              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_no_hashtree.apex",
443        },
444        x86: {
445              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_no_hashtree.apex",
446        },
447        x86_64: {
448              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_no_hashtree.apex",
449        },
450    },
451    filename: "com.android.apex.cts.shim.v2_no_hashtree.apex",
452    installable: false,
453}
454
455prebuilt_apex {
456  name: "StagedInstallTestApexV2_SdkTargetP",
457  arch: {
458        arm: {
459              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_sdk_target_p.apex",
460        },
461        arm64: {
462              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_sdk_target_p.apex",
463        },
464        x86: {
465              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_sdk_target_p.apex",
466        },
467        x86_64: {
468              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_sdk_target_p.apex",
469        },
470    },
471  filename: "com.android.apex.cts.shim.v2_sdk_target_p.apex",
472  installable: false,
473}
474
475prebuilt_apex {
476  name: "StagedInstallTestApexV2_ApkInApexSdkTargetP",
477  arch: {
478        arm: {
479              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_apk_in_apex_sdk_target_p.apex",
480        },
481        arm64: {
482              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_apk_in_apex_sdk_target_p.apex",
483        },
484        x86: {
485              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_apk_in_apex_sdk_target_p.apex",
486        },
487        x86_64: {
488              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_apk_in_apex_sdk_target_p.apex",
489        },
490    },
491  filename: "com.android.apex.cts.shim.v2_apk_in_apex_sdk_target_p.apex",
492  installable: false,
493}
494
495prebuilt_apex {
496  name: "StagedInstallTestCorruptedApex_b146895998",
497  src: "testdata/apex/corrupted_b146895998.apex",
498  filename: "corrupted_b146895998.apex",
499  installable: false,
500}
501
502prebuilt_apex {
503  name: "StagedInstallTestApexV2_NoApkSignature",
504  arch: {
505        arm: {
506              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_unsigned_apk_container.apex",
507        },
508        arm64: {
509              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_unsigned_apk_container.apex",
510        },
511        x86: {
512              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_unsigned_apk_container.apex",
513        },
514        x86_64: {
515              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_unsigned_apk_container.apex",
516        },
517    },
518  filename: "com.android.apex.cts.shim.v2_unsigned_apk_container.apex",
519  installable: false,
520}
521
522prebuilt_apex {
523  name: "StagedInstallTestApexV2_UnsignedPayload",
524  arch: {
525        arm: {
526              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_unsigned_payload.apex",
527        },
528        arm64: {
529              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_unsigned_payload.apex",
530        },
531        x86: {
532              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_unsigned_payload.apex",
533        },
534        x86_64: {
535              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_unsigned_payload.apex",
536        },
537    },
538  filename: "com.android.apex.cts.shim.v2_unsigned_payload.apex",
539  installable: false,
540}
541
542ApexFilenameSigningPayloadWithDifferentKey =
543  "com.android.apex.cts.shim.v2_sign_payload_with_different_key.apex"
544prebuilt_apex {
545  name: "StagedInstallTestApexV2_SignPayloadWithDifferentKey",
546  arch: {
547        arm: {
548              src: "testdata/apex/arm/" + ApexFilenameSigningPayloadWithDifferentKey,
549        },
550        arm64: {
551              src: "testdata/apex/arm/" + ApexFilenameSigningPayloadWithDifferentKey,
552        },
553        x86: {
554              src: "testdata/apex/x86/" + ApexFilenameSigningPayloadWithDifferentKey,
555        },
556        x86_64: {
557              src: "testdata/apex/x86/" + ApexFilenameSigningPayloadWithDifferentKey,
558        },
559    },
560  filename: ApexFilenameSigningPayloadWithDifferentKey,
561  installable: false,
562}
563
564prebuilt_apex {
565  name: "StagedInstallTestApexV2_Rebootless",
566  arch: {
567        arm: {
568              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_rebootless.apex",
569        },
570        arm64: {
571              src: "testdata/apex/arm/com.android.apex.cts.shim.v2_rebootless.apex",
572        },
573        x86: {
574              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_rebootless.apex",
575        },
576        x86_64: {
577              src: "testdata/apex/x86/com.android.apex.cts.shim.v2_rebootless.apex",
578        },
579    },
580  filename: "com.android.apex.cts.shim.v2_rebootless.apex",
581  installable: false,
582}
583
584prebuilt_apex {
585  name: "StagedInstallTestApexV3_Rebootless",
586  arch: {
587        arm: {
588              src: "testdata/apex/arm/com.android.apex.cts.shim.v3_rebootless.apex",
589        },
590        arm64: {
591              src: "testdata/apex/arm/com.android.apex.cts.shim.v3_rebootless.apex",
592        },
593        x86: {
594              src: "testdata/apex/x86/com.android.apex.cts.shim.v3_rebootless.apex",
595        },
596        x86_64: {
597              src: "testdata/apex/x86/com.android.apex.cts.shim.v3_rebootless.apex",
598        },
599    },
600  filename: "com.android.apex.cts.shim.v3_rebootless.apex",
601  installable: false,
602}
603
604// collects deapexer and its dependency modules (libc++ and debugfs_static) to the zip file.
605genrule {
606  name: "deapexer.zip",
607  tools: [
608      "deapexer",
609      "debugfs_static",
610      "soong_zip",
611  ],
612  cmd: "rm -rf mkdir $(genDir)/deapexer && mkdir $(genDir)/deapexer && " +
613       "cp $(location deapexer) $(genDir)/deapexer && " +
614       "cp $(location debugfs_static) $(genDir)/deapexer && " +
615       "HOST_OUT_SHARED_LIBRARIES=$$(dirname $(location deapexer))/../lib64 && " +
616       "cp $${HOST_OUT_SHARED_LIBRARIES}/libc++.* $(genDir)/deapexer && " +
617       "$(location soong_zip) -o $(out) -C $(genDir)/deapexer -D $(genDir)/deapexer",
618  out: ["deapexer.zip"],
619}
620