Merge "SF: Apply translations to transparent region" into nyc-dev
diff --git a/cmds/installd/commands.cpp b/cmds/installd/commands.cpp
index 90ef277..34b570a 100644
--- a/cmds/installd/commands.cpp
+++ b/cmds/installd/commands.cpp
@@ -315,9 +315,9 @@
// Copy app
{
- std::string from(create_data_app_package_path(from_uuid, data_app_name));
- std::string to(create_data_app_package_path(to_uuid, data_app_name));
- std::string to_parent(create_data_app_path(to_uuid));
+ auto from = create_data_app_package_path(from_uuid, data_app_name);
+ auto to = create_data_app_package_path(to_uuid, data_app_name);
+ auto to_parent = create_data_app_path(to_uuid);
char *argv[] = {
(char*) kCpPath,
@@ -346,27 +346,18 @@
}
// Copy private data for all known users
- // TODO: handle user_de paths
for (auto user : users) {
- std::string from(create_data_user_ce_package_path(from_uuid, user, package_name));
- std::string to(create_data_user_ce_package_path(to_uuid, user, package_name));
- std::string to_parent(create_data_user_ce_path(to_uuid, user));
// Data source may not exist for all users; that's okay
- if (access(from.c_str(), F_OK) != 0) {
- LOG(INFO) << "Missing source " << from;
+ auto from_ce = create_data_user_ce_package_path(from_uuid, user, package_name);
+ if (access(from_ce.c_str(), F_OK) != 0) {
+ LOG(INFO) << "Missing source " << from_ce;
continue;
}
- std::string user_path(create_data_user_ce_path(to_uuid, user));
- if (fs_prepare_dir(user_path.c_str(), 0771, AID_SYSTEM, AID_SYSTEM) != 0) {
- LOG(ERROR) << "Failed to prepare user target " << user_path;
- goto fail;
- }
-
if (create_app_data(to_uuid, package_name, user, FLAG_STORAGE_CE | FLAG_STORAGE_DE,
appid, seinfo, target_sdk_version) != 0) {
- LOG(ERROR) << "Failed to create package target " << to;
+ LOG(ERROR) << "Failed to create package target on " << to_uuid;
goto fail;
}
@@ -377,17 +368,35 @@
(char*) "-R", /* recurse into subdirectories (DEST must be a directory) */
(char*) "-P", /* Do not follow symlinks [default] */
(char*) "-d", /* don't dereference symlinks */
- (char*) from.c_str(),
- (char*) to_parent.c_str()
+ nullptr,
+ nullptr
};
- LOG(DEBUG) << "Copying " << from << " to " << to;
- int rc = android_fork_execvp(ARRAY_SIZE(argv), argv, NULL, false, true);
+ {
+ auto from = create_data_user_de_package_path(from_uuid, user, package_name);
+ auto to = create_data_user_de_path(to_uuid, user);
+ argv[6] = (char*) from.c_str();
+ argv[7] = (char*) to.c_str();
- if (rc != 0) {
- LOG(ERROR) << "Failed copying " << from << " to " << to
- << ": status " << rc;
- goto fail;
+ LOG(DEBUG) << "Copying " << from << " to " << to;
+ int rc = android_fork_execvp(ARRAY_SIZE(argv), argv, NULL, false, true);
+ if (rc != 0) {
+ LOG(ERROR) << "Failed copying " << from << " to " << to << " with status " << rc;
+ goto fail;
+ }
+ }
+ {
+ auto from = create_data_user_ce_package_path(from_uuid, user, package_name);
+ auto to = create_data_user_ce_path(to_uuid, user);
+ argv[6] = (char*) from.c_str();
+ argv[7] = (char*) to.c_str();
+
+ LOG(DEBUG) << "Copying " << from << " to " << to;
+ int rc = android_fork_execvp(ARRAY_SIZE(argv), argv, NULL, false, true);
+ if (rc != 0) {
+ LOG(ERROR) << "Failed copying " << from << " to " << to << " with status " << rc;
+ goto fail;
+ }
}
if (restorecon_app_data(to_uuid, package_name, user, FLAG_STORAGE_CE | FLAG_STORAGE_DE,
@@ -405,15 +414,23 @@
fail:
// Nuke everything we might have already copied
{
- std::string to(create_data_app_package_path(to_uuid, data_app_name));
+ auto to = create_data_app_package_path(to_uuid, data_app_name);
if (delete_dir_contents(to.c_str(), 1, NULL) != 0) {
LOG(WARNING) << "Failed to rollback " << to;
}
}
for (auto user : users) {
- std::string to(create_data_user_ce_package_path(to_uuid, user, package_name));
- if (delete_dir_contents(to.c_str(), 1, NULL) != 0) {
- LOG(WARNING) << "Failed to rollback " << to;
+ {
+ auto to = create_data_user_de_package_path(to_uuid, user, package_name);
+ if (delete_dir_contents(to.c_str(), 1, NULL) != 0) {
+ LOG(WARNING) << "Failed to rollback " << to;
+ }
+ }
+ {
+ auto to = create_data_user_ce_package_path(to_uuid, user, package_name);
+ if (delete_dir_contents(to.c_str(), 1, NULL) != 0) {
+ LOG(WARNING) << "Failed to rollback " << to;
+ }
}
}
return -1;
@@ -452,16 +469,11 @@
* also require that apps constantly modify file metadata even
* when just reading from the cache, which is pretty awful.
*/
-int free_cache(const char *uuid, int64_t free_size)
-{
+int free_cache(const char *uuid, int64_t free_size) {
cache_t* cache;
int64_t avail;
- DIR *d;
- struct dirent *de;
- char tmpdir[PATH_MAX];
- char *dirpos;
- std::string data_path(create_data_path(uuid));
+ auto data_path = create_data_path(uuid);
avail = data_disk_free(data_path);
if (avail < 0) return -1;
@@ -471,65 +483,12 @@
cache = start_cache_collection();
- // Special case for owner on internal storage
- if (uuid == nullptr) {
- std::string _tmpdir(create_data_user_ce_path(nullptr, 0));
- add_cache_files(cache, _tmpdir.c_str(), "cache");
- }
-
- // Search for other users and add any cache files from them.
- std::string _tmpdir(create_data_path(uuid) + "/" + SECONDARY_USER_PREFIX);
- strcpy(tmpdir, _tmpdir.c_str());
-
- dirpos = tmpdir + strlen(tmpdir);
- d = opendir(tmpdir);
- if (d != NULL) {
- while ((de = readdir(d))) {
- if (de->d_type == DT_DIR) {
- const char *name = de->d_name;
- /* always skip "." and ".." */
- if (name[0] == '.') {
- if (name[1] == 0) continue;
- if ((name[1] == '.') && (name[2] == 0)) continue;
- }
- if ((strlen(name)+(dirpos-tmpdir)) < (sizeof(tmpdir)-1)) {
- strcpy(dirpos, name);
- //ALOGI("adding cache files from %s\n", tmpdir);
- add_cache_files(cache, tmpdir, "cache");
- } else {
- ALOGW("Path exceeds limit: %s%s", tmpdir, name);
- }
- }
- }
- closedir(d);
- }
-
- // Collect cache files on external storage for all users (if it is mounted as part
- // of the internal storage).
- strcpy(tmpdir, android_media_dir.path);
- dirpos = tmpdir + strlen(tmpdir);
- d = opendir(tmpdir);
- if (d != NULL) {
- while ((de = readdir(d))) {
- if (de->d_type == DT_DIR) {
- const char *name = de->d_name;
- /* skip any dir that doesn't start with a number, so not a user */
- if (name[0] < '0' || name[0] > '9') {
- continue;
- }
- if ((strlen(name)+(dirpos-tmpdir)) < (sizeof(tmpdir)-1)) {
- strcpy(dirpos, name);
- if (lookup_media_dir(tmpdir, "Android") == 0
- && lookup_media_dir(tmpdir, "data") == 0) {
- //ALOGI("adding cache files from %s\n", tmpdir);
- add_cache_files(cache, tmpdir, "cache");
- }
- } else {
- ALOGW("Path exceeds limit: %s%s", tmpdir, name);
- }
- }
- }
- closedir(d);
+ auto users = get_known_users(uuid);
+ for (auto user : users) {
+ add_cache_files(cache, create_data_user_ce_path(uuid, user));
+ add_cache_files(cache, create_data_user_de_path(uuid, user));
+ add_cache_files(cache,
+ StringPrintf("%s/Android/data", create_data_media_path(uuid, user).c_str()));
}
clear_cache_files(data_path, cache, free_size);
diff --git a/cmds/installd/utils.cpp b/cmds/installd/utils.cpp
index 90d2a9e..c838993 100644
--- a/cmds/installd/utils.cpp
+++ b/cmds/installd/utils.cpp
@@ -521,56 +521,6 @@
return res;
}
-int lookup_media_dir(char basepath[PATH_MAX], const char *dir)
-{
- DIR *d;
- struct dirent *de;
- struct stat s;
- char* dirpos = basepath + strlen(basepath);
-
- if ((*(dirpos-1)) != '/') {
- *dirpos = '/';
- dirpos++;
- }
-
- CACHE_NOISY(ALOGI("Looking up %s in %s\n", dir, basepath));
- // Verify the path won't extend beyond our buffer, to avoid
- // repeated checking later.
- if ((dirpos-basepath+strlen(dir)) >= (PATH_MAX-1)) {
- ALOGW("Path exceeds limit: %s%s", basepath, dir);
- return -1;
- }
-
- // First, can we find this directory with the case that is given?
- strcpy(dirpos, dir);
- if (stat(basepath, &s) >= 0) {
- CACHE_NOISY(ALOGI("Found direct: %s\n", basepath));
- return 0;
- }
-
- // Not found with that case... search through all entries to find
- // one that matches regardless of case.
- *dirpos = 0;
-
- d = opendir(basepath);
- if (d == NULL) {
- return -1;
- }
-
- while ((de = readdir(d))) {
- if (strcasecmp(de->d_name, dir) == 0) {
- strcpy(dirpos, de->d_name);
- closedir(d);
- CACHE_NOISY(ALOGI("Found search: %s\n", basepath));
- return 0;
- }
- }
-
- ALOGW("Couldn't find %s in %s", dir, basepath);
- closedir(d);
- return -1;
-}
-
int64_t data_disk_free(const std::string& data_path)
{
struct statfs sfs;
@@ -829,13 +779,13 @@
return 0;
}
-void add_cache_files(cache_t* cache, const char *basepath, const char *cachedir)
-{
+void add_cache_files(cache_t* cache, const std::string& data_path) {
DIR *d;
struct dirent *de;
char dirname[PATH_MAX];
- CACHE_NOISY(ALOGI("add_cache_files: base=%s cachedir=%s\n", basepath, cachedir));
+ const char* basepath = data_path.c_str();
+ CACHE_NOISY(ALOGI("add_cache_files: basepath=%s\n", basepath));
d = opendir(basepath);
if (d == NULL) {
@@ -861,12 +811,11 @@
pathpos++;
*pathpos = 0;
}
- if (cachedir != NULL) {
- snprintf(pathpos, sizeof(dirname)-(pathpos-dirname), "%s/%s", name, cachedir);
- } else {
- snprintf(pathpos, sizeof(dirname)-(pathpos-dirname), "%s", name);
- }
+
+ // TODO: also try searching using xattr when CE is locked
+ snprintf(pathpos, sizeof(dirname)-(pathpos-dirname), "%s/cache", name);
CACHE_NOISY(ALOGI("Adding cache files from dir: %s\n", dirname));
+
subdir = opendir(dirname);
if (subdir != NULL) {
size_t dirnameLen = strlen(dirname);
diff --git a/cmds/installd/utils.h b/cmds/installd/utils.h
index 477baea..60df356 100644
--- a/cmds/installd/utils.h
+++ b/cmds/installd/utils.h
@@ -114,13 +114,11 @@
int copy_dir_files(const char *srcname, const char *dstname, uid_t owner, gid_t group);
-int lookup_media_dir(char basepath[PATH_MAX], const char *dir);
-
int64_t data_disk_free(const std::string& data_path);
cache_t* start_cache_collection();
-void add_cache_files(cache_t* cache, const char *basepath, const char *cachedir);
+void add_cache_files(cache_t* cache, const std::string& data_path);
void clear_cache_files(const std::string& data_path, cache_t* cache, int64_t free_size);
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 96252f3..ed320cb 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -1820,6 +1820,7 @@
// NOTE: We don't need to hold the transaction lock here
// because State::active is only accessed from this thread.
current.active = front.active;
+ current.modified = true;
// recompute visible region
recomputeVisibleRegions = true;