Why is the android app size in app details larger than the actual apk size?

28 Views Asked by At

I build a apk into custom rom, then flash to my device The apk size 99M,but it show in settings->App Info->Storage->App size is 214M, it is big larger than apk size. I see the getAppSize source code here: https://cs.android.com/android/platform/superproject/main/+/main:frameworks/native/cmds/installd/InstalldNativeService.cpp;l=2523;bpv=0;bpt=1 it will call:

if (flags & FLAG_USE_QUOTA && appId >= AID_APP_START && !ownsExternalStorage(appId)) {
        atrace_pm_begin("code");
        for (const auto& codePath : codePaths) {
            calculate_tree_size(codePath, &stats.codeSize, -1,
                    multiuser_get_shared_gid(0, appId));
        }
        atrace_pm_end();

        atrace_pm_begin("quota");
        collectQuotaStats(uuidString, userId, appId, &stats, &extStats);
        atrace_pm_end();
    }

collectQuotaStats function will call:

        int sharedGid = multiuser_get_shared_gid(0, appId);
        if (sharedGid != -1) {
            if ((space = GetOccupiedSpaceForGid(uuid, sharedGid)) != -1) {
                stats->codeSize += space;
            }
        }

At here, some app will get zero, some app will return a number greater than 0 So i want to know why some app will return a number greater than 0?

I have read this reference and try to find reason

https://source.android.com/docs/core/storage/faster-stats?hl=zh-cn https://android.stackexchange.com/questions/217911/can-disk-quotas-be-disabled

0

There are 0 best solutions below