• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (C) 2018 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
15// These apex definitions will generate the prebuilt test data. The modules
16// are disabled so as not to pollute the build.
17
18package {
19    default_applicable_licenses: ["Android-Apache-2.0"],
20}
21
22apex_key {
23    name: "com.android.apex.test_package.key",
24    public_key: "com.android.apex.test_package.avbpubkey",
25    private_key: "com.android.apex.test_package.pem",
26    installable: false,
27}
28
29apex_key {
30    name: "com.android.apex.compressed.key",
31    public_key: "com.android.apex.compressed.avbpubkey",
32    private_key: "com.android.apex.compressed.pem",
33    installable: false,
34}
35
36apex {
37    name: "apex.apexd_test",
38    manifest: "manifest.json",
39    file_contexts: ":apex.test-file_contexts",
40    prebuilts: ["sample_prebuilt_file"],
41    key: "com.android.apex.test_package.key",
42    installable: false,
43    min_sdk_version: "29", // test requires hashtree to be present.
44}
45
46apex {
47    name: "com.android.apex.compressed.v1",
48    manifest: "manifest_compressed.json",
49    file_contexts: ":apex.test-file_contexts",
50    prebuilts: ["sample_prebuilt_file"],
51    key: "com.android.apex.compressed.key",
52    installable: false,
53    test_only_force_compression: true,
54    updatable: false,
55}
56
57apex {
58    name: "com.android.apex.compressed.v1_different_digest",
59    manifest: "manifest_compressed.json",
60    file_contexts: ":apex.test-file_contexts",
61    prebuilts: ["hash_of_dev_null"],
62    key: "com.android.apex.compressed.key",
63    installable: false,
64    test_only_force_compression: true,
65    updatable: false,
66}
67
68genrule {
69    // Generates an apex which has a different public key outside the filesystem image
70    name: "gen_key_mismatch_with_image_apex",
71    out: ["apex.apexd_test_wrong_public_key.apex"],
72    srcs: [":apex.apexd_test"],
73    tools: [
74        "soong_zip",
75        "zipalign",
76    ],
77    cmd: "unzip -q $(in) -d $(genDir) && " + // unzip input
78        "echo 'different-key' >> $(genDir)/apex_pubkey && " + // modify the public key
79        "$(location soong_zip) -d -C $(genDir) -D $(genDir) " +
80        "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " +
81        "-o $(genDir)/unaligned.apex && " +
82        "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " +
83        "$(genDir)/apex.apexd_test_wrong_public_key.apex",
84}
85
86genrule {
87    // Generates a compressed apex which doesn't have an original_apex file in it
88    name: "gen_capex_without_apex",
89    out: ["com.android.apex.compressed.v1_without_apex.capex"],
90    srcs: [":com.android.apex.compressed.v1"],
91    tools: ["soong_zip"],
92    cmd: "unzip -q $(in) -d $(genDir) && rm $(genDir)/original_apex && " +
93        "$(location soong_zip) -d -C $(genDir) -D $(genDir) -L 9 " +
94        "-o $(genDir)/com.android.apex.compressed.v1_without_apex.capex",
95}
96
97genrule {
98    // Generates a compressed apex which has different version of original_apex in it
99    name: "gen_capex_with_v2_apex",
100    out: ["com.android.apex.compressed.v1_with_v2_apex.capex"],
101    srcs: [":com.android.apex.compressed.v2"],
102    tools: [
103        "soong_zip",
104        "conv_apex_manifest",
105    ],
106    cmd: "unzip -q $(in) -d $(genDir) && " +
107        "$(location conv_apex_manifest) setprop version 1 $(genDir)/apex_manifest.pb && " +
108        "$(location soong_zip) -d -C $(genDir) -D $(genDir) -L 9 " +
109        "-o $(genDir)/com.android.apex.compressed.v1_with_v2_apex.capex",
110}
111
112genrule {
113    // Generates a compressed apex which can be opened but not decompressed
114    name: "gen_capex_not_decompressible",
115    out: ["com.android.apex.compressed.v1_not_decompressible.capex"],
116    srcs: [":com.android.apex.compressed.v1"],
117    tools: [
118        "soong_zip",
119        "conv_apex_manifest",
120    ],
121    cmd: "unzip -q $(in) -d $(genDir) && echo '' > $(genDir)/original_apex && " +
122        "$(location soong_zip) -d -C $(genDir) -D $(genDir) -L 9 " +
123        "-o $(genDir)/com.android.apex.compressed.v1_not_decompressible.capex",
124}
125
126genrule {
127    // Generates a capex which has same module name as com.android.apex.compressed, but
128    // is contains a different public key.
129    name: "gen_key_mismatch_capex",
130    out: ["com.android.apex.compressed_different_key.capex"],
131    srcs: [":apex.apexd_test_no_inst_key"],
132    tools: [
133        "soong_zip",
134        "zipalign",
135        "conv_apex_manifest",
136        "apex_compression_tool",
137        "avbtool",
138    ],
139    cmd: "mkdir $(genDir)/tempdir && unzip -q $(in) -d $(genDir)/tempdir && " +
140        "$(location conv_apex_manifest) setprop name com.android.apex.compressed $(genDir)/tempdir/apex_manifest.pb && " +
141        "$(location soong_zip) -d -C $(genDir)/tempdir -D $(genDir)/tempdir " +
142        "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " +
143        "-o $(genDir)/unaligned.apex && " +
144        "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " +
145        "$(genDir)/com.android.apex.compressed_different_key.apex && " +
146        "HOST_OUT_BIN=$$(dirname $(location apex_compression_tool)) && " +
147        "$(location apex_compression_tool) compress " +
148        "--apex_compression_tool_path=\"$$HOST_OUT_BIN\" " +
149        "--input=$(genDir)/com.android.apex.compressed_different_key.apex " +
150        "--output=$(genDir)/com.android.apex.compressed_different_key.capex",
151}
152
153genrule {
154    // Generates a capex which has a different public key than original_apex
155    name: "gen_key_mismatch_with_original_capex",
156    out: ["com.android.apex.compressed_key_mismatch_with_original.capex"],
157    srcs: [":com.android.apex.compressed.v1"],
158    tools: ["soong_zip"],
159    cmd: "unzip -q $(in) -d $(genDir) && " + // unzip input
160        "echo 'different-key' >> $(genDir)/apex_pubkey && " + // modify the public key
161        "$(location soong_zip) -d -C $(genDir) -D $(genDir) -L 9 " + // repack the compressed APEX
162        "-o $(genDir)/com.android.apex.compressed_key_mismatch_with_original.capex",
163}
164
165genrule {
166    // Generates an apex which has a different manifest outside the filesystem
167    // image.
168    name: "gen_manifest_mismatch_compressed_apex_v2",
169    out: ["com.android.apex.compressed.v2_manifest_mismatch.apex"],
170    srcs: [":com.android.apex.compressed.v2_original"],
171    tools: [
172        "soong_zip",
173        "zipalign",
174        "conv_apex_manifest",
175    ],
176    cmd: "unzip -q $(in) -d $(genDir) && " +
177        "$(location conv_apex_manifest) setprop version 137 $(genDir)/apex_manifest.pb && " +
178        "$(location soong_zip) -d -C $(genDir) -D $(genDir) " +
179        "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " +
180        "-o $(genDir)/unaligned.apex && " +
181        "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " +
182        "$(genDir)/com.android.apex.compressed.v2_manifest_mismatch.apex",
183}
184
185apex {
186    name: "com.android.apex.compressed.v1_different_digest_original",
187    manifest: "manifest_compressed.json",
188    file_contexts: ":apex.test-file_contexts",
189    prebuilts: ["hash_of_dev_null"],
190    key: "com.android.apex.compressed.key",
191    installable: false,
192    compressible: false,
193    updatable: false,
194}
195
196apex {
197    name: "com.android.apex.compressed.v2",
198    manifest: "manifest_compressed_v2.json",
199    file_contexts: ":apex.test-file_contexts",
200    prebuilts: ["sample_prebuilt_file"],
201    key: "com.android.apex.compressed.key",
202    installable: false,
203    test_only_force_compression: true,
204    updatable: false,
205}
206
207apex {
208    name: "com.android.apex.compressed.v2_original",
209    manifest: "manifest_compressed_v2.json",
210    file_contexts: ":apex.test-file_contexts",
211    prebuilts: ["sample_prebuilt_file"],
212    key: "com.android.apex.compressed.key",
213    installable: false,
214    compressible: false,
215    updatable: false,
216}
217
218apex {
219    name: "apex.apexd_test_f2fs",
220    manifest: "manifest.json",
221    file_contexts: ":apex.test-file_contexts",
222    prebuilts: ["sample_prebuilt_file"],
223    key: "com.android.apex.test_package.key",
224    installable: false,
225    min_sdk_version: "current",
226    payload_fs_type: "f2fs",
227    updatable: false,
228}
229
230apex {
231    name: "apex.apexd_test_erofs",
232    manifest: "manifest.json",
233    file_contexts: ":apex.test-file_contexts",
234    prebuilts: ["sample_prebuilt_file"],
235    key: "com.android.apex.test_package.key",
236    installable: false,
237    min_sdk_version: "current",
238    payload_fs_type: "erofs",
239    updatable: false,
240}
241
242apex {
243    name: "apex.apexd_test_no_hashtree",
244    manifest: "manifest.json",
245    file_contexts: ":apex.test-file_contexts",
246    prebuilts: ["sample_prebuilt_file"],
247    key: "com.android.apex.test_package.key",
248    installable: false,
249    generate_hashtree: false,
250    updatable: false,
251}
252
253// This APEX has same name and version as apex.apexd_test_no_hashtree, but has
254// different content. It's used to test that staging a same version of already
255// active APEX without hashtree doesn't impact already active one.
256apex {
257    name: "apex.apexd_test_no_hashtree_2",
258    manifest: "manifest.json",
259    file_contexts: ":apex.test-file_contexts",
260    prebuilts: [
261        "another_prebuilt_file",
262        "sample_prebuilt_file",
263    ],
264    key: "com.android.apex.test_package.key",
265    installable: false,
266    generate_hashtree: false,
267    updatable: false,
268}
269
270apex {
271    name: "apex.apexd_test_v2",
272    manifest: "manifest_v2.json",
273    file_contexts: ":apex.test-file_contexts",
274    prebuilts: ["sample_prebuilt_file"],
275    key: "com.android.apex.test_package.key",
276    installable: false,
277    updatable: false,
278}
279
280apex {
281    name: "apex.apexd_test_v2_legacy",
282    manifest: "manifest_v2.json",
283    file_contexts: ":apex.test-file_contexts",
284    prebuilts: ["sample_prebuilt_file"],
285    key: "com.android.apex.test_package.key",
286    installable: false,
287    min_sdk_version: "29", // add apex_manifest.json as well
288}
289
290genrule {
291    name: "apex.apexd_test_v2_no_pb",
292    srcs: [":apex.apexd_test_v2_legacy"],
293    out: ["apex.apexd_test_v2_no_pb.apex"],
294    tools: ["zip2zip"],
295    cmd: "$(location zip2zip) -i $(in) -x apex_manifest.pb -o $(out)", // remove apex_manifest.pb
296}
297
298apex {
299    name: "apex.apexd_test_v3",
300    manifest: "manifest_v3.json",
301    file_contexts: ":apex.test-file_contexts",
302    prebuilts: ["sample_prebuilt_file"],
303    key: "com.android.apex.test_package.key",
304    installable: false,
305    updatable: false,
306}
307
308apex_key {
309    name: "com.android.apex.test_package.no_inst_key.key",
310    public_key: "com.android.apex.test_package.no_inst_key.avbpubkey",
311    private_key: "com.android.apex.test_package.no_inst_key.pem",
312    installable: true, // set to true to prevent bundling into the APEX
313}
314
315apex {
316    name: "apex.apexd_test_no_inst_key",
317    manifest: "manifest_no_inst_key.json",
318    file_contexts: ":apex.test-file_contexts",
319    prebuilts: ["sample_prebuilt_file"],
320    key: "com.android.apex.test_package.no_inst_key.key",
321    installable: false,
322    updatable: false,
323}
324
325apex {
326    name: "apex.apexd_test_f2fs_no_inst_key",
327    manifest: "manifest_no_inst_key.json",
328    file_contexts: ":apex.test-file_contexts",
329    prebuilts: ["sample_prebuilt_file"],
330    key: "com.android.apex.test_package.no_inst_key.key",
331    installable: false,
332    payload_fs_type: "f2fs",
333    updatable: false,
334}
335
336apex {
337    name: "apex.apexd_test_erofs_no_inst_key",
338    manifest: "manifest_no_inst_key.json",
339    file_contexts: ":apex.test-file_contexts",
340    prebuilts: ["sample_prebuilt_file"],
341    key: "com.android.apex.test_package.no_inst_key.key",
342    installable: false,
343    payload_fs_type: "erofs",
344    updatable: false,
345}
346
347apex_key {
348    name: "com.android.apex.test_package_2.key",
349    public_key: "com.android.apex.test_package_2.avbpubkey",
350    private_key: "com.android.apex.test_package_2.pem",
351    installable: false,
352}
353
354apex {
355    name: "apex.apexd_test_different_app",
356    manifest: "manifest_different_app.json",
357    file_contexts: ":apex.test-file_contexts",
358    prebuilts: ["sample_prebuilt_file"],
359    key: "com.android.apex.test_package_2.key",
360    installable: false,
361    updatable: false,
362}
363
364apex {
365    name: "apex.apexd_test_nocode",
366    manifest: "manifest_nocode.json",
367    file_contexts: ":apex.test-file_contexts",
368    prebuilts: ["sample_prebuilt_file"],
369    key: "com.android.apex.test_package.key",
370    installable: false,
371    updatable: false,
372}
373
374prebuilt_etc {
375    name: "another_prebuilt_file",
376    src: "another_prebuilt_file",
377}
378
379prebuilt_apex {
380    name: "apex.corrupted_b146895998",
381    src: "corrupted_b146895998.apex",
382    filename: "corrupted_b146895998.apex",
383    installable: false,
384}
385
386// APEX for banned name test cannot be generated at build time.
387// This file can be generated manually by creating new apex target
388// with manifest name 'sharedlibs', and modify aapt2 to skip validating
389// package name from aapt::util::IsAndroidPackageName().
390prebuilt_apex {
391    name: "apex.banned_name",
392    src: "sharedlibs.apex",
393    filename: "sharedlibs.apex",
394    installable: false,
395}
396
397// A compressed apex that also provides shared libs.
398// Should be declined by ApexFile::Open.
399apex {
400    name: "com.android.apex.compressed_sharedlibs",
401    manifest: "manifest_compressed_sharedlibs.json",
402    file_contexts: ":apex.test-file_contexts",
403    prebuilts: ["sample_prebuilt_file"],
404    key: "com.android.apex.compressed.key",
405    installable: false,
406    test_only_force_compression: true,
407    updatable: false,
408}
409
410apex {
411    name: "test.rebootless_apex_v1",
412    manifest: "manifest_rebootless.json",
413    file_contexts: ":apex.test-file_contexts",
414    key: "com.android.apex.test_package.key",
415    installable: false,
416    updatable: false,
417    // TODO(ioffe): we should have a separate field to hashtree presence.
418    min_sdk_version: "29", // test requires hashtree to be present.
419}
420
421apex {
422    name: "test.rebootless_apex_v2",
423    manifest: "manifest_rebootless_v2.json",
424    file_contexts: ":apex.test-file_contexts",
425    key: "com.android.apex.test_package.key",
426    installable: false,
427    updatable: false,
428    // TODO(ioffe): we should have a separate field to hashtree presence.
429    min_sdk_version: "29", // test requires hashtree to be present.
430}
431
432apex {
433    name: "test.rebootless_apex_service_v1",
434    manifest: "manifest_rebootless.json",
435    init_rc: ["test_apex_service.rc"],
436    file_contexts: ":apex.test-file_contexts",
437    key: "com.android.apex.test_package.key",
438    installable: false,
439    updatable: false,
440}
441
442apex {
443    name: "test.rebootless_apex_service_v2",
444    manifest: "manifest_rebootless_v2.json",
445    init_rc: ["test_apex_service.rc"],
446    file_contexts: ":apex.test-file_contexts",
447    key: "com.android.apex.test_package.key",
448    installable: false,
449    updatable: false,
450}
451
452apex {
453    name: "test.rebootless_apex_v2_no_hashtree",
454    manifest: "manifest_rebootless_v2.json",
455    file_contexts: ":apex.test-file_contexts",
456    key: "com.android.apex.test_package.key",
457    installable: false,
458    updatable: false,
459    generate_hashtree: false,
460}
461
462apex {
463    name: "test.rebootless_apex_provides_sharedlibs",
464    manifest: "manifest_rebootless_provides_sharedlibs.json",
465    file_contexts: ":apex.test-file_contexts",
466    key: "com.android.apex.test_package.key",
467    installable: false,
468    updatable: false,
469}
470
471apex {
472    name: "test.rebootless_apex_provides_native_libs",
473    manifest: "manifest_rebootless_provides_native_libs.json",
474    file_contexts: ":apex.test-file_contexts",
475    key: "com.android.apex.test_package.key",
476    installable: false,
477    updatable: false,
478}
479
480apex {
481    name: "test.rebootless_apex_requires_shared_apex_libs",
482    manifest: "manifest_rebootless_requires_shared_apex_libs.json",
483    file_contexts: ":apex.test-file_contexts",
484    key: "com.android.apex.test_package.key",
485    installable: false,
486    updatable: false,
487}
488
489apex {
490    name: "test.rebootless_apex_jni_libs",
491    manifest: "manifest_rebootless_jni_libs.json",
492    file_contexts: ":apex.test-file_contexts",
493    key: "com.android.apex.test_package.key",
494    installable: false,
495    updatable: false,
496}
497
498apex {
499    name: "test.rebootless_apex_add_native_lib",
500    manifest: "manifest_rebootless_add_native_lib.json",
501    file_contexts: ":apex.test-file_contexts",
502    key: "com.android.apex.test_package.key",
503    installable: false,
504    updatable: false,
505}
506
507apex {
508    name: "test.rebootless_apex_remove_native_lib",
509    manifest: "manifest_rebootless_remove_native_lib.json",
510    file_contexts: ":apex.test-file_contexts",
511    key: "com.android.apex.test_package.key",
512    installable: false,
513    updatable: false,
514}
515
516apex {
517    name: "test.rebootless_apex_app_in_apex",
518    manifest: "manifest_rebootless_v2.json",
519    file_contexts: ":apex.test-file_contexts",
520    key: "com.android.apex.test_package.key",
521    installable: false,
522    updatable: false,
523    apps: ["AppInRebootlessApex"],
524    // TODO(ioffe): we should have a separate field to hashtree presence.
525    min_sdk_version: "29", // test requires hashtree to be present.
526}
527
528apex {
529    name: "test.rebootless_apex_priv_app_in_apex",
530    manifest: "manifest_rebootless_v2.json",
531    file_contexts: ":apex.test-file_contexts",
532    key: "com.android.apex.test_package.key",
533    installable: false,
534    updatable: false,
535    apps: ["PrivAppInRebootlessApex"],
536    // TODO(ioffe): we should have a separate field to hashtree presence.
537    min_sdk_version: "29", // test requires hashtree to be present.
538}
539
540android_app {
541    name: "AppInRebootlessApex",
542    sdk_version: "29",
543    manifest: "AppInRebootlessApex_AndroidManifest.xml",
544    apex_available: [
545        "test.rebootless_apex_app_in_apex",
546    ],
547}
548
549android_app {
550    name: "PrivAppInRebootlessApex",
551    sdk_version: "29",
552    privileged: true,
553    manifest: "AppInRebootlessApex_AndroidManifest.xml",
554    apex_available: [
555        "test.rebootless_apex_priv_app_in_apex",
556    ],
557}
558
559apex_test {
560    name: "apex.apexd_test_classpath",
561    bootclasspath_fragments: ["apex.apexd_test_bootclasspath-fragment"],
562    systemserverclasspath_fragments: ["apex.apexd_test_systemserverclasspath-fragment"],
563    manifest: "manifest.json",
564    prebuilts: ["sample_prebuilt_file"],
565    key: "com.android.apex.test_package.key",
566    file_contexts: ":apex.test-file_contexts",
567    installable: false, // Should never be installed on the systemimage
568    updatable: false,
569}
570
571bootclasspath_fragment_test {
572    name: "apex.apexd_test_bootclasspath-fragment",
573    contents: ["test_framework-apexd"],
574}
575
576systemserverclasspath_fragment {
577    name: "apex.apexd_test_systemserverclasspath-fragment",
578    contents: ["test_service-apexd"],
579}
580
581java_sdk_library {
582    name: "test_framework-apexd",
583    defaults: ["framework-module-defaults"],
584    srcs: ["src/com/android/apex/test/Test.java"],
585    permitted_packages: ["com.android.apex.test"],
586    min_sdk_version: "30",
587
588    // Test only SDK, don't check against released APIs.
589    unsafe_ignore_missing_latest_api: true,
590    // Output the api files to a special directory that won't trigger an API
591    // review as it is a test only API.
592    api_dir: "apis_for_tests",
593    // Testing only.
594    no_dist: true,
595}
596
597java_sdk_library {
598    name: "test_service-apexd",
599    defaults: ["framework-system-server-module-defaults"],
600    srcs: ["src/com/android/apex/test/Test.java"],
601    permitted_packages: ["com.android.apex.test"],
602    min_sdk_version: "30",
603
604    // Test only SDK, don't check against released APIs.
605    unsafe_ignore_missing_latest_api: true,
606    // Output the api files to a special directory that won't trigger an API
607    // review as it is a test only API.
608    api_dir: "apis_for_tests",
609    // Testing only.
610    no_dist: true,
611}
612