Fix issue #2558391: Package manager problem when not replacing existing system partition app

This fixes the package manager to ensure we can't get in this bad state of
an update to a system app being installed as a separate app.

Change-Id: I2a3f601bbc06b74f31ca09192993614bc6885ff7
This commit is contained in:
Dianne Hackborn
2010-03-30 19:24:44 -07:00
parent 9b9a89a58f
commit e259bc770b

View File

@@ -5464,6 +5464,17 @@ class PackageManagerService extends IPackageManager.Stub {
boolean dataDirExists = getDataPathForPackage(pkg).exists(); boolean dataDirExists = getDataPathForPackage(pkg).exists();
res.name = pkgName; res.name = pkgName;
synchronized(mPackages) { synchronized(mPackages) {
if (mSettings.mRenamedPackages.containsKey(pkgName)) {
// A package with the same name is already installed, though
// it has been renamed to an older name. The package we
// are trying to install should be installed as an update to
// the existing one, but that has not been requested, so bail.
Slog.w(TAG, "Attempt to re-install " + pkgName
+ " without first uninstalling package running as "
+ mSettings.mRenamedPackages.get(pkgName));
res.returnCode = PackageManager.INSTALL_FAILED_ALREADY_EXISTS;
return;
}
if (mPackages.containsKey(pkgName) || mAppDirs.containsKey(pkg.mPath)) { if (mPackages.containsKey(pkgName) || mAppDirs.containsKey(pkg.mPath)) {
// Don't allow installation over an existing package with the same name. // Don't allow installation over an existing package with the same name.
Slog.w(TAG, "Attempt to re-install " + pkgName Slog.w(TAG, "Attempt to re-install " + pkgName
@@ -5595,7 +5606,7 @@ class PackageManagerService extends IPackageManager.Stub {
PackageInstalledInfo restoreRes = new PackageInstalledInfo(); PackageInstalledInfo restoreRes = new PackageInstalledInfo();
restoreRes.removedInfo = new PackageRemovedInfo(); restoreRes.removedInfo = new PackageRemovedInfo();
// Parse old package // Parse old package
parseFlags |= ~PackageManager.INSTALL_REPLACE_EXISTING; parseFlags &= ~PackageManager.INSTALL_REPLACE_EXISTING;
scanPackageLI(restoreFile, parseFlags, scanMode); scanPackageLI(restoreFile, parseFlags, scanMode);
synchronized (mPackages) { synchronized (mPackages) {
updatePermissionsLP(deletedPackage.packageName, deletedPackage, updatePermissionsLP(deletedPackage.packageName, deletedPackage,