diff options
| author | 2021-12-06 09:29:55 +0000 | |
|---|---|---|
| committer | 2021-12-06 09:29:55 +0000 | |
| commit | 26c6a3e0f669441e945d55fc96667a081969487f (patch) | |
| tree | 8cf81a997fe78f81fd8b75178a7e8105aa81bd3d /cmds/installd/InstalldNativeService.cpp | |
| parent | 0a6c981d8652c1f9b05c29d8030a9d38fd530de8 (diff) | |
| parent | aae9644cebfa6a6fc8787c75711d21586549450f (diff) | |
Merge "Manually calculate stats for app owning external storage"
Diffstat (limited to 'cmds/installd/InstalldNativeService.cpp')
| -rw-r--r-- | cmds/installd/InstalldNativeService.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp index 373a70ad2d..94c4c8cda0 100644 --- a/cmds/installd/InstalldNativeService.cpp +++ b/cmds/installd/InstalldNativeService.cpp @@ -1986,7 +1986,18 @@ static void collectManualExternalStatsForUser(const std::string& path, struct st } fts_close(fts); } - +static bool ownsExternalStorage(int32_t appId) { + // Fetch external storage owner appid and check if it is the same as the + // current appId whose size is calculated + struct stat s; + auto _picDir = StringPrintf("%s/Pictures", create_data_media_path(nullptr, 0).c_str()); + // check if the stat are present + if (stat(_picDir.c_str(), &s) == 0) { + // fetch the appId from the uid of the media app + return ((int32_t)multiuser_get_app_id(s.st_uid) == appId); + } + return false; +} binder::Status InstalldNativeService::getAppSize(const std::optional<std::string>& uuid, const std::vector<std::string>& packageNames, int32_t userId, int32_t flags, int32_t appId, const std::vector<int64_t>& ceDataInodes, @@ -2041,8 +2052,10 @@ binder::Status InstalldNativeService::getAppSize(const std::optional<std::string calculate_tree_size(obbCodePath, &extStats.codeSize); } ATRACE_END(); - - if (flags & FLAG_USE_QUOTA && appId >= AID_APP_START) { + // Calculating the app size of the external storage owning app in a manual way, since + // calculating it through quota apis also includes external media storage in the app storage + // numbers + if (flags & FLAG_USE_QUOTA && appId >= AID_APP_START && !ownsExternalStorage(appId)) { ATRACE_BEGIN("code"); for (const auto& codePath : codePaths) { calculate_tree_size(codePath, &stats.codeSize, -1, |