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

Commit bdcce366 authored by William Loh's avatar William Loh
Browse files

Create app metadata folder only when needed

Only create app metadata folder for system apps if the source is apk and
the folder does not already exist.

Bug: 338174039
Test: atest InstallAppMetadataTest
Change-Id: Ib358f44c093d9c0197fab788697fe54def18c41b
parent ed3993e1
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -1667,15 +1667,6 @@ public class PackageManagerServiceUtils {
        if (appMetadataFile.exists()) {
            return true;
        }
        if (isSystem) {
            try {
                makeDirRecursive(new File(appMetadataFilePath).getParentFile(), 0700);
            } catch (Exception e) {
                Slog.e(TAG, "Failed to create app metadata dir for package "
                        + pkg.getPackageName() + ": " + e.getMessage());
                return false;
            }
        }
        Map<String, Property> properties = pkg.getProperties();
        if (!properties.containsKey(PROPERTY_ANDROID_SAFETY_LABEL_PATH)) {
            return false;
@@ -1684,6 +1675,15 @@ public class PackageManagerServiceUtils {
        if (!fileInAPkPathProperty.isString()) {
            return false;
        }
        if (isSystem && !appMetadataFile.getParentFile().exists()) {
            try {
                makeDirRecursive(appMetadataFile.getParentFile(), 0700);
            } catch (Exception e) {
                Slog.e(TAG, "Failed to create app metadata dir for package "
                        + pkg.getPackageName() + ": " + e.getMessage());
                return false;
            }
        }
        String fileInApkPath = fileInAPkPathProperty.getString();
        List<AndroidPackageSplit> splits = pkg.getSplits();
        for (int i = 0; i < splits.size(); i++) {