installd_constants.h revision 73dae11162aa61396c06cbdb05b954764e944e02
1/*
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.
7** You may obtain a copy of the License at
8**
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
21namespace android {
22namespace installd {
23
24/* elements combined with a valid package name to form paths */
25
26constexpr const char* PRIMARY_USER_PREFIX = "data/";
27constexpr const char* SECONDARY_USER_PREFIX = "user/";
28
29constexpr const char* PKG_DIR_POSTFIX = "";
30
31constexpr const char* PKG_LIB_POSTFIX = "/lib";
32
33constexpr const char* CACHE_DIR_POSTFIX = "/cache";
34constexpr const char* CODE_CACHE_DIR_POSTFIX = "/code_cache";
35
36constexpr const char* APP_SUBDIR = "app/"; // sub-directory under ANDROID_DATA
37constexpr const char* PRIV_APP_SUBDIR = "priv-app/"; // sub-directory under ANDROID_DATA
38constexpr const char* EPHEMERAL_APP_SUBDIR = "app-ephemeral/"; // sub-directory under ANDROID_DATA
39
40constexpr const char* APP_LIB_SUBDIR = "app-lib/"; // sub-directory under ANDROID_DATA
41
42constexpr const char* MEDIA_SUBDIR = "media/"; // sub-directory under ANDROID_DATA
43
44/* other handy constants */
45
46constexpr const char* PRIVATE_APP_SUBDIR = "app-private/"; // sub-directory under ANDROID_DATA
47
48// This is used as a string literal, can't be constants. TODO: std::string...
49#define DALVIK_CACHE "dalvik-cache"
50constexpr const char* DALVIK_CACHE_POSTFIX = "/classes.dex";
51constexpr const char* DALVIK_CACHE_POSTFIX2 = "@classes.dex";
52
53constexpr const char* IDMAP_PREFIX = "/data/resource-cache/";
54constexpr const char* IDMAP_SUFFIX = "@idmap";
55
56constexpr size_t PKG_NAME_MAX = 128u;   /* largest allowed package name */
57constexpr size_t PKG_PATH_MAX = 256u;   /* max size of any path we use */
58
59constexpr int FLAG_DE_STORAGE = 1 << 0;
60constexpr int FLAG_CE_STORAGE = 1 << 1;
61constexpr int FLAG_CLEAR_CACHE_ONLY = 1 << 2;
62constexpr int FLAG_CLEAR_CODE_CACHE_ONLY = 1 << 3;
63
64/* dexopt needed flags matching those in dalvik.system.DexFile */
65constexpr int DEXOPT_DEX2OAT_NEEDED       = 1;
66constexpr int DEXOPT_PATCHOAT_NEEDED      = 2;
67constexpr int DEXOPT_SELF_PATCHOAT_NEEDED = 3;
68
69/****************************************************************************
70 * IMPORTANT: These values are passed from Java code. Keep them in sync with
71 * frameworks/base/services/core/java/com/android/server/pm/Installer.java
72 ***************************************************************************/
73constexpr int DEXOPT_PUBLIC       = 1 << 1;
74constexpr int DEXOPT_SAFEMODE     = 1 << 2;
75constexpr int DEXOPT_DEBUGGABLE   = 1 << 3;
76constexpr int DEXOPT_BOOTCOMPLETE = 1 << 4;
77constexpr int DEXOPT_EXTRACTONLY  = 1 << 5;
78constexpr int DEXOPT_OTA          = 1 << 6;
79
80/* all known values for dexopt flags */
81constexpr int DEXOPT_MASK =
82    DEXOPT_PUBLIC
83    | DEXOPT_SAFEMODE
84    | DEXOPT_DEBUGGABLE
85    | DEXOPT_BOOTCOMPLETE
86    | DEXOPT_EXTRACTONLY
87    | DEXOPT_OTA;
88
89#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
90
91}  // namespace installd
92}  // namespace android
93
94#endif  // INSTALLD_CONSTANTS_H_
95