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

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19324069

Change-Id: Ie172f1e285a7cd89b67caa50badfe77cd65941d4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2022-07-21 13:46:35 +00:00
committed by Automerger Merge Worker
3 changed files with 23 additions and 16 deletions

View File

@@ -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());

View File

@@ -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;
}

View File

@@ -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);
}
/**