blob: 1394701f55cb5ee4321b8ac24b92d8ef96ddb7b6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
/*
** Copyright 2015, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
#define LOG_TAG "installd"
#include <globals.h>
#include <installd_constants.h>
#include <utils.h>
#include <android-base/logging.h>
#include <stdlib.h>
#include <string.h>
namespace android {
namespace installd {
static constexpr const char* APP_SUBDIR = "app/"; // sub-directory under ANDROID_DATA
static constexpr const char* PRIV_APP_SUBDIR = "priv-app/"; // sub-directory under ANDROID_DATA
static constexpr const char* EPHEMERAL_APP_SUBDIR = "app-ephemeral/"; // sub-directory under
// ANDROID_DATA
static constexpr const char* APP_LIB_SUBDIR = "app-lib/"; // sub-directory under ANDROID_DATA
static constexpr const char* MEDIA_SUBDIR = "media/"; // sub-directory under ANDROID_DATA
static constexpr const char* PROFILES_SUBDIR = "misc/profiles"; // sub-directory under ANDROID_DATA
static constexpr const char* PRIVATE_APP_SUBDIR = "app-private/"; // sub-directory under
// ANDROID_DATA
static constexpr const char* STAGING_SUBDIR = "app-staging/"; // sub-directory under ANDROID_DATA
std::string android_app_dir;
std::string android_app_ephemeral_dir;
std::string android_app_lib_dir;
std::string android_app_private_dir;
std::string android_asec_dir;
std::string android_data_dir;
std::string android_media_dir;
std::string android_mnt_expand_dir;
std::string android_profiles_dir;
std::string android_root_dir;
std::string android_staging_dir;
std::vector<std::string> android_system_dirs;
bool init_globals_from_data_and_root() {
const char* data_path = getenv("ANDROID_DATA");
if (data_path == nullptr) {
LOG(ERROR) << "Could not find ANDROID_DATA";
return false;
}
const char* root_path = getenv("ANDROID_ROOT");
if (root_path == nullptr) {
LOG(ERROR) << "Could not find ANDROID_ROOT";
return false;
}
return init_globals_from_data_and_root(data_path, root_path);
}
static std::string ensure_trailing_slash(const std::string& path) {
if (path.rfind('/') != path.size() - 1) {
return path + '/';
} else {
return path;
}
}
bool init_globals_from_data_and_root(const char* data, const char* root) {
// Get the android data directory.
android_data_dir = ensure_trailing_slash(data);
// Get the android root directory.
android_root_dir = ensure_trailing_slash(root);
// Get the android app directory.
android_app_dir = android_data_dir + APP_SUBDIR;
// Get the android protected app directory.
android_app_private_dir = android_data_dir + PRIVATE_APP_SUBDIR;
// Get the android ephemeral app directory.
android_app_ephemeral_dir = android_data_dir + EPHEMERAL_APP_SUBDIR;
// Get the android app native library directory.
android_app_lib_dir = android_data_dir + APP_LIB_SUBDIR;
// Get the sd-card ASEC mount point.
android_asec_dir = ensure_trailing_slash(getenv(ASEC_MOUNTPOINT_ENV_NAME));
// Get the android media directory.
android_media_dir = android_data_dir + MEDIA_SUBDIR;
// Get the android external app directory.
android_mnt_expand_dir = "/mnt/expand/";
// Get the android profiles directory.
android_profiles_dir = android_data_dir + PROFILES_SUBDIR;
// Get the android session staging directory.
android_staging_dir = android_data_dir + STAGING_SUBDIR;
// Take note of the system and vendor directories.
android_system_dirs.clear();
android_system_dirs.push_back(android_root_dir + APP_SUBDIR);
android_system_dirs.push_back(android_root_dir + PRIV_APP_SUBDIR);
android_system_dirs.push_back("/vendor/app/");
android_system_dirs.push_back("/oem/app/");
return true;
}
} // namespace installd
} // namespace android
|