1// Messages describing APK Set's table of contents (toc.pb entry).
2// Please be advised that the ultimate source is at
3// https://github.com/google/bundletool/tree/master/src/main/proto
4// so you have been warned.
5syntax = "proto3";
6
7package android.bundle;
8
9option go_package = "android/soong/cmd/extract_apks/bundle_proto";
10option java_package = "com.android.bundle";
11
12message BundleConfig {
13  Bundletool bundletool = 1;
14  Optimizations optimizations = 2;
15  Compression compression = 3;
16  // Resources to be always kept in the master split.
17  MasterResources master_resources = 4;
18  ApexConfig apex_config = 5;
19  // APKs to be signed with the same key as generated APKs.
20  repeated UnsignedEmbeddedApkConfig unsigned_embedded_apk_config = 6;
21  AssetModulesConfig asset_modules_config = 7;
22
23  enum BundleType {
24    REGULAR = 0;
25    APEX = 1;
26    ASSET_ONLY = 2;
27  }
28  BundleType type = 8;
29
30  // Configuration for locales.
31  Locales locales = 9;
32}
33
34message Bundletool {
35  reserved 1;
36  // Version of BundleTool used to build the Bundle.
37  string version = 2;
38}
39
40message Compression {
41  // Glob matching the list of files to leave uncompressed in the APKs.
42  // The matching is done against the path of files in the APK, thus excluding
43  // the name of the modules, and using forward slash ("/") as a name separator.
44  // Examples: "res/raw/**", "assets/**/*.uncompressed", etc.
45  repeated string uncompressed_glob = 1;
46
47  enum AssetModuleCompression {
48    UNSPECIFIED = 0;
49    // Assets are left uncompressed in the generated asset module.
50    UNCOMPRESSED = 1;
51    // Assets are compressed in the generated asset module.
52    // This option can be overridden at a finer granularity by specifying
53    // files or folders to keep uncompressed in `uncompressed_glob`.
54    // This option should only be used if the app is able to handle compressed
55    // asset module content at runtime (some runtime APIs may misbehave).
56    COMPRESSED = 2;
57  }
58
59  // Default compression strategy for install-time asset modules.
60  // If the compression strategy indicates to compress a file and the same file
61  // matches one of the `uncompressed_glob` values, the `uncompressed_glob`
62  // takes precedence (the file is left uncompressed in the generated APK).
63  //
64  // If unspecified, asset module content is left uncompressed in the
65  // generated asset modules.
66  //
67  // Note: this flag only configures the compression strategy for install-time
68  // asset modules; the content of on-demand and fast-follow asset modules is
69  // always kept uncompressed.
70  AssetModuleCompression install_time_asset_module_default_compression = 2;
71
72  enum ApkCompressionAlgorithm {
73    // Default in the current version of bundletool is zlib deflate algorithm
74    // with compression level 9 for the application's resources and compression
75    // level 6 for other entries.
76    //
77    // This is a good trade-off between size of final APK and size of patches
78    // which are used to update the application from previous to next version.
79    DEFAULT_APK_COMPRESSION_ALGORITHM = 0;
80
81    // 7zip implementation of deflate algorithm which gives smaller APK size
82    // but size of patches required to update the application are larger.
83    P7ZIP = 1;
84  }
85
86  // Compression algorithm which is used to compress entries in final APKs.
87  ApkCompressionAlgorithm apk_compression_algorithm = 3;
88}
89
90// Resources to keep in the master split.
91message MasterResources {
92  // Resource IDs to be kept in master split.
93  repeated int32 resource_ids = 1;
94  // Resource names to be kept in master split.
95  repeated string resource_names = 2;
96}
97
98message Optimizations {
99  SplitsConfig splits_config = 1;
100  // This is for uncompressing native libraries on M+ devices (L+ devices on
101  // instant apps).
102  UncompressNativeLibraries uncompress_native_libraries = 2;
103  // This is for uncompressing dex files.
104  UncompressDexFiles uncompress_dex_files = 3;
105  // Configuration for the generation of standalone APKs.
106  // If no StandaloneConfig is set, the configuration is inherited from
107  // splits_config.
108  StandaloneConfig standalone_config = 4;
109
110  // Optimizations that are applied to resources.
111  ResourceOptimizations resource_optimizations = 5;
112
113  // Configuration for archiving the app.
114  StoreArchive store_archive = 6;
115}
116
117message ResourceOptimizations {
118  // Whether to use sparse encoding for resource tables.
119  // Resources in sparse resource table are accessed using a binary search tree.
120  // This decreases APK size at the cost of resource retrieval performance.
121  SparseEncoding sparse_encoding = 1;
122
123  enum SparseEncoding {
124    // Previously 'ENFORCED'. This option is deprecated because of issues found
125    // in Android O up to Android Sv2 and causes segfaults in
126    // Resources#getIdentifier.
127    reserved 1;
128    reserved "ENFORCED";
129
130    // Disables sparse encoding.
131    UNSPECIFIED = 0;
132    // Generates special APKs for Android SDK +32 with sparse resource tables.
133    // Devices with Android SDK below 32 will still receive APKs with regular
134    // resource tables.
135    VARIANT_FOR_SDK_32 = 2;
136  }
137}
138
139message UncompressNativeLibraries {
140  bool enabled = 1;
141}
142
143message UncompressDexFiles {
144  //  A new variant with uncompressed dex will be generated. The sdk targeting
145  //  of the variant is determined by 'uncompressed_dex_target_sdk'.
146  bool enabled = 1;
147
148  //  If 'enabled' field is set, this will determine the sdk targeting of the
149  //  generated variant.
150  UncompressedDexTargetSdk uncompressed_dex_target_sdk = 2;
151
152  enum UncompressedDexTargetSdk {
153    // Q+ variant will be generated.
154    UNSPECIFIED = 0;
155    // S+ variant will be generated.
156    SDK_31 = 1;
157  }
158}
159
160message StoreArchive {
161  // Archive is an app state that allows an official app store to reclaim device
162  // storage and disable app functionality temporarily until the user interacts
163  // with the app again. Upon interaction the latest available version of the
164  // app will be restored while leaving user data unaffected.
165  // Enabled by default.
166  bool enabled = 1;
167}
168
169message Locales {
170  // Instructs bundletool to generate locale config and inject it into
171  // AndroidManifest.xml. A locale is marked as supported by the application if
172  // there is at least one resource value in this locale. Be very careful with
173  // this setting because if some of your libraries expose resources in some
174  // locales which are not actually supported by your application it will mark
175  // this locale as supported. Disabled by default.
176  bool inject_locale_config = 1;
177}
178
179// Optimization configuration used to generate Split APKs.
180message SplitsConfig {
181  repeated SplitDimension split_dimension = 1;
182}
183
184// Optimization configuration used to generate Standalone APKs.
185message StandaloneConfig {
186  // Device targeting dimensions to shard.
187  repeated SplitDimension split_dimension = 1;
188  // Whether 64 bit libraries should be stripped from Standalone APKs.
189  bool strip_64_bit_libraries = 2;
190  // Dex merging strategy that should be applied to produce Standalone APKs.
191  DexMergingStrategy dex_merging_strategy = 3;
192
193  enum DexMergingStrategy {
194    // Strategy that does dex merging for applications that have minimum SDK
195    // below 21 to ensure dex files from all modules are merged into one or
196    // mainDexList is applied when merging into one dex is not possible. For
197    // applications with minSdk >= 21 dex files from all modules are copied into
198    // standalone APK as is because Android supports multiple dex files natively
199    // starting from Android 5.0.
200    MERGE_IF_NEEDED = 0;
201    // Requires to copy dex files from all modules into standalone APK as is.
202    // If an application supports SDKs below 21 this strategy puts
203    // responsibility of providing dex files compatible with legacy multidex on
204    // application developers.
205    NEVER_MERGE = 1;
206  }
207}
208
209// BEGIN-INTERNAL
210// LINT.IfChange
211// END-INTERNAL
212message SplitDimension {
213  enum Value {
214    UNSPECIFIED_VALUE = 0;
215    ABI = 1;
216    SCREEN_DENSITY = 2;
217    LANGUAGE = 3;
218    TEXTURE_COMPRESSION_FORMAT = 4;
219    // BEGIN-INTERNAL
220    GRAPHICS_API = 5 [deprecated = true];
221    // END-INTERNAL
222    DEVICE_TIER = 6;
223  }
224  Value value = 1;
225
226  // If set to 'true', indicates that APKs should *not* be split by this
227  // dimension.
228  bool negate = 2;
229
230  // Optional transformation to be applied to asset directories where
231  // the targeting is encoded in the directory name (e.g: assets/foo#tcf_etc1)
232  SuffixStripping suffix_stripping = 3;
233}
234// BEGIN-INTERNAL
235// LINT.ThenChange(//depot/google3/wireless/android/vending/developer/proto/storage/app/apk_bundle.proto)
236// END-INTERNAL
237
238message SuffixStripping {
239  // If set to 'true', indicates that the targeting suffix should be removed
240  // from assets paths for this dimension when splits (e.g: "asset packs") or
241  // standalone/universal APKs are generated.
242  // This only applies to assets.
243  // For example a folder with path "assets/level1_textures#tcf_etc1"
244  // would be outputted to "assets/level1_textures". File contents are
245  // unchanged.
246  bool enabled = 1;
247
248  // The default suffix to be used for the cases where separate slices can't
249  // be generated for this dimension - typically for standalone or universal
250  // APKs.
251  // This default suffix defines the directories to retain. The others are
252  // discarded: standalone/universal APKs will contain only directories
253  // targeted at this value for the dimension.
254  //
255  // If not set or empty, the fallback directory in each directory group will be
256  // used (for example, if both "assets/level1_textures#tcf_etc1" and
257  // "assets/level1_textures" are present and the default suffix is empty,
258  // then only "assets/level1_textures" will be used).
259  string default_suffix = 2;
260}
261
262// Configuration for processing APEX bundles.
263// https://source.android.com/devices/tech/ota/apex
264message ApexConfig {
265  // Configuration for processing of APKs embedded in an APEX image.
266  repeated ApexEmbeddedApkConfig apex_embedded_apk_config = 1;
267
268  // Explicit list of supported ABIs.
269  // Default: See ApexBundleValidator.REQUIRED_ONE_OF_ABI_SETS
270  repeated SupportedAbiSet supported_abi_set = 2;
271}
272
273// Represents a set of ABIs which must be supported by a single APEX image.
274message SupportedAbiSet {
275  repeated string abi = 1;
276}
277
278message ApexEmbeddedApkConfig {
279  // Android package name of the APK.
280  string package_name = 1;
281
282  // Path to the APK within the APEX system image.
283  string path = 2;
284}
285
286message UnsignedEmbeddedApkConfig {
287  // Path to the APK inside the module (e.g. if the path inside the bundle
288  // is split/assets/example.apk, this will be assets/example.apk).
289  string path = 1;
290}
291
292message AssetModulesConfig {
293  // App versionCodes that will be updated with these asset modules.
294  // Only relevant for asset-only bundles.
295  repeated int64 app_version = 1;
296
297  // Version tag for the asset upload.
298  // Only relevant for asset-only bundles.
299  string asset_version_tag = 2;
300}
301