blob: 3623f9b8846d6dc7b81988133a39eaa5e3a93379 [file] [log] [blame]
Andreas Gampe02d0de52015-11-11 20:43:16 -08001/*
2**
3** Copyright 2008, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
Calin Juravle6a1648e2016-02-01 12:12:16 +00007** You may obtain a copy of the License at
Andreas Gampe02d0de52015-11-11 20:43:16 -08008**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
18#ifndef INSTALLD_CONSTANTS_H_
19#define INSTALLD_CONSTANTS_H_
20
Jiakai Zhangf515a1b2022-02-23 18:33:26 +000021#include "cutils/multiuser.h"
22
Andreas Gampe02d0de52015-11-11 20:43:16 -080023namespace android {
24namespace installd {
25
26/* elements combined with a valid package name to form paths */
27
28constexpr const char* PRIMARY_USER_PREFIX = "data/";
29constexpr const char* SECONDARY_USER_PREFIX = "user/";
30
Andreas Gampe02d0de52015-11-11 20:43:16 -080031// This is used as a string literal, can't be constants. TODO: std::string...
32#define DALVIK_CACHE "dalvik-cache"
David Brazdil249c1792016-09-06 15:35:28 +010033constexpr const char* DALVIK_CACHE_POSTFIX = "@classes.dex";
Andreas Gampe02d0de52015-11-11 20:43:16 -080034
Andreas Gampe02d0de52015-11-11 20:43:16 -080035constexpr size_t PKG_NAME_MAX = 128u; /* largest allowed package name */
Calin Juravled23dee72017-07-06 16:29:11 -070036constexpr size_t PKG_PATH_MAX = 1024u; /* max size of any path we use */
Andreas Gampe02d0de52015-11-11 20:43:16 -080037
Andreas Gampe02d0de52015-11-11 20:43:16 -080038/****************************************************************************
39 * IMPORTANT: These values are passed from Java code. Keep them in sync with
40 * frameworks/base/services/core/java/com/android/server/pm/Installer.java
41 ***************************************************************************/
Andreas Gampe4d0f8252016-03-20 11:30:28 -070042constexpr int DEXOPT_PUBLIC = 1 << 1;
Nicolas Geoffraybad623a2017-05-05 14:32:51 +010043constexpr int DEXOPT_DEBUGGABLE = 1 << 2;
44constexpr int DEXOPT_BOOTCOMPLETE = 1 << 3;
45constexpr int DEXOPT_PROFILE_GUIDED = 1 << 4;
46constexpr int DEXOPT_SECONDARY_DEX = 1 << 5;
Calin Juravle42451c02017-01-17 14:43:25 -080047// DEXOPT_FORCE, DEXOPT_STORAGE_CE, DEXOPT_STORAGE_DE are exposed for secondary
48// dex files only. Primary apks are analyzed in PackageManager and installd
49// does not need to know if the compilation is forced or on what kind of storage
50// the dex files are.
Nicolas Geoffraybad623a2017-05-05 14:32:51 +010051constexpr int DEXOPT_FORCE = 1 << 6;
52constexpr int DEXOPT_STORAGE_CE = 1 << 7;
53constexpr int DEXOPT_STORAGE_DE = 1 << 8;
David Sehra3b5ab62017-10-25 14:27:29 -070054// Tells the compiler that it is invoked from the background service. This
55// controls whether extra debugging flags can be used (taking more compile time.)
56constexpr int DEXOPT_IDLE_BACKGROUND_JOB = 1 << 9;
David Brazdil52249162018-02-12 18:04:59 -080057constexpr int DEXOPT_ENABLE_HIDDEN_API_CHECKS = 1 << 10;
Mathieu Chartierf69c2f72018-03-06 13:55:58 -080058constexpr int DEXOPT_GENERATE_COMPACT_DEX = 1 << 11;
Mathieu Chartier1dc3dfa2018-03-12 17:55:06 -070059constexpr int DEXOPT_GENERATE_APP_IMAGE = 1 << 12;
Patrick Baumann2271b3e2020-04-14 17:03:00 -070060constexpr int DEXOPT_FOR_RESTORE = 1 << 13; // TODO(b/135202722): remove
Andreas Gampe02d0de52015-11-11 20:43:16 -080061
62/* all known values for dexopt flags */
63constexpr int DEXOPT_MASK =
64 DEXOPT_PUBLIC
Andreas Gampe02d0de52015-11-11 20:43:16 -080065 | DEXOPT_DEBUGGABLE
66 | DEXOPT_BOOTCOMPLETE
Calin Juravle42451c02017-01-17 14:43:25 -080067 | DEXOPT_PROFILE_GUIDED
68 | DEXOPT_SECONDARY_DEX
69 | DEXOPT_FORCE
70 | DEXOPT_STORAGE_CE
David Brazdil7fcbb812018-01-17 17:05:40 +000071 | DEXOPT_STORAGE_DE
Andreas Gamped32eec22018-02-28 16:02:51 -080072 | DEXOPT_IDLE_BACKGROUND_JOB
Mathieu Chartierf69c2f72018-03-06 13:55:58 -080073 | DEXOPT_ENABLE_HIDDEN_API_CHECKS
Mathieu Chartier1dc3dfa2018-03-12 17:55:06 -070074 | DEXOPT_GENERATE_COMPACT_DEX
Patrick Baumann2271b3e2020-04-14 17:03:00 -070075 | DEXOPT_GENERATE_APP_IMAGE
76 | DEXOPT_FOR_RESTORE;
Calin Juravle42451c02017-01-17 14:43:25 -080077
78// NOTE: keep in sync with StorageManager
79constexpr int FLAG_STORAGE_DE = 1 << 0;
80constexpr int FLAG_STORAGE_CE = 1 << 1;
Andreas Gampe02d0de52015-11-11 20:43:16 -080081
Calin Juravlee90de862021-06-08 08:04:52 -070082// TODO: import them from dexoptanalyzer.h
83// NOTE: keep in sync with Installer.java
84constexpr int PROFILES_ANALYSIS_OPTIMIZE = 1;
85constexpr int PROFILES_ANALYSIS_DONT_OPTIMIZE_SMALL_DELTA = 2;
86constexpr int PROFILES_ANALYSIS_DONT_OPTIMIZE_EMPTY_PROFILES = 3;
87
Jiakai Zhangf515a1b2022-02-23 18:33:26 +000088// NOTE: keep in sync with Installer.java
89constexpr int ODEX_NOT_FOUND = 0;
90constexpr int ODEX_IS_PUBLIC = 1;
91constexpr int ODEX_IS_PRIVATE = 2;
92
93// NOTE: keep in sync with UserHandle.java
94constexpr userid_t USER_NULL = -10000;
95constexpr userid_t USER_SYSTEM = 0;
96
Andreas Gampe02d0de52015-11-11 20:43:16 -080097#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
98
99} // namespace installd
100} // namespace android
101
102#endif // INSTALLD_CONSTANTS_H_