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

Commit ae3e9ae7 authored by hyejin.kim's avatar hyejin.kim
Browse files

Adjust obb path to be able calculate external's codeSize well wo/quota

Without quota, installd doesn't not calculate codeSize correctly
use Android/obb, So we adjust to Android/obb.
And we needed to remove external's codeSize from dataSize.

- Test: run cts -m CtsAppSecurityHostTestCases
        -t android.appsecurity.cts.StorageHostTest#testVerifyStats

Change-Id: I253c62ef4a9171242e10c0bcf57047c207278868
parent f7752a2f
Loading
Loading
Loading
Loading
+14 −10
Original line number Diff line number Diff line
@@ -2374,11 +2374,15 @@ static void collectManualExternalStatsForUser(const std::string& path, struct st
        p->fts_number = p->fts_parent->fts_number;
        switch (p->fts_info) {
        case FTS_D:
            if (p->fts_level == 4
            if (p->fts_level == 3
                    && !strcmp(p->fts_parent->fts_name, "obb")
                    && !strcmp(p->fts_parent->fts_parent->fts_name, "Android")) {
                p->fts_number = 1;
            } else if (p->fts_level == 4
                    && !strcmp(p->fts_name, "cache")
                    && !strcmp(p->fts_parent->fts_parent->fts_name, "data")
                    && !strcmp(p->fts_parent->fts_parent->fts_parent->fts_name, "Android")) {
                p->fts_number = 1;
                p->fts_number = 2;
            }
            [[fallthrough]]; // to count the directory
        case FTS_DEFAULT:
@@ -2387,9 +2391,13 @@ static void collectManualExternalStatsForUser(const std::string& path, struct st
        case FTS_SLNONE:
            int64_t size = (p->fts_statp->st_blocks * 512);
            if (p->fts_number == 1) {
                stats->codeSize += size;
            } else {
                if (p->fts_number == 2) {
                    stats->cacheSize += size;
                }
                stats->dataSize += size;
            }
            break;
        }
    }
@@ -2735,11 +2743,6 @@ binder::Status InstalldNativeService::getUserSize(const std::optional<std::strin
        extStats.dataSize = dataSize;
        atrace_pm_end();
    } else {
        atrace_pm_begin("obb");
        auto obbPath = create_data_path(uuid_) + "/media/obb";
        calculate_tree_size(obbPath, &extStats.codeSize);
        atrace_pm_end();

        atrace_pm_begin("code");
        calculate_tree_size(create_data_app_path(uuid_), &stats.codeSize);
        atrace_pm_end();
@@ -2770,9 +2773,10 @@ binder::Status InstalldNativeService::getUserSize(const std::optional<std::strin
        atrace_pm_begin("external");
        auto dataMediaPath = create_data_media_path(uuid_, userId);
        collectManualExternalStatsForUser(dataMediaPath, &extStats);

#if MEASURE_DEBUG
        LOG(DEBUG) << "Measured external data " << extStats.dataSize << " cache "
                << extStats.cacheSize;
                << extStats.cacheSize << " code " << extStats.codeSize;
#endif
        atrace_pm_end();