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

Commit c3138f87 authored by Songchun Fan's avatar Songchun Fan
Browse files

[StorageStats] support apps uninstalled with DELETE_KEEP_DATA

codePath can be null for apps uninstalled with DELETE_KEEP_DATA. The
downstream code would crash if there's a null inside the codePaths
array passed into Installer.getAppSize.

Also makes sure that the correct storageUuid and data dir is preserved
in the PackageInfo query result.

BUG: 288142708
Test: manually tested with test code and verified it doesn't crash
Test: to be added in cts
Change-Id: If7cb1c3cba7a66994780a65c7aa3884889e16c65
parent 9994945d
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import static android.content.ContentProvider.isAuthorityRedirectedForCloneProfi
import static android.content.Intent.ACTION_MAIN;
import static android.content.Intent.CATEGORY_DEFAULT;
import static android.content.Intent.CATEGORY_HOME;
import static android.content.pm.ApplicationInfo.PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE;
import static android.content.pm.PackageManager.CERT_INPUT_RAW_X509;
import static android.content.pm.PackageManager.CERT_INPUT_SHA256;
import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
@@ -1514,6 +1515,11 @@ public class ComputerEngine implements Computer {
            ai.uid = UserHandle.getUid(userId, ps.getAppId());
            ai.primaryCpuAbi = ps.getPrimaryCpuAbiLegacy();
            ai.secondaryCpuAbi = ps.getSecondaryCpuAbiLegacy();
            ai.volumeUuid = ps.getVolumeUuid();
            ai.storageUuid = StorageManager.convert(ai.volumeUuid);
            if (ps.isDefaultToDeviceProtectedStorage()) {
                ai.privateFlags |= PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE;
            }
            ai.setVersionCode(ps.getVersionCode());
            ai.flags = ps.getFlags();
            ai.privateFlags = ps.getPrivateFlags();
+7 −3
Original line number Diff line number Diff line
@@ -364,9 +364,11 @@ public class StorageStatsService extends IStorageStatsManager.Stub {
            if (appInfo.isSystemApp() && !appInfo.isUpdatedSystemApp()) {
                // We don't count code baked into system image
            } else {
                if (appInfo.getCodePath() != null) {
                    codePaths = ArrayUtils.appendElement(String.class, codePaths,
                        appInfo.getCodePath());
                }
            }

            final PackageStats stats = new PackageStats(TAG);
            try {
@@ -418,9 +420,11 @@ public class StorageStatsService extends IStorageStatsManager.Stub {
                if (appInfo.isSystemApp() && !appInfo.isUpdatedSystemApp()) {
                    // We don't count code baked into system image
                } else {
                    if (appInfo.getCodePath() != null) {
                        codePaths = ArrayUtils.appendElement(String.class, codePaths,
                                appInfo.getCodePath());
                    }
                }
            } catch (NameNotFoundException e) {
                throw new ParcelableException(e);
            }