Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b0eaeec2 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Measure and clean up new "sandbox" directories.

The new storage model in Q creates "sandbox" directories that belong
to specific apps.  To keep existing CTS working, we need to measure
and clean up these sandboxes.

Future changes will add support for shared UIDs.

Bug: 112545973
Test: atest android.appsecurity.cts.StorageHostTest
Change-Id: I79fb44982ed97a33f1c6e61d74837bfe54a9a651
parent 36607ad0
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -562,6 +562,10 @@ binder::Status InstalldNativeService::clearAppData(const std::unique_ptr<std::st
            // No code cache on shared storage
        } else {
            // Clear everything on shared storage
            path = StringPrintf("%s/Android/sandbox/%s", extPath.c_str(), pkgname);
            if (delete_dir_contents(path, true) != 0) {
                res = error("Failed to delete contents of " + path);
            }
            path = StringPrintf("%s/Android/data/%s", extPath.c_str(), pkgname);
            if (delete_dir_contents(path, true) != 0) {
                res = error("Failed to delete contents of " + path);
@@ -645,6 +649,10 @@ binder::Status InstalldNativeService::destroyAppData(const std::unique_ptr<std::
        }

        auto extPath = findDataMediaPath(uuid, userId);
        path = StringPrintf("%s/Android/sandbox/%s", extPath.c_str(), pkgname);
        if (delete_dir_contents_and_dir(path, true) != 0) {
            res = error("Failed to delete " + path);
        }
        path = StringPrintf("%s/Android/data/%s", extPath.c_str(), pkgname);
        if (delete_dir_contents_and_dir(path, true) != 0) {
            res = error("Failed to delete " + path);
@@ -1491,6 +1499,8 @@ binder::Status InstalldNativeService::getAppSize(const std::unique_ptr<std::stri
            }

            ATRACE_BEGIN("external");
            auto sandboxPath = create_data_media_package_path(uuid_, userId, "sandbox", pkgname);
            calculate_tree_size(sandboxPath, &extStats.dataSize);
            auto extPath = create_data_media_package_path(uuid_, userId, "data", pkgname);
            collectManualStats(extPath, &extStats);
            auto mediaPath = create_data_media_package_path(uuid_, userId, "media", pkgname);