Fix profile disk space accounting bugs.
Profile data is only stored on internal storage (it doesn't move to
adoptable devices), so only count it when asking about internal
storage (which has a null UUID).
Also fix bug where "current" profile data was being double-counted
for apps.
Test: runtest -x frameworks/base/services/tests/servicestests/src/com/android/server/pm/InstallerTest.java
Bug: 36102172, 36101738
Change-Id: I22b82e8cfb3bf1be1155fb827a538c21f09d88eb
diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp
index 3e0f6f0..4946b4d 100644
--- a/cmds/installd/InstalldNativeService.cpp
+++ b/cmds/installd/InstalldNativeService.cpp
@@ -1395,12 +1395,16 @@
collectManualStats(dePath, &stats);
ATRACE_END();
- ATRACE_BEGIN("profiles");
- auto userProfilePath = create_primary_current_profile_package_dir_path(userId, pkgname);
- calculate_tree_size(userProfilePath, &stats.dataSize);
- auto refProfilePath = create_primary_reference_profile_package_dir_path(pkgname);
- calculate_tree_size(refProfilePath, &stats.codeSize);
- ATRACE_END();
+ if (!uuid) {
+ ATRACE_BEGIN("profiles");
+ calculate_tree_size(
+ create_primary_current_profile_package_dir_path(userId, pkgname),
+ &stats.dataSize);
+ calculate_tree_size(
+ create_primary_reference_profile_package_dir_path(pkgname),
+ &stats.codeSize);
+ ATRACE_END();
+ }
ATRACE_BEGIN("external");
auto extPath = create_data_media_package_path(uuid_, userId, "data", pkgname);
@@ -1410,15 +1414,15 @@
ATRACE_END();
}
- ATRACE_BEGIN("dalvik");
- int32_t sharedGid = multiuser_get_shared_gid(userId, appId);
- if (sharedGid != -1) {
- calculate_tree_size(create_data_dalvik_cache_path(), &stats.codeSize,
- sharedGid, -1);
+ if (!uuid) {
+ ATRACE_BEGIN("dalvik");
+ int32_t sharedGid = multiuser_get_shared_gid(userId, appId);
+ if (sharedGid != -1) {
+ calculate_tree_size(create_data_dalvik_cache_path(), &stats.codeSize,
+ sharedGid, -1);
+ }
+ ATRACE_END();
}
- calculate_tree_size(create_primary_cur_profile_dir_path(userId), &stats.dataSize,
- multiuser_get_uid(userId, appId), -1);
- ATRACE_END();
}
std::vector<int64_t> ret;
@@ -1496,12 +1500,14 @@
collectManualStatsForUser(dePath, &stats, true);
ATRACE_END();
- ATRACE_BEGIN("profile");
- auto userProfilePath = create_primary_cur_profile_dir_path(userId);
- calculate_tree_size(userProfilePath, &stats.dataSize, -1, -1, true);
- auto refProfilePath = create_primary_ref_profile_dir_path();
- calculate_tree_size(refProfilePath, &stats.codeSize, -1, -1, true);
- ATRACE_END();
+ if (!uuid) {
+ ATRACE_BEGIN("profile");
+ auto userProfilePath = create_primary_cur_profile_dir_path(userId);
+ calculate_tree_size(userProfilePath, &stats.dataSize, -1, -1, true);
+ auto refProfilePath = create_primary_ref_profile_dir_path();
+ calculate_tree_size(refProfilePath, &stats.codeSize, -1, -1, true);
+ ATRACE_END();
+ }
ATRACE_BEGIN("external");
uid_t uid = multiuser_get_uid(userId, AID_MEDIA_RW);
@@ -1518,12 +1524,14 @@
}
ATRACE_END();
- ATRACE_BEGIN("dalvik");
- calculate_tree_size(create_data_dalvik_cache_path(), &stats.codeSize,
- -1, -1, true);
- calculate_tree_size(create_primary_cur_profile_dir_path(userId), &stats.dataSize,
- -1, -1, true);
- ATRACE_END();
+ if (!uuid) {
+ ATRACE_BEGIN("dalvik");
+ calculate_tree_size(create_data_dalvik_cache_path(), &stats.codeSize,
+ -1, -1, true);
+ calculate_tree_size(create_primary_cur_profile_dir_path(userId), &stats.dataSize,
+ -1, -1, true);
+ ATRACE_END();
+ }
ATRACE_BEGIN("quota");
for (auto appId : appIds) {
@@ -1554,12 +1562,14 @@
collectManualStatsForUser(dePath, &stats);
ATRACE_END();
- ATRACE_BEGIN("profile");
- auto userProfilePath = create_primary_cur_profile_dir_path(userId);
- calculate_tree_size(userProfilePath, &stats.dataSize);
- auto refProfilePath = create_primary_ref_profile_dir_path();
- calculate_tree_size(refProfilePath, &stats.codeSize);
- ATRACE_END();
+ if (!uuid) {
+ ATRACE_BEGIN("profile");
+ auto userProfilePath = create_primary_cur_profile_dir_path(userId);
+ calculate_tree_size(userProfilePath, &stats.dataSize);
+ auto refProfilePath = create_primary_ref_profile_dir_path();
+ calculate_tree_size(refProfilePath, &stats.codeSize);
+ ATRACE_END();
+ }
ATRACE_BEGIN("external");
auto dataMediaPath = create_data_media_path(uuid_, userId);
@@ -1570,10 +1580,12 @@
#endif
ATRACE_END();
- ATRACE_BEGIN("dalvik");
- calculate_tree_size(create_data_dalvik_cache_path(), &stats.codeSize);
- calculate_tree_size(create_primary_cur_profile_dir_path(userId), &stats.dataSize);
- ATRACE_END();
+ if (!uuid) {
+ ATRACE_BEGIN("dalvik");
+ calculate_tree_size(create_data_dalvik_cache_path(), &stats.codeSize);
+ calculate_tree_size(create_primary_cur_profile_dir_path(userId), &stats.dataSize);
+ ATRACE_END();
+ }
}
std::vector<int64_t> ret;