1 /*
2 * Copyright (C) 2021 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 //! Common items used by CompOS server and/or clients
18
19 pub mod binder;
20 pub mod compos_client;
21 pub mod odrefresh;
22 pub mod timeouts;
23
24 /// VSock port that the CompOS server listens on for RPC binder connections. This should be out of
25 /// future port range (if happens) that microdroid may reserve for system components.
26 pub const COMPOS_VSOCK_PORT: u32 = 6432;
27
28 /// The root directory where the CompOS APEX is mounted (read only).
29 pub const COMPOS_APEX_ROOT: &str = "/apex/com.android.compos";
30
31 /// The root of the data directory available for private use by the CompOS APEX.
32 pub const COMPOS_DATA_ROOT: &str = "/data/misc/apexdata/com.android.compos";
33
34 /// The sub-directory where we store information relating to the instance of CompOS used for
35 /// real compilation.
36 pub const CURRENT_INSTANCE_DIR: &str = "current";
37
38 /// The sub-directory where we store information relating to the instance of CompOS used for
39 /// tests.
40 pub const TEST_INSTANCE_DIR: &str = "test";
41
42 /// The file that holds the instance_id of CompOS instance.
43 pub const INSTANCE_ID_FILE: &str = "instance_id";
44
45 /// The file that holds the instance image for a CompOS instance.
46 pub const INSTANCE_IMAGE_FILE: &str = "instance.img";
47
48 /// The file that holds the idsig for the CompOS Payload APK.
49 pub const IDSIG_FILE: &str = "idsig";
50
51 /// The file that holds the idsig for the build manifest APK that makes enumerated files from
52 /// /system available in CompOS.
53 pub const IDSIG_MANIFEST_APK_FILE: &str = "idsig_manifest_apk";
54
55 /// The file that holds the idsig for the build manifest APK that makes enumerated files from
56 /// /system_ext available in CompOS.
57 pub const IDSIG_MANIFEST_EXT_APK_FILE: &str = "idsig_manifest_ext_apk";
58
59 /// The Android path of fs-verity build manifest APK for /system.
60 pub const BUILD_MANIFEST_APK_PATH: &str = "/system/etc/security/fsverity/BuildManifest.apk";
61
62 /// The Android path of fs-verity build manifest APK for /system_ext.
63 pub const BUILD_MANIFEST_SYSTEM_EXT_APK_PATH: &str =
64 "/system_ext/etc/security/fsverity/BuildManifestSystemExt.apk";
65
66 /// Returns the path of proper VM config for the current device.
get_vm_config_path(has_system_ext: bool, prefer_staged: bool) -> String67 pub fn get_vm_config_path(has_system_ext: bool, prefer_staged: bool) -> String {
68 match (has_system_ext, prefer_staged) {
69 (false, false) => "assets/vm_config.json",
70 (false, true) => "assets/vm_config_staged.json",
71 (true, false) => "assets/vm_config_system_ext.json",
72 (true, true) => "assets/vm_config_system_ext_staged.json",
73 }
74 .to_owned()
75 }
76