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

Commit ad2153b3 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Assign all flags during initial package scan or update." into tm-qpr-dev

parents 071f3115 dde0b629
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -427,8 +427,7 @@ final class ScanPackageUtils {
        pkgSetting.setLastModifiedTime(scanFileTime);
        // TODO(b/135203078): Remove, move to constructor
        pkgSetting.setPkg(parsedPackage)
                .setFlags(PackageInfoUtils.appInfoFlags(parsedPackage, pkgSetting))
                .setPrivateFlags(
                .setPkgFlags(PackageInfoUtils.appInfoFlags(parsedPackage, pkgSetting),
                        PackageInfoUtils.appInfoPrivateFlags(parsedPackage, pkgSetting));
        if (parsedPackage.getLongVersionCode() != pkgSetting.getVersionCode()) {
            pkgSetting.setLongVersionCode(parsedPackage.getLongVersionCode());
+11 −0
Original line number Diff line number Diff line
@@ -146,6 +146,17 @@ public abstract class SettingBase implements Watchable, Snappable {
        return this;
    }

    /**
     * Unconditionally set both mPkgFlags and mPkgPrivateFlags.
     * Should not be used outside pkgSetting initialization or update.
     */
    SettingBase setPkgFlags(int flags, int privateFlags) {
        this.mPkgFlags = flags;
        this.mPkgPrivateFlags = privateFlags;
        onChanged();
        return this;
    }

    public int getFlags() {
        return mPkgFlags;
    }
+11 −14
Original line number Diff line number Diff line
@@ -987,8 +987,7 @@ public final class Settings implements Watchable, Snappable {
                    // Update new package state.
                    .setLastModifiedTime(codePath.lastModified())
                    .setDomainSetId(domainSetId);
            pkgSetting.setFlags(pkgFlags)
                    .setPrivateFlags(pkgPrivateFlags);
            pkgSetting.setPkgFlags(pkgFlags, pkgPrivateFlags);
        } else {
            pkgSetting = new PackageSetting(pkgName, realPkgName, codePath,
                    legacyNativeLibraryPath, primaryCpuAbi, secondaryCpuAbi,
@@ -1175,15 +1174,15 @@ public final class Settings implements Watchable, Snappable {
                    .setUsesStaticLibrariesVersions(null);
        }

        // These two flags are preserved from the existing PackageSetting. Copied from prior code,
        // unclear if this is actually necessary.
        boolean wasExternalStorage = (pkgSetting.getFlags()
                & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0;
        if (wasExternalStorage) {
            pkgFlags |= ApplicationInfo.FLAG_EXTERNAL_STORAGE;
        } else {
            pkgFlags &= ~ApplicationInfo.FLAG_EXTERNAL_STORAGE;
        }
        // If what we are scanning is a system (and possibly privileged) package,
        // then make it so, regardless of whether it was previously installed only
        // in the data partition. Reset first.
        int newPkgFlags = pkgSetting.getFlags();
        newPkgFlags &= ~ApplicationInfo.FLAG_SYSTEM;
        newPkgFlags |= pkgFlags & ApplicationInfo.FLAG_SYSTEM;
        // Only set pkgFlags.
        pkgSetting.setPkgFlags(newPkgFlags, pkgSetting.getPrivateFlags());

        boolean wasRequiredForSystemUser = (pkgSetting.getPrivateFlags()
                & ApplicationInfo.PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER) != 0;
        if (wasRequiredForSystemUser) {
@@ -1191,9 +1190,7 @@ public final class Settings implements Watchable, Snappable {
        } else {
            pkgPrivateFlags &= ~ApplicationInfo.PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER;
        }

        pkgSetting.setFlags(pkgFlags)
                .setPrivateFlags(pkgPrivateFlags);
        pkgSetting.setPrivateFlags(pkgPrivateFlags);
    }

    /**