Andreas Gampe | 02d0de5 | 2015-11-11 20:43:16 -0800 | [diff] [blame] | 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 | |
| 21 | namespace android { |
| 22 | namespace installd { |
| 23 | |
| 24 | /* elements combined with a valid package name to form paths */ |
| 25 | |
| 26 | constexpr const char* PRIMARY_USER_PREFIX = "data/"; |
| 27 | constexpr const char* SECONDARY_USER_PREFIX = "user/"; |
| 28 | |
| 29 | constexpr const char* PKG_DIR_POSTFIX = ""; |
| 30 | |
| 31 | constexpr const char* PKG_LIB_POSTFIX = "/lib"; |
| 32 | |
| 33 | constexpr const char* CACHE_DIR_POSTFIX = "/cache"; |
| 34 | constexpr const char* CODE_CACHE_DIR_POSTFIX = "/code_cache"; |
| 35 | |
| 36 | constexpr const char* APP_SUBDIR = "app/"; // sub-directory under ANDROID_DATA |
| 37 | constexpr const char* PRIV_APP_SUBDIR = "priv-app/"; // sub-directory under ANDROID_DATA |
| 38 | constexpr const char* EPHEMERAL_APP_SUBDIR = "app-ephemeral/"; // sub-directory under ANDROID_DATA |
| 39 | |
| 40 | constexpr const char* APP_LIB_SUBDIR = "app-lib/"; // sub-directory under ANDROID_DATA |
| 41 | |
| 42 | constexpr const char* MEDIA_SUBDIR = "media/"; // sub-directory under ANDROID_DATA |
| 43 | |
| 44 | /* other handy constants */ |
| 45 | |
| 46 | constexpr 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" |
| 50 | constexpr const char* DALVIK_CACHE_POSTFIX = "/classes.dex"; |
Andreas Gampe | 73dae11 | 2015-11-19 14:12:14 -0800 | [diff] [blame] | 51 | constexpr const char* DALVIK_CACHE_POSTFIX2 = "@classes.dex"; |
Andreas Gampe | 02d0de5 | 2015-11-11 20:43:16 -0800 | [diff] [blame] | 52 | |
Andreas Gampe | 02d0de5 | 2015-11-11 20:43:16 -0800 | [diff] [blame] | 53 | constexpr const char* IDMAP_PREFIX = "/data/resource-cache/"; |
| 54 | constexpr const char* IDMAP_SUFFIX = "@idmap"; |
| 55 | |
| 56 | constexpr size_t PKG_NAME_MAX = 128u; /* largest allowed package name */ |
| 57 | constexpr size_t PKG_PATH_MAX = 256u; /* max size of any path we use */ |
| 58 | |
Jeff Sharkey | aa7ddfd | 2016-02-03 14:03:16 -0700 | [diff] [blame^] | 59 | // NOTE: keep in sync with StorageManager |
| 60 | constexpr int FLAG_STORAGE_DE = 1 << 0; |
| 61 | constexpr int FLAG_STORAGE_CE = 1 << 1; |
| 62 | |
| 63 | // NOTE: keep in sync with Installer |
| 64 | constexpr int FLAG_CLEAR_CACHE_ONLY = 1 << 8; |
| 65 | constexpr int FLAG_CLEAR_CODE_CACHE_ONLY = 1 << 9; |
Jeff Sharkey | c7d1b22 | 2016-01-11 13:07:09 -0700 | [diff] [blame] | 66 | |
Andreas Gampe | 02d0de5 | 2015-11-11 20:43:16 -0800 | [diff] [blame] | 67 | /* dexopt needed flags matching those in dalvik.system.DexFile */ |
| 68 | constexpr int DEXOPT_DEX2OAT_NEEDED = 1; |
| 69 | constexpr int DEXOPT_PATCHOAT_NEEDED = 2; |
| 70 | constexpr int DEXOPT_SELF_PATCHOAT_NEEDED = 3; |
| 71 | |
| 72 | /**************************************************************************** |
| 73 | * IMPORTANT: These values are passed from Java code. Keep them in sync with |
| 74 | * frameworks/base/services/core/java/com/android/server/pm/Installer.java |
| 75 | ***************************************************************************/ |
| 76 | constexpr int DEXOPT_PUBLIC = 1 << 1; |
| 77 | constexpr int DEXOPT_SAFEMODE = 1 << 2; |
| 78 | constexpr int DEXOPT_DEBUGGABLE = 1 << 3; |
| 79 | constexpr int DEXOPT_BOOTCOMPLETE = 1 << 4; |
David Brazdil | b0fad6d | 2015-12-30 11:16:04 +0000 | [diff] [blame] | 80 | constexpr int DEXOPT_EXTRACTONLY = 1 << 5; |
Andreas Gampe | 73dae11 | 2015-11-19 14:12:14 -0800 | [diff] [blame] | 81 | constexpr int DEXOPT_OTA = 1 << 6; |
Andreas Gampe | 02d0de5 | 2015-11-11 20:43:16 -0800 | [diff] [blame] | 82 | |
| 83 | /* all known values for dexopt flags */ |
| 84 | constexpr int DEXOPT_MASK = |
| 85 | DEXOPT_PUBLIC |
| 86 | | DEXOPT_SAFEMODE |
| 87 | | DEXOPT_DEBUGGABLE |
| 88 | | DEXOPT_BOOTCOMPLETE |
Andreas Gampe | 73dae11 | 2015-11-19 14:12:14 -0800 | [diff] [blame] | 89 | | DEXOPT_EXTRACTONLY |
| 90 | | DEXOPT_OTA; |
Andreas Gampe | 02d0de5 | 2015-11-11 20:43:16 -0800 | [diff] [blame] | 91 | |
| 92 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a))) |
| 93 | |
| 94 | } // namespace installd |
| 95 | } // namespace android |
| 96 | |
| 97 | #endif // INSTALLD_CONSTANTS_H_ |