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