Loading services/core/java/com/android/server/pm/PackageSetting.java +13 −27 Original line number Diff line number Diff line Loading @@ -238,34 +238,16 @@ public class PackageSetting extends SettingBase implements PackageStateInternal } @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) public PackageSetting(String name, String realName, @NonNull File path, String legacyNativeLibraryPath, String primaryCpuAbi, String secondaryCpuAbi, String cpuAbiOverride, long longVersionCode, int pkgFlags, int pkgPrivateFlags, int sharedUserAppId, String[] usesSdkLibraries, long[] usesSdkLibrariesVersionsMajor, String[] usesStaticLibraries, long[] usesStaticLibrariesVersions, Map<String, Set<String>> mimeGroups, @NonNull UUID domainSetId) { public PackageSetting(@NonNull String name, @Nullable String realName, @NonNull File path, int pkgFlags, int pkgPrivateFlags, @NonNull UUID domainSetId) { super(pkgFlags, pkgPrivateFlags); this.mName = name; this.mRealName = realName; this.usesSdkLibraries = usesSdkLibraries; this.usesSdkLibrariesVersionsMajor = usesSdkLibrariesVersionsMajor; this.usesStaticLibraries = usesStaticLibraries; this.usesStaticLibrariesVersions = usesStaticLibrariesVersions; this.mPath = path; this.mPathString = path.toString(); this.legacyNativeLibraryPath = legacyNativeLibraryPath; this.mPrimaryCpuAbi = primaryCpuAbi; this.mSecondaryCpuAbi = secondaryCpuAbi; this.mCpuAbiOverride = cpuAbiOverride; this.versionCode = longVersionCode; this.signatures = new PackageSignatures(); this.installSource = InstallSource.EMPTY; this.mSharedUserAppId = sharedUserAppId; mDomainSetId = domainSetId; copyMimeGroups(mimeGroups); this.mDomainSetId = domainSetId; mSnapshot = makeCache(); } Loading Loading @@ -536,9 +518,10 @@ public class PackageSetting extends SettingBase implements PackageStateInternal return this; } public void setSharedUserAppId(int sharedUserAppId) { public PackageSetting setSharedUserAppId(int sharedUserAppId) { mSharedUserAppId = sharedUserAppId; onChanged(); return this; } public PackageSetting setIsPersistent(boolean isPersistent) { Loading Loading @@ -576,7 +559,7 @@ public class PackageSetting extends SettingBase implements PackageStateInternal + " " + mName + "/" + mAppId + "}"; } protected void copyMimeGroups(@Nullable Map<String, Set<String>> newMimeGroups) { private void copyMimeGroups(@Nullable Map<String, Set<String>> newMimeGroups) { if (newMimeGroups == null) { mimeGroups = null; return; Loading Loading @@ -1250,7 +1233,8 @@ public class PackageSetting extends SettingBase implements PackageStateInternal /** * @see #mPath */ PackageSetting setPath(@NonNull File path) { @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) public PackageSetting setPath(@NonNull File path) { this.mPath = path; this.mPathString = path.toString(); onChanged(); Loading Loading @@ -1451,9 +1435,11 @@ public class PackageSetting extends SettingBase implements PackageStateInternal return this; } public PackageSetting setMimeGroups(@NonNull Map<String, Set<String>> mimeGroups) { this.mimeGroups = mimeGroups; public PackageSetting setMimeGroups(@Nullable Map<String, Set<String>> mimeGroups) { if (mimeGroups != null) { copyMimeGroups(mimeGroups); onChanged(); } return this; } Loading services/core/java/com/android/server/pm/Settings.java +88 −50 Original line number Diff line number Diff line Loading @@ -931,16 +931,24 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile sharedUserSetting.mDisabledPackages.remove(p); } p.getPkgState().setUpdatedSystemApp(false); PackageSetting ret = addPackageLPw(name, p.getRealName(), p.getPath(), p.getLegacyNativeLibraryPath(), p.getPrimaryCpuAbiLegacy(), p.getSecondaryCpuAbiLegacy(), p.getCpuAbiOverride(), p.getAppId(), p.getVersionCode(), p.getFlags(), p.getPrivateFlags(), p.getUsesSdkLibraries(), p.getUsesSdkLibrariesVersionsMajor(), p.getUsesStaticLibraries(), p.getUsesStaticLibrariesVersions(), p.getMimeGroups(), mDomainVerificationManager.generateNewId()); PackageSetting ret = addPackageLPw(name, p.getRealName(), p.getPath(), p.getAppId(), p.getFlags(), p.getPrivateFlags(), mDomainVerificationManager.generateNewId()); if (ret != null) { ret.setLegacyNativeLibraryPath(p.getLegacyNativeLibraryPath()); ret.setPrimaryCpuAbi(p.getPrimaryCpuAbiLegacy()); ret.setSecondaryCpuAbi(p.getSecondaryCpuAbiLegacy()); ret.setCpuAbiOverride(p.getCpuAbiOverride()); ret.setLongVersionCode(p.getVersionCode()); ret.setUsesSdkLibraries(p.getUsesSdkLibraries()); ret.setUsesSdkLibrariesVersionsMajor(p.getUsesSdkLibrariesVersionsMajor()); ret.setUsesStaticLibraries(p.getUsesStaticLibraries()); ret.setUsesStaticLibrariesVersions(p.getUsesStaticLibrariesVersions()); ret.setMimeGroups(p.getMimeGroups()); ret.setAppMetadataFilePath(p.getAppMetadataFilePath()); ret.getPkgState().setUpdatedSystemApp(false); ret.setIsPersistent(p.isPersistent()); ret.setTargetSdkVersion(p.getTargetSdkVersion()); ret.setRestrictUpdateHash(p.getRestrictUpdateHash()); } mDisabledSysPackages.remove(name); return ret; Loading @@ -961,13 +969,8 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile } } PackageSetting addPackageLPw(String name, String realName, File codePath, String legacyNativeLibraryPathString, String primaryCpuAbiString, String secondaryCpuAbiString, String cpuAbiOverrideString, int uid, long vc, int pkgFlags, int pkgPrivateFlags, String[] usesSdkLibraries, long[] usesSdkLibrariesVersions, String[] usesStaticLibraries, long[] usesStaticLibrariesVersions, Map<String, Set<String>> mimeGroups, @NonNull UUID domainSetId) { PackageSetting addPackageLPw(String name, String realName, File codePath, int uid, int pkgFlags, int pkgPrivateFlags, @NonNull UUID domainSetId) { PackageSetting p = mPackages.get(name); if (p != null) { if (p.getAppId() == uid) { Loading @@ -977,11 +980,8 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile "Adding duplicate package, keeping first: " + name); return null; } p = new PackageSetting(name, realName, codePath, legacyNativeLibraryPathString, primaryCpuAbiString, secondaryCpuAbiString, cpuAbiOverrideString, vc, pkgFlags, pkgPrivateFlags, 0 /*userId*/, usesSdkLibraries, usesSdkLibrariesVersions, usesStaticLibraries, usesStaticLibrariesVersions, mimeGroups, domainSetId); p.setAppId(uid); p = new PackageSetting(name, realName, codePath, pkgFlags, pkgPrivateFlags, domainSetId) .setAppId(uid); if (mAppIds.registerExistingAppId(uid, p, name)) { mPackages.put(name, p); return p; Loading Loading @@ -1092,16 +1092,21 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile int installUserId = installUser != null ? installUser.getIdentifier() : UserHandle.USER_SYSTEM; pkgSetting = new PackageSetting(pkgName, realPkgName, codePath, legacyNativeLibraryPath, primaryCpuAbi, secondaryCpuAbi, null /*cpuAbiOverrideString*/, versionCode, pkgFlags, pkgPrivateFlags, 0 /*sharedUserAppId*/, usesSdkLibraries, usesSdkLibrariesVersions, usesStaticLibraries, usesStaticLibrariesVersions, createMimeGroups(mimeGroupNames), domainSetId) pkgSetting = new PackageSetting(pkgName, realPkgName, codePath, pkgFlags, pkgPrivateFlags, domainSetId) .setUsesSdkLibraries(usesSdkLibraries) .setUsesSdkLibrariesVersionsMajor(usesSdkLibrariesVersions) .setUsesStaticLibraries(usesStaticLibraries) .setUsesStaticLibrariesVersions(usesStaticLibrariesVersions) .setLegacyNativeLibraryPath(legacyNativeLibraryPath) .setPrimaryCpuAbi(primaryCpuAbi) .setSecondaryCpuAbi(secondaryCpuAbi) .setLongVersionCode(versionCode) .setMimeGroups(createMimeGroups(mimeGroupNames)) .setIsPersistent(isPersistent) .setTargetSdkVersion(targetSdkVersion) .setRestrictUpdateHash(restrictUpdatedHash); pkgSetting.setLastModifiedTime(codePath.lastModified()); .setRestrictUpdateHash(restrictUpdatedHash) .setLastModifiedTime(codePath.lastModified()); if (sharedUser != null) { pkgSetting.setSharedUserAppId(sharedUser.mAppId); } Loading Loading @@ -3066,6 +3071,12 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile serializer.attributeLongHex(null, "ft", pkg.getLastModifiedTime()); serializer.attributeLongHex(null, "ut", pkg.getLastUpdateTime()); serializer.attributeLong(null, "version", pkg.getVersionCode()); serializer.attributeBoolean(null, "isPersistent", pkg.isPersistent()); serializer.attributeInt(null, "targetSdkVersion", pkg.getTargetSdkVersion()); if (pkg.getRestrictUpdateHash() != null) { serializer.attributeBytesBase64(null, "restrictUpdateHash", pkg.getRestrictUpdateHash()); } if (pkg.getLegacyNativeLibraryPath() != null) { serializer.attribute(null, "nativeLibraryPath", pkg.getLegacyNativeLibraryPath()); } Loading Loading @@ -3129,6 +3140,12 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile serializer.attributeLongHex(null, "ft", pkg.getLastModifiedTime()); serializer.attributeLongHex(null, "ut", pkg.getLastUpdateTime()); serializer.attributeLong(null, "version", pkg.getVersionCode()); serializer.attributeBoolean(null, "isPersistent", pkg.isPersistent()); serializer.attributeInt(null, "targetSdkVersion", pkg.getTargetSdkVersion()); if (pkg.getRestrictUpdateHash() != null) { serializer.attributeBytesBase64(null, "restrictUpdateHash", pkg.getRestrictUpdateHash()); } if (!pkg.hasSharedUser()) { serializer.attributeInt(null, "userId", pkg.getAppId()); } else { Loading Loading @@ -3861,6 +3878,10 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile } long versionCode = parser.getAttributeLong(null, "version", 0); boolean isPersistent = parser.getAttributeBoolean(null, "isPersistent", false); int targetSdkVersion = parser.getAttributeInt(null, "targetSdkVersion", 0); byte[] restrictUpdateHash = parser.getAttributeBytesBase64(null, "restrictUpdateHash", null); int pkgFlags = 0; int pkgPrivateFlags = 0; Loading @@ -3873,10 +3894,16 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile // debug invalid entries. The actual logic for migrating to a new ID is done in other // methods that use DomainVerificationManagerInternal#generateNewId UUID domainSetId = DomainVerificationManagerInternal.DISABLED_ID; PackageSetting ps = new PackageSetting(name, realName, new File(codePathStr), legacyNativeLibraryPathStr, primaryCpuAbiStr, secondaryCpuAbiStr, cpuAbiOverrideStr, versionCode, pkgFlags, pkgPrivateFlags, 0 /*sharedUserAppId*/, null, null, null, null, null, domainSetId); PackageSetting ps = new PackageSetting(name, realName, new File(codePathStr), pkgFlags, pkgPrivateFlags, domainSetId) .setLegacyNativeLibraryPath(legacyNativeLibraryPathStr) .setPrimaryCpuAbi(primaryCpuAbiStr) .setSecondaryCpuAbi(secondaryCpuAbiStr) .setCpuAbiOverride(cpuAbiOverrideStr) .setLongVersionCode(versionCode) .setIsPersistent(isPersistent) .setTargetSdkVersion(targetSdkVersion) .setRestrictUpdateHash(restrictUpdateHash); long timeStamp = parser.getAttributeLongHex(null, "ft", 0); if (timeStamp == 0) { timeStamp = parser.getAttributeLong(null, "ts", 0); Loading Loading @@ -3970,6 +3997,9 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile long loadingCompletedTime = 0; UUID domainSetId; String appMetadataFilePath = null; boolean isPersistent = false; int targetSdkVersion = 0; byte[] restrictUpdateHash = null; try { name = parser.getAttributeValue(null, ATTR_NAME); realName = parser.getAttributeValue(null, "realName"); Loading @@ -3993,6 +4023,9 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile } versionCode = parser.getAttributeLong(null, "version", 0); isPersistent = parser.getAttributeBoolean(null, "isPersistent", false); targetSdkVersion = parser.getAttributeInt(null, "targetSdkVersion", 0); restrictUpdateHash = parser.getAttributeBytesBase64(null, "restrictUpdateHash", null); installerPackageName = parser.getAttributeValue(null, "installer"); installerPackageUid = parser.getAttributeInt(null, "installerUid", INVALID_UID); updateOwnerPackageName = parser.getAttributeValue(null, "updateOwner"); Loading Loading @@ -4088,11 +4121,7 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile + parser.getPositionDescription()); } else if (appId > 0) { packageSetting = addPackageLPw(name.intern(), realName, new File(codePathStr), legacyNativeLibraryPathStr, primaryCpuAbiString, secondaryCpuAbiString, cpuAbiOverrideString, appId, versionCode, pkgFlags, pkgPrivateFlags, null /* usesSdkLibraries */, null /* usesSdkLibraryVersions */, null /* usesStaticLibraries */, null /* usesStaticLibraryVersions */, null /* mimeGroups */, domainSetId); appId, pkgFlags, pkgPrivateFlags, domainSetId); if (PackageManagerService.DEBUG_SETTINGS) Log.i(PackageManagerService.TAG, "Reading package " + name + ": appId=" + appId + " pkg=" + packageSetting); Loading @@ -4101,22 +4130,26 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile + appId + " while parsing settings at " + parser.getPositionDescription()); } else { packageSetting.setLegacyNativeLibraryPath(legacyNativeLibraryPathStr); packageSetting.setPrimaryCpuAbi(primaryCpuAbiString); packageSetting.setSecondaryCpuAbi(secondaryCpuAbiString); packageSetting.setCpuAbiOverride(cpuAbiOverrideString); packageSetting.setLongVersionCode(versionCode); packageSetting.setLastModifiedTime(timeStamp); packageSetting.setLastUpdateTime(lastUpdateTime); } } else if (sharedUserAppId != 0) { if (sharedUserAppId > 0) { packageSetting = new PackageSetting(name.intern(), realName, new File(codePathStr), legacyNativeLibraryPathStr, primaryCpuAbiString, secondaryCpuAbiString, cpuAbiOverrideString, versionCode, pkgFlags, pkgPrivateFlags, sharedUserAppId, null /* usesSdkLibraries */, null /* usesSdkLibrariesVersions */, null /* usesStaticLibraries */, null /* usesStaticLibraryVersions */, null /* mimeGroups */, domainSetId); packageSetting.setLastModifiedTime(timeStamp); packageSetting.setLastUpdateTime(lastUpdateTime); new File(codePathStr), pkgFlags, pkgPrivateFlags, domainSetId) .setLegacyNativeLibraryPath(legacyNativeLibraryPathStr) .setPrimaryCpuAbi(primaryCpuAbiString) .setSecondaryCpuAbi(secondaryCpuAbiString) .setCpuAbiOverride(cpuAbiOverrideString) .setLongVersionCode(versionCode) .setSharedUserAppId(sharedUserAppId) .setLastModifiedTime(timeStamp) .setLastUpdateTime(lastUpdateTime); mPendingPackages.add(packageSetting); if (PackageManagerService.DEBUG_SETTINGS) Log.i(PackageManagerService.TAG, "Reading package " + name Loading Loading @@ -4155,7 +4188,10 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile .setForceQueryableOverride(installedForceQueryable) .setLoadingProgress(loadingProgress) .setLoadingCompletedTime(loadingCompletedTime) .setAppMetadataFilePath(appMetadataFilePath); .setAppMetadataFilePath(appMetadataFilePath) .setIsPersistent(isPersistent) .setTargetSdkVersion(targetSdkVersion) .setRestrictUpdateHash(restrictUpdateHash); // Handle legacy string here for single-user mode final String enabledStr = parser.getAttributeValue(null, ATTR_ENABLED); if (enabledStr != null) { Loading Loading @@ -4916,9 +4952,11 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile } pw.print(prefix); pw.print(" versionCode="); pw.print(ps.getVersionCode()); if (pkg != null) { pw.print(" minSdk="); pw.print(pkg.getMinSdkVersion()); pw.print(" targetSdk="); pw.println(pkg.getTargetSdkVersion()); pw.print(" minSdk="); pw.print(pkg.getMinSdkVersion()); } pw.print(" targetSdk="); pw.println(ps.getTargetSdkVersion()); if (pkg != null) { SparseIntArray minExtensionVersions = pkg.getMinExtensionVersions(); pw.print(prefix); pw.print(" minExtensionVersions=["); Loading services/tests/PackageManagerComponentOverrideTests/src/com/android/server/pm/test/override/PackageManagerComponentLabelIconOverrideTest.kt +6 −8 Original line number Diff line number Diff line Loading @@ -143,8 +143,8 @@ class PackageManagerComponentLabelIconOverrideTest { val result: Result, val componentName: ComponentName? = ComponentName(pkgName, COMPONENT_CLASS_NAME) ) { constructor(pkgName: String, appType: AppType, exception: Class<out Exception>) : this(pkgName, appType, Result.Exception(exception)) constructor(pkgName: String, appType: AppType, exception: Class<out Exception>) : this(pkgName, appType, Result.Exception(exception)) val expectedLabel = when (result) { Result.Changed, Result.ChangedWithoutNotify, Result.NotChanged -> TEST_LABEL Loading Loading @@ -299,11 +299,9 @@ class PackageManagerComponentLabelIconOverrideTest { .hideAsFinal() private fun makePkgSetting(pkgName: String, pkg: AndroidPackageInternal) = PackageSetting( pkgName, null, File("/test"), null, null, null, null, 0, 0, 0, 0, null, null, null, null, null, UUID.fromString("3f9d52b7-d7b4-406a-a1da-d9f19984c72c") ).apply { PackageSetting(pkgName, null, File("/test"), 0, 0, UUID.fromString("3f9d52b7-d7b4-406a-a1da-d9f19984c72c")) .apply { if (params.isSystem) { this.flags = this.flags or ApplicationInfo.FLAG_SYSTEM } Loading services/tests/PackageManagerServiceTests/server/src/com/android/server/pm/PackageManagerSettingsTests.java +21 −62 Original line number Diff line number Diff line Loading @@ -967,20 +967,12 @@ public class PackageManagerSettingsTests { PACKAGE_NAME, REAL_PACKAGE_NAME, INITIAL_CODE_PATH /*codePath*/, null /*legacyNativeLibraryPathString*/, "x86_64" /*primaryCpuAbiString*/, "x86" /*secondaryCpuAbiString*/, null /*cpuAbiOverrideString*/, INITIAL_VERSION_CODE, ApplicationInfo.FLAG_SYSTEM|ApplicationInfo.FLAG_HAS_CODE, ApplicationInfo.PRIVATE_FLAG_PRIVILEGED|ApplicationInfo.PRIVATE_FLAG_HIDDEN, 0, null /*usesSdkLibraries*/, null /*usesSdkLibrariesVersions*/, null /*usesStaticLibraries*/, null /*usesStaticLibrariesVersions*/, null /*mimeGroups*/, UUID.randomUUID()); UUID.randomUUID()) .setPrimaryCpuAbi("x86_64") .setSecondaryCpuAbi("x86") .setLongVersionCode(INITIAL_VERSION_CODE); origPkgSetting01.setPkg(mockAndroidPackage(origPkgSetting01)); final PackageSetting testPkgSetting01 = new PackageSetting(origPkgSetting01); verifySettingCopy(origPkgSetting01, testPkgSetting01); Loading @@ -989,23 +981,15 @@ public class PackageManagerSettingsTests { @Test public void testPackageStateCopy02() { final PackageSetting origPkgSetting01 = new PackageSetting( PACKAGE_NAME /*pkgName*/, REAL_PACKAGE_NAME /*realPkgName*/, PACKAGE_NAME, REAL_PACKAGE_NAME, INITIAL_CODE_PATH /*codePath*/, null /*legacyNativeLibraryPathString*/, "x86_64" /*primaryCpuAbiString*/, "x86" /*secondaryCpuAbiString*/, null /*cpuAbiOverrideString*/, INITIAL_VERSION_CODE, ApplicationInfo.FLAG_SYSTEM|ApplicationInfo.FLAG_HAS_CODE, ApplicationInfo.PRIVATE_FLAG_PRIVILEGED|ApplicationInfo.PRIVATE_FLAG_HIDDEN, 0, null /*usesSdkLibraries*/, null /*usesSdkLibrariesVersions*/, null /*usesStaticLibraries*/, null /*usesStaticLibrariesVersions*/, null /*mimeGroups*/, UUID.randomUUID()); UUID.randomUUID()) .setPrimaryCpuAbi("x86_64") .setSecondaryCpuAbi("x86") .setLongVersionCode(INITIAL_VERSION_CODE); origPkgSetting01.setUserState(0, 100, 100, 1, true, false, false, false, 0, null, false, false, "lastDisabledCaller", new ArraySet<>(new String[]{"enabledComponent1"}), new ArraySet<>(new String[]{"disabledComponent1"}), 0, 0, "harmfulAppWarning", Loading @@ -1028,20 +1012,10 @@ public class PackageManagerSettingsTests { PACKAGE_NAME /*pkgName*/, REAL_PACKAGE_NAME /*realPkgName*/, UPDATED_CODE_PATH /*codePath*/, null /*legacyNativeLibraryPathString*/, null /*primaryCpuAbiString*/, null /*secondaryCpuAbiString*/, null /*cpuAbiOverrideString*/, UPDATED_VERSION_CODE, 0 /*pkgFlags*/, 0 /*pkgPrivateFlags*/, 0, null /*usesSdkLibraries*/, null /*usesSdkLibrariesVersions*/, null /*usesStaticLibraries*/, null /*usesStaticLibrariesVersions*/, null /*mimeGroups*/, UUID.randomUUID()); UUID.randomUUID()) .setLongVersionCode(UPDATED_VERSION_CODE); testPkgSetting01.copyPackageSetting(origPkgSetting01, true); verifySettingCopy(origPkgSetting01, testPkgSetting01); verifyUserStatesCopy(origPkgSetting01.readUserState(0), Loading Loading @@ -1717,20 +1691,13 @@ public class PackageManagerSettingsTests { PACKAGE_NAME, REAL_PACKAGE_NAME, INITIAL_CODE_PATH /*codePath*/, null /*legacyNativeLibraryPathString*/, "x86_64" /*primaryCpuAbiString*/, "x86" /*secondaryCpuAbiString*/, null /*cpuAbiOverrideString*/, INITIAL_VERSION_CODE, pkgFlags, 0 /*privateFlags*/, sharedUserId, null /*usesSdkLibraries*/, null /*usesSdkLibrariesVersions*/, null /*usesStaticLibraries*/, null /*usesStaticLibrariesVersions*/, null /*mimeGroups*/, UUID.randomUUID()); UUID.randomUUID()) .setPrimaryCpuAbi("x86_64") .setSecondaryCpuAbi("x86") .setLongVersionCode(INITIAL_VERSION_CODE) .setSharedUserAppId(sharedUserId); } private PackageSetting createPackageSetting(String packageName) { Loading @@ -1738,20 +1705,12 @@ public class PackageManagerSettingsTests { packageName, packageName, INITIAL_CODE_PATH /*codePath*/, null /*legacyNativeLibraryPathString*/, "x86_64" /*primaryCpuAbiString*/, "x86" /*secondaryCpuAbiString*/, null /*cpuAbiOverrideString*/, INITIAL_VERSION_CODE, 0, 0 /*privateFlags*/, 0, null /*usesSdkLibraries*/, null /*usesSdkLibrariesVersions*/, null /*usesStaticLibraries*/, null /*usesStaticLibrariesVersions*/, null /*mimeGroups*/, UUID.randomUUID()); UUID.randomUUID()) .setPrimaryCpuAbi("x86_64") .setSecondaryCpuAbi("x86") .setLongVersionCode(INITIAL_VERSION_CODE); } static @NonNull List<UserInfo> createFakeUsers() { Loading services/tests/mockingservicestests/src/com/android/server/pm/MockSystem.kt +1 −2 Original line number Diff line number Diff line Loading @@ -165,8 +165,7 @@ class MockSystem(withSession: (StaticMockitoSessionBuilder) -> Unit = {}) { null } whenever(mocks.settings.addPackageLPw(nullable(), nullable(), nullable(), nullable(), nullable(), nullable(), nullable(), nullable(), nullable(), nullable(), nullable(), nullable(), nullable(), nullable(), nullable(), nullable(), nullable())) { nullable(), nullable(), nullable())) { val name: String = getArgument(0) val pendingAdd = mPendingPackageAdds.firstOrNull { it.first == name } ?: return@whenever null Loading Loading
services/core/java/com/android/server/pm/PackageSetting.java +13 −27 Original line number Diff line number Diff line Loading @@ -238,34 +238,16 @@ public class PackageSetting extends SettingBase implements PackageStateInternal } @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) public PackageSetting(String name, String realName, @NonNull File path, String legacyNativeLibraryPath, String primaryCpuAbi, String secondaryCpuAbi, String cpuAbiOverride, long longVersionCode, int pkgFlags, int pkgPrivateFlags, int sharedUserAppId, String[] usesSdkLibraries, long[] usesSdkLibrariesVersionsMajor, String[] usesStaticLibraries, long[] usesStaticLibrariesVersions, Map<String, Set<String>> mimeGroups, @NonNull UUID domainSetId) { public PackageSetting(@NonNull String name, @Nullable String realName, @NonNull File path, int pkgFlags, int pkgPrivateFlags, @NonNull UUID domainSetId) { super(pkgFlags, pkgPrivateFlags); this.mName = name; this.mRealName = realName; this.usesSdkLibraries = usesSdkLibraries; this.usesSdkLibrariesVersionsMajor = usesSdkLibrariesVersionsMajor; this.usesStaticLibraries = usesStaticLibraries; this.usesStaticLibrariesVersions = usesStaticLibrariesVersions; this.mPath = path; this.mPathString = path.toString(); this.legacyNativeLibraryPath = legacyNativeLibraryPath; this.mPrimaryCpuAbi = primaryCpuAbi; this.mSecondaryCpuAbi = secondaryCpuAbi; this.mCpuAbiOverride = cpuAbiOverride; this.versionCode = longVersionCode; this.signatures = new PackageSignatures(); this.installSource = InstallSource.EMPTY; this.mSharedUserAppId = sharedUserAppId; mDomainSetId = domainSetId; copyMimeGroups(mimeGroups); this.mDomainSetId = domainSetId; mSnapshot = makeCache(); } Loading Loading @@ -536,9 +518,10 @@ public class PackageSetting extends SettingBase implements PackageStateInternal return this; } public void setSharedUserAppId(int sharedUserAppId) { public PackageSetting setSharedUserAppId(int sharedUserAppId) { mSharedUserAppId = sharedUserAppId; onChanged(); return this; } public PackageSetting setIsPersistent(boolean isPersistent) { Loading Loading @@ -576,7 +559,7 @@ public class PackageSetting extends SettingBase implements PackageStateInternal + " " + mName + "/" + mAppId + "}"; } protected void copyMimeGroups(@Nullable Map<String, Set<String>> newMimeGroups) { private void copyMimeGroups(@Nullable Map<String, Set<String>> newMimeGroups) { if (newMimeGroups == null) { mimeGroups = null; return; Loading Loading @@ -1250,7 +1233,8 @@ public class PackageSetting extends SettingBase implements PackageStateInternal /** * @see #mPath */ PackageSetting setPath(@NonNull File path) { @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) public PackageSetting setPath(@NonNull File path) { this.mPath = path; this.mPathString = path.toString(); onChanged(); Loading Loading @@ -1451,9 +1435,11 @@ public class PackageSetting extends SettingBase implements PackageStateInternal return this; } public PackageSetting setMimeGroups(@NonNull Map<String, Set<String>> mimeGroups) { this.mimeGroups = mimeGroups; public PackageSetting setMimeGroups(@Nullable Map<String, Set<String>> mimeGroups) { if (mimeGroups != null) { copyMimeGroups(mimeGroups); onChanged(); } return this; } Loading
services/core/java/com/android/server/pm/Settings.java +88 −50 Original line number Diff line number Diff line Loading @@ -931,16 +931,24 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile sharedUserSetting.mDisabledPackages.remove(p); } p.getPkgState().setUpdatedSystemApp(false); PackageSetting ret = addPackageLPw(name, p.getRealName(), p.getPath(), p.getLegacyNativeLibraryPath(), p.getPrimaryCpuAbiLegacy(), p.getSecondaryCpuAbiLegacy(), p.getCpuAbiOverride(), p.getAppId(), p.getVersionCode(), p.getFlags(), p.getPrivateFlags(), p.getUsesSdkLibraries(), p.getUsesSdkLibrariesVersionsMajor(), p.getUsesStaticLibraries(), p.getUsesStaticLibrariesVersions(), p.getMimeGroups(), mDomainVerificationManager.generateNewId()); PackageSetting ret = addPackageLPw(name, p.getRealName(), p.getPath(), p.getAppId(), p.getFlags(), p.getPrivateFlags(), mDomainVerificationManager.generateNewId()); if (ret != null) { ret.setLegacyNativeLibraryPath(p.getLegacyNativeLibraryPath()); ret.setPrimaryCpuAbi(p.getPrimaryCpuAbiLegacy()); ret.setSecondaryCpuAbi(p.getSecondaryCpuAbiLegacy()); ret.setCpuAbiOverride(p.getCpuAbiOverride()); ret.setLongVersionCode(p.getVersionCode()); ret.setUsesSdkLibraries(p.getUsesSdkLibraries()); ret.setUsesSdkLibrariesVersionsMajor(p.getUsesSdkLibrariesVersionsMajor()); ret.setUsesStaticLibraries(p.getUsesStaticLibraries()); ret.setUsesStaticLibrariesVersions(p.getUsesStaticLibrariesVersions()); ret.setMimeGroups(p.getMimeGroups()); ret.setAppMetadataFilePath(p.getAppMetadataFilePath()); ret.getPkgState().setUpdatedSystemApp(false); ret.setIsPersistent(p.isPersistent()); ret.setTargetSdkVersion(p.getTargetSdkVersion()); ret.setRestrictUpdateHash(p.getRestrictUpdateHash()); } mDisabledSysPackages.remove(name); return ret; Loading @@ -961,13 +969,8 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile } } PackageSetting addPackageLPw(String name, String realName, File codePath, String legacyNativeLibraryPathString, String primaryCpuAbiString, String secondaryCpuAbiString, String cpuAbiOverrideString, int uid, long vc, int pkgFlags, int pkgPrivateFlags, String[] usesSdkLibraries, long[] usesSdkLibrariesVersions, String[] usesStaticLibraries, long[] usesStaticLibrariesVersions, Map<String, Set<String>> mimeGroups, @NonNull UUID domainSetId) { PackageSetting addPackageLPw(String name, String realName, File codePath, int uid, int pkgFlags, int pkgPrivateFlags, @NonNull UUID domainSetId) { PackageSetting p = mPackages.get(name); if (p != null) { if (p.getAppId() == uid) { Loading @@ -977,11 +980,8 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile "Adding duplicate package, keeping first: " + name); return null; } p = new PackageSetting(name, realName, codePath, legacyNativeLibraryPathString, primaryCpuAbiString, secondaryCpuAbiString, cpuAbiOverrideString, vc, pkgFlags, pkgPrivateFlags, 0 /*userId*/, usesSdkLibraries, usesSdkLibrariesVersions, usesStaticLibraries, usesStaticLibrariesVersions, mimeGroups, domainSetId); p.setAppId(uid); p = new PackageSetting(name, realName, codePath, pkgFlags, pkgPrivateFlags, domainSetId) .setAppId(uid); if (mAppIds.registerExistingAppId(uid, p, name)) { mPackages.put(name, p); return p; Loading Loading @@ -1092,16 +1092,21 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile int installUserId = installUser != null ? installUser.getIdentifier() : UserHandle.USER_SYSTEM; pkgSetting = new PackageSetting(pkgName, realPkgName, codePath, legacyNativeLibraryPath, primaryCpuAbi, secondaryCpuAbi, null /*cpuAbiOverrideString*/, versionCode, pkgFlags, pkgPrivateFlags, 0 /*sharedUserAppId*/, usesSdkLibraries, usesSdkLibrariesVersions, usesStaticLibraries, usesStaticLibrariesVersions, createMimeGroups(mimeGroupNames), domainSetId) pkgSetting = new PackageSetting(pkgName, realPkgName, codePath, pkgFlags, pkgPrivateFlags, domainSetId) .setUsesSdkLibraries(usesSdkLibraries) .setUsesSdkLibrariesVersionsMajor(usesSdkLibrariesVersions) .setUsesStaticLibraries(usesStaticLibraries) .setUsesStaticLibrariesVersions(usesStaticLibrariesVersions) .setLegacyNativeLibraryPath(legacyNativeLibraryPath) .setPrimaryCpuAbi(primaryCpuAbi) .setSecondaryCpuAbi(secondaryCpuAbi) .setLongVersionCode(versionCode) .setMimeGroups(createMimeGroups(mimeGroupNames)) .setIsPersistent(isPersistent) .setTargetSdkVersion(targetSdkVersion) .setRestrictUpdateHash(restrictUpdatedHash); pkgSetting.setLastModifiedTime(codePath.lastModified()); .setRestrictUpdateHash(restrictUpdatedHash) .setLastModifiedTime(codePath.lastModified()); if (sharedUser != null) { pkgSetting.setSharedUserAppId(sharedUser.mAppId); } Loading Loading @@ -3066,6 +3071,12 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile serializer.attributeLongHex(null, "ft", pkg.getLastModifiedTime()); serializer.attributeLongHex(null, "ut", pkg.getLastUpdateTime()); serializer.attributeLong(null, "version", pkg.getVersionCode()); serializer.attributeBoolean(null, "isPersistent", pkg.isPersistent()); serializer.attributeInt(null, "targetSdkVersion", pkg.getTargetSdkVersion()); if (pkg.getRestrictUpdateHash() != null) { serializer.attributeBytesBase64(null, "restrictUpdateHash", pkg.getRestrictUpdateHash()); } if (pkg.getLegacyNativeLibraryPath() != null) { serializer.attribute(null, "nativeLibraryPath", pkg.getLegacyNativeLibraryPath()); } Loading Loading @@ -3129,6 +3140,12 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile serializer.attributeLongHex(null, "ft", pkg.getLastModifiedTime()); serializer.attributeLongHex(null, "ut", pkg.getLastUpdateTime()); serializer.attributeLong(null, "version", pkg.getVersionCode()); serializer.attributeBoolean(null, "isPersistent", pkg.isPersistent()); serializer.attributeInt(null, "targetSdkVersion", pkg.getTargetSdkVersion()); if (pkg.getRestrictUpdateHash() != null) { serializer.attributeBytesBase64(null, "restrictUpdateHash", pkg.getRestrictUpdateHash()); } if (!pkg.hasSharedUser()) { serializer.attributeInt(null, "userId", pkg.getAppId()); } else { Loading Loading @@ -3861,6 +3878,10 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile } long versionCode = parser.getAttributeLong(null, "version", 0); boolean isPersistent = parser.getAttributeBoolean(null, "isPersistent", false); int targetSdkVersion = parser.getAttributeInt(null, "targetSdkVersion", 0); byte[] restrictUpdateHash = parser.getAttributeBytesBase64(null, "restrictUpdateHash", null); int pkgFlags = 0; int pkgPrivateFlags = 0; Loading @@ -3873,10 +3894,16 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile // debug invalid entries. The actual logic for migrating to a new ID is done in other // methods that use DomainVerificationManagerInternal#generateNewId UUID domainSetId = DomainVerificationManagerInternal.DISABLED_ID; PackageSetting ps = new PackageSetting(name, realName, new File(codePathStr), legacyNativeLibraryPathStr, primaryCpuAbiStr, secondaryCpuAbiStr, cpuAbiOverrideStr, versionCode, pkgFlags, pkgPrivateFlags, 0 /*sharedUserAppId*/, null, null, null, null, null, domainSetId); PackageSetting ps = new PackageSetting(name, realName, new File(codePathStr), pkgFlags, pkgPrivateFlags, domainSetId) .setLegacyNativeLibraryPath(legacyNativeLibraryPathStr) .setPrimaryCpuAbi(primaryCpuAbiStr) .setSecondaryCpuAbi(secondaryCpuAbiStr) .setCpuAbiOverride(cpuAbiOverrideStr) .setLongVersionCode(versionCode) .setIsPersistent(isPersistent) .setTargetSdkVersion(targetSdkVersion) .setRestrictUpdateHash(restrictUpdateHash); long timeStamp = parser.getAttributeLongHex(null, "ft", 0); if (timeStamp == 0) { timeStamp = parser.getAttributeLong(null, "ts", 0); Loading Loading @@ -3970,6 +3997,9 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile long loadingCompletedTime = 0; UUID domainSetId; String appMetadataFilePath = null; boolean isPersistent = false; int targetSdkVersion = 0; byte[] restrictUpdateHash = null; try { name = parser.getAttributeValue(null, ATTR_NAME); realName = parser.getAttributeValue(null, "realName"); Loading @@ -3993,6 +4023,9 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile } versionCode = parser.getAttributeLong(null, "version", 0); isPersistent = parser.getAttributeBoolean(null, "isPersistent", false); targetSdkVersion = parser.getAttributeInt(null, "targetSdkVersion", 0); restrictUpdateHash = parser.getAttributeBytesBase64(null, "restrictUpdateHash", null); installerPackageName = parser.getAttributeValue(null, "installer"); installerPackageUid = parser.getAttributeInt(null, "installerUid", INVALID_UID); updateOwnerPackageName = parser.getAttributeValue(null, "updateOwner"); Loading Loading @@ -4088,11 +4121,7 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile + parser.getPositionDescription()); } else if (appId > 0) { packageSetting = addPackageLPw(name.intern(), realName, new File(codePathStr), legacyNativeLibraryPathStr, primaryCpuAbiString, secondaryCpuAbiString, cpuAbiOverrideString, appId, versionCode, pkgFlags, pkgPrivateFlags, null /* usesSdkLibraries */, null /* usesSdkLibraryVersions */, null /* usesStaticLibraries */, null /* usesStaticLibraryVersions */, null /* mimeGroups */, domainSetId); appId, pkgFlags, pkgPrivateFlags, domainSetId); if (PackageManagerService.DEBUG_SETTINGS) Log.i(PackageManagerService.TAG, "Reading package " + name + ": appId=" + appId + " pkg=" + packageSetting); Loading @@ -4101,22 +4130,26 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile + appId + " while parsing settings at " + parser.getPositionDescription()); } else { packageSetting.setLegacyNativeLibraryPath(legacyNativeLibraryPathStr); packageSetting.setPrimaryCpuAbi(primaryCpuAbiString); packageSetting.setSecondaryCpuAbi(secondaryCpuAbiString); packageSetting.setCpuAbiOverride(cpuAbiOverrideString); packageSetting.setLongVersionCode(versionCode); packageSetting.setLastModifiedTime(timeStamp); packageSetting.setLastUpdateTime(lastUpdateTime); } } else if (sharedUserAppId != 0) { if (sharedUserAppId > 0) { packageSetting = new PackageSetting(name.intern(), realName, new File(codePathStr), legacyNativeLibraryPathStr, primaryCpuAbiString, secondaryCpuAbiString, cpuAbiOverrideString, versionCode, pkgFlags, pkgPrivateFlags, sharedUserAppId, null /* usesSdkLibraries */, null /* usesSdkLibrariesVersions */, null /* usesStaticLibraries */, null /* usesStaticLibraryVersions */, null /* mimeGroups */, domainSetId); packageSetting.setLastModifiedTime(timeStamp); packageSetting.setLastUpdateTime(lastUpdateTime); new File(codePathStr), pkgFlags, pkgPrivateFlags, domainSetId) .setLegacyNativeLibraryPath(legacyNativeLibraryPathStr) .setPrimaryCpuAbi(primaryCpuAbiString) .setSecondaryCpuAbi(secondaryCpuAbiString) .setCpuAbiOverride(cpuAbiOverrideString) .setLongVersionCode(versionCode) .setSharedUserAppId(sharedUserAppId) .setLastModifiedTime(timeStamp) .setLastUpdateTime(lastUpdateTime); mPendingPackages.add(packageSetting); if (PackageManagerService.DEBUG_SETTINGS) Log.i(PackageManagerService.TAG, "Reading package " + name Loading Loading @@ -4155,7 +4188,10 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile .setForceQueryableOverride(installedForceQueryable) .setLoadingProgress(loadingProgress) .setLoadingCompletedTime(loadingCompletedTime) .setAppMetadataFilePath(appMetadataFilePath); .setAppMetadataFilePath(appMetadataFilePath) .setIsPersistent(isPersistent) .setTargetSdkVersion(targetSdkVersion) .setRestrictUpdateHash(restrictUpdateHash); // Handle legacy string here for single-user mode final String enabledStr = parser.getAttributeValue(null, ATTR_ENABLED); if (enabledStr != null) { Loading Loading @@ -4916,9 +4952,11 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile } pw.print(prefix); pw.print(" versionCode="); pw.print(ps.getVersionCode()); if (pkg != null) { pw.print(" minSdk="); pw.print(pkg.getMinSdkVersion()); pw.print(" targetSdk="); pw.println(pkg.getTargetSdkVersion()); pw.print(" minSdk="); pw.print(pkg.getMinSdkVersion()); } pw.print(" targetSdk="); pw.println(ps.getTargetSdkVersion()); if (pkg != null) { SparseIntArray minExtensionVersions = pkg.getMinExtensionVersions(); pw.print(prefix); pw.print(" minExtensionVersions=["); Loading
services/tests/PackageManagerComponentOverrideTests/src/com/android/server/pm/test/override/PackageManagerComponentLabelIconOverrideTest.kt +6 −8 Original line number Diff line number Diff line Loading @@ -143,8 +143,8 @@ class PackageManagerComponentLabelIconOverrideTest { val result: Result, val componentName: ComponentName? = ComponentName(pkgName, COMPONENT_CLASS_NAME) ) { constructor(pkgName: String, appType: AppType, exception: Class<out Exception>) : this(pkgName, appType, Result.Exception(exception)) constructor(pkgName: String, appType: AppType, exception: Class<out Exception>) : this(pkgName, appType, Result.Exception(exception)) val expectedLabel = when (result) { Result.Changed, Result.ChangedWithoutNotify, Result.NotChanged -> TEST_LABEL Loading Loading @@ -299,11 +299,9 @@ class PackageManagerComponentLabelIconOverrideTest { .hideAsFinal() private fun makePkgSetting(pkgName: String, pkg: AndroidPackageInternal) = PackageSetting( pkgName, null, File("/test"), null, null, null, null, 0, 0, 0, 0, null, null, null, null, null, UUID.fromString("3f9d52b7-d7b4-406a-a1da-d9f19984c72c") ).apply { PackageSetting(pkgName, null, File("/test"), 0, 0, UUID.fromString("3f9d52b7-d7b4-406a-a1da-d9f19984c72c")) .apply { if (params.isSystem) { this.flags = this.flags or ApplicationInfo.FLAG_SYSTEM } Loading
services/tests/PackageManagerServiceTests/server/src/com/android/server/pm/PackageManagerSettingsTests.java +21 −62 Original line number Diff line number Diff line Loading @@ -967,20 +967,12 @@ public class PackageManagerSettingsTests { PACKAGE_NAME, REAL_PACKAGE_NAME, INITIAL_CODE_PATH /*codePath*/, null /*legacyNativeLibraryPathString*/, "x86_64" /*primaryCpuAbiString*/, "x86" /*secondaryCpuAbiString*/, null /*cpuAbiOverrideString*/, INITIAL_VERSION_CODE, ApplicationInfo.FLAG_SYSTEM|ApplicationInfo.FLAG_HAS_CODE, ApplicationInfo.PRIVATE_FLAG_PRIVILEGED|ApplicationInfo.PRIVATE_FLAG_HIDDEN, 0, null /*usesSdkLibraries*/, null /*usesSdkLibrariesVersions*/, null /*usesStaticLibraries*/, null /*usesStaticLibrariesVersions*/, null /*mimeGroups*/, UUID.randomUUID()); UUID.randomUUID()) .setPrimaryCpuAbi("x86_64") .setSecondaryCpuAbi("x86") .setLongVersionCode(INITIAL_VERSION_CODE); origPkgSetting01.setPkg(mockAndroidPackage(origPkgSetting01)); final PackageSetting testPkgSetting01 = new PackageSetting(origPkgSetting01); verifySettingCopy(origPkgSetting01, testPkgSetting01); Loading @@ -989,23 +981,15 @@ public class PackageManagerSettingsTests { @Test public void testPackageStateCopy02() { final PackageSetting origPkgSetting01 = new PackageSetting( PACKAGE_NAME /*pkgName*/, REAL_PACKAGE_NAME /*realPkgName*/, PACKAGE_NAME, REAL_PACKAGE_NAME, INITIAL_CODE_PATH /*codePath*/, null /*legacyNativeLibraryPathString*/, "x86_64" /*primaryCpuAbiString*/, "x86" /*secondaryCpuAbiString*/, null /*cpuAbiOverrideString*/, INITIAL_VERSION_CODE, ApplicationInfo.FLAG_SYSTEM|ApplicationInfo.FLAG_HAS_CODE, ApplicationInfo.PRIVATE_FLAG_PRIVILEGED|ApplicationInfo.PRIVATE_FLAG_HIDDEN, 0, null /*usesSdkLibraries*/, null /*usesSdkLibrariesVersions*/, null /*usesStaticLibraries*/, null /*usesStaticLibrariesVersions*/, null /*mimeGroups*/, UUID.randomUUID()); UUID.randomUUID()) .setPrimaryCpuAbi("x86_64") .setSecondaryCpuAbi("x86") .setLongVersionCode(INITIAL_VERSION_CODE); origPkgSetting01.setUserState(0, 100, 100, 1, true, false, false, false, 0, null, false, false, "lastDisabledCaller", new ArraySet<>(new String[]{"enabledComponent1"}), new ArraySet<>(new String[]{"disabledComponent1"}), 0, 0, "harmfulAppWarning", Loading @@ -1028,20 +1012,10 @@ public class PackageManagerSettingsTests { PACKAGE_NAME /*pkgName*/, REAL_PACKAGE_NAME /*realPkgName*/, UPDATED_CODE_PATH /*codePath*/, null /*legacyNativeLibraryPathString*/, null /*primaryCpuAbiString*/, null /*secondaryCpuAbiString*/, null /*cpuAbiOverrideString*/, UPDATED_VERSION_CODE, 0 /*pkgFlags*/, 0 /*pkgPrivateFlags*/, 0, null /*usesSdkLibraries*/, null /*usesSdkLibrariesVersions*/, null /*usesStaticLibraries*/, null /*usesStaticLibrariesVersions*/, null /*mimeGroups*/, UUID.randomUUID()); UUID.randomUUID()) .setLongVersionCode(UPDATED_VERSION_CODE); testPkgSetting01.copyPackageSetting(origPkgSetting01, true); verifySettingCopy(origPkgSetting01, testPkgSetting01); verifyUserStatesCopy(origPkgSetting01.readUserState(0), Loading Loading @@ -1717,20 +1691,13 @@ public class PackageManagerSettingsTests { PACKAGE_NAME, REAL_PACKAGE_NAME, INITIAL_CODE_PATH /*codePath*/, null /*legacyNativeLibraryPathString*/, "x86_64" /*primaryCpuAbiString*/, "x86" /*secondaryCpuAbiString*/, null /*cpuAbiOverrideString*/, INITIAL_VERSION_CODE, pkgFlags, 0 /*privateFlags*/, sharedUserId, null /*usesSdkLibraries*/, null /*usesSdkLibrariesVersions*/, null /*usesStaticLibraries*/, null /*usesStaticLibrariesVersions*/, null /*mimeGroups*/, UUID.randomUUID()); UUID.randomUUID()) .setPrimaryCpuAbi("x86_64") .setSecondaryCpuAbi("x86") .setLongVersionCode(INITIAL_VERSION_CODE) .setSharedUserAppId(sharedUserId); } private PackageSetting createPackageSetting(String packageName) { Loading @@ -1738,20 +1705,12 @@ public class PackageManagerSettingsTests { packageName, packageName, INITIAL_CODE_PATH /*codePath*/, null /*legacyNativeLibraryPathString*/, "x86_64" /*primaryCpuAbiString*/, "x86" /*secondaryCpuAbiString*/, null /*cpuAbiOverrideString*/, INITIAL_VERSION_CODE, 0, 0 /*privateFlags*/, 0, null /*usesSdkLibraries*/, null /*usesSdkLibrariesVersions*/, null /*usesStaticLibraries*/, null /*usesStaticLibrariesVersions*/, null /*mimeGroups*/, UUID.randomUUID()); UUID.randomUUID()) .setPrimaryCpuAbi("x86_64") .setSecondaryCpuAbi("x86") .setLongVersionCode(INITIAL_VERSION_CODE); } static @NonNull List<UserInfo> createFakeUsers() { Loading
services/tests/mockingservicestests/src/com/android/server/pm/MockSystem.kt +1 −2 Original line number Diff line number Diff line Loading @@ -165,8 +165,7 @@ class MockSystem(withSession: (StaticMockitoSessionBuilder) -> Unit = {}) { null } whenever(mocks.settings.addPackageLPw(nullable(), nullable(), nullable(), nullable(), nullable(), nullable(), nullable(), nullable(), nullable(), nullable(), nullable(), nullable(), nullable(), nullable(), nullable(), nullable(), nullable())) { nullable(), nullable(), nullable())) { val name: String = getArgument(0) val pendingAdd = mPendingPackageAdds.firstOrNull { it.first == name } ?: return@whenever null Loading