1// Copyright (C) 2023 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_team: "trendy_team_fwk_nfc",
17    default_applicable_licenses: ["Android-Apache-2.0"],
18}
19
20apex_key {
21    name: "com.android.nfcservices.key",
22    public_key: "com.android.nfcservices.avbpubkey",
23    private_key: "com.android.nfcservices.pem",
24}
25
26android_app_certificate {
27    name: "com.android.nfcservices.certificate",
28    certificate: "com.android.nfcservices",
29}
30
31soong_config_module_type {
32    name: "custom_apex",
33    module_type: "apex",
34    config_namespace: "bootclasspath",
35    bool_variables: [
36        "nfc_apex_bootclasspath_fragment",
37    ],
38    properties: [
39        "bootclasspath_fragments",
40    ],
41}
42
43custom_apex {
44    name: "com.android.nfcservices",
45    manifest: "manifest.json",
46    apps: ["NfcNciApex"],
47    defaults: ["b-launched-apex-module"],
48    updatable: false, // TODO: fix this.
49    min_sdk_version: "35", // Make it 36 once available.
50    multilib: {
51        first: {
52            // Extractor process runs only with the primary ABI.
53            jni_libs: [
54                "libnfc_nci_jni",
55            ],
56        },
57    },
58    soong_config_variables: {
59        nfc_apex_bootclasspath_fragment: {
60            bootclasspath_fragments: ["com.android.nfcservices-bootclasspath-fragment"],
61        },
62    },
63
64    required: [
65        // Provide a default libnfc-nci.conf in /system/etc for devices that
66        // does not ship one in /product
67        "libnfc-nci.conf-default",
68    ],
69    file_contexts: ":com.android.nfcservices-file_contexts",
70    key: "com.android.nfcservices.key",
71    certificate: ":com.android.nfcservices.certificate",
72}
73
74sdk {
75    name: "nfcservices-module-sdk",
76    apexes: [
77        // Adds exportable dependencies of the APEX to the sdk,
78        // e.g. *classpath_fragments.
79        "com.android.nfcservices",
80    ],
81}
82
83soong_config_module_type {
84    name: "custom_bootclasspath_fragment",
85    module_type: "bootclasspath_fragment",
86    config_namespace: "bootclasspath",
87    bool_variables: [
88        "nfc_apex_bootclasspath_fragment",
89    ],
90    properties: [
91        "enabled",
92    ],
93}
94
95// Encapsulate the contributions made by the com.android.nfc to the bootclasspath.
96custom_bootclasspath_fragment {
97    name: "com.android.nfcservices-bootclasspath-fragment",
98    contents: ["framework-nfc"],
99    apex_available: ["com.android.nfcservices"],
100    // This is disabled for now since the build system does not allow for adding a bootclasspath
101    // fragment and conditionally adding it to PRODUCT_APEX_BOOT_JARS.
102    // When `RELEASE_PACKAGE_NFC_STACK` is set to `com.android.nfcservices`, this needs to be
103    // set to true.
104    enabled: false,
105    soong_config_variables: {
106        nfc_apex_bootclasspath_fragment: {
107            enabled: true,
108        },
109    },
110
111    // The bootclasspath_fragments that provide APIs on which this depends.
112    fragments: [
113        // Needed to access core java APIs.
114        {
115            apex: "com.android.art",
116            module: "art-bootclasspath-fragment",
117        },
118    ],
119
120    // Additional stubs libraries that this fragment's contents use which are
121    // not provided by another bootclasspath_fragment.
122    additional_stubs: [
123        // Needed to access platform APIs.
124        "android-non-updatable",
125    ],
126    hidden_api: {
127        // Additional hidden API flag files to override the defaults. This must only be
128        // modified by the Soong or platform compat team.
129        max_target_o_low_priority: ["hiddenapi/hiddenapi-max-target-o.txt"],
130        max_target_r_low_priority: ["hiddenapi/hiddenapi-max-target-r-loprio.txt"],
131
132        // The following packages contain classes from other modules on the
133        // bootclasspath. That means that the hidden API flags for this module
134        // has to explicitly list every single class this module provides in
135        // that package to differentiate them from the classes provided by other
136        // modules. That can include private classes that are not part of the
137        // API.
138        split_packages: [
139            "android.nfc",
140            "android.nfc.cardemulation",
141        ],
142
143        // The following packages and all their subpackages currently only
144        // contain classes from this bootclasspath_fragment. Listing a package
145        // here won't prevent other bootclasspath modules from adding classes in
146        // any of those packages but it will prevent them from adding those
147        // classes into an API surface, e.g. public, system, etc.. Doing so will
148        // result in a build failure due to inconsistent flags.
149        package_prefixes: [
150            "android.nfc.dta",
151            "android.nfc.tech",
152            "com.android.nfc",
153        ],
154    },
155}
156