diff options
author | Suchi Amalapurapu <asuchitra@google.com> | 2010-04-14 20:30:27 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-04-14 20:30:27 -0700 |
commit | c260b08e59304b4b72037c3724fdfdd03ecac37f (patch) | |
tree | 0d29f3d753f092d2b5091f52d3b0066e6ab934e6 /services | |
parent | ccb87e11da5ff4508ede1e4582a5d617fbe78a97 (diff) | |
parent | 0751d1eaad55603eaeb0f035a55935f713ab0476 (diff) | |
download | frameworks_base-c260b08e59304b4b72037c3724fdfdd03ecac37f.zip frameworks_base-c260b08e59304b4b72037c3724fdfdd03ecac37f.tar.gz frameworks_base-c260b08e59304b4b72037c3724fdfdd03ecac37f.tar.bz2 |
am 0751d1ea: am deb69370: Revert "Add ordered broadcast when removing packages." Couple of cosmetic fixes as well.
Merge commit '0751d1eaad55603eaeb0f035a55935f713ab0476' into kraken
* commit '0751d1eaad55603eaeb0f035a55935f713ab0476':
Revert "Add ordered broadcast when removing packages."
Diffstat (limited to 'services')
-rw-r--r-- | services/java/com/android/server/PackageManagerService.java | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java index 4814eab..1383a0b 100644 --- a/services/java/com/android/server/PackageManagerService.java +++ b/services/java/com/android/server/PackageManagerService.java @@ -576,15 +576,14 @@ class PackageManagerService extends IPackageManager.Stub { if (DEBUG_INSTALL) Log.v(TAG, "Handling post-install for " + msg.arg1); PostInstallData data = mRunningInstalls.get(msg.arg1); mRunningInstalls.delete(msg.arg1); + boolean deleteOld = false; if (data != null) { InstallArgs args = data.args; PackageInstalledInfo res = data.res; if (res.returnCode == PackageManager.INSTALL_SUCCEEDED) { - res.removedInfo.sendBroadcast(false, true, - new PackageRemovedIntentReceiver(res.removedInfo.args, - res.removedInfo.args != null)); + res.removedInfo.sendBroadcast(false, true); Bundle extras = new Bundle(1); extras.putInt(Intent.EXTRA_UID, res.uid); final boolean update = res.removedInfo.removedPackage != null; @@ -599,6 +598,18 @@ class PackageManagerService extends IPackageManager.Stub { res.pkg.applicationInfo.packageName, extras, null); } + if (res.removedInfo.args != null) { + // Remove the replaced package's older resources safely now + deleteOld = true; + } + } + // Force a gc to clear up things + Runtime.getRuntime().gc(); + // We delete after a gc for applications on sdcard. + if (deleteOld) { + synchronized (mInstallLock) { + res.removedInfo.args.doPostDeleteLI(true); + } } if (args.observer != null) { try { @@ -6089,8 +6100,7 @@ class PackageManagerService extends IPackageManager.Stub { if(res && sendBroadCast) { boolean systemUpdate = info.isRemovedPackageSystemUpdate; - info.sendBroadcast(deleteCodeAndResources, systemUpdate, - new PackageRemovedIntentReceiver(info.args, deleteCodeAndResources)); + info.sendBroadcast(deleteCodeAndResources, systemUpdate); // If the removed package was a system update, the old system packaged // was re-enabled; we need to broadcast this information @@ -6103,28 +6113,18 @@ class PackageManagerService extends IPackageManager.Stub { sendPackageBroadcast(Intent.ACTION_PACKAGE_REPLACED, packageName, extras, null); } } - return res; - } - - class PackageRemovedIntentReceiver extends IIntentReceiver.Stub { - boolean deleteOld; - InstallArgs args; - PackageRemovedIntentReceiver(InstallArgs args, boolean deleteOld) { - this.args = args; - this.deleteOld = deleteOld; - } - public void performReceive(Intent intent, int resultCode, String data, Bundle extras, - boolean ordered, boolean sticky) throws RemoteException { - // Force a gc to clear up things - Runtime.getRuntime().gc(); - // We delete after a gc for applications on sdcard. - if (deleteOld && args != null) { - synchronized (mInstallLock) { - args.doPostDeleteLI(true); - } + // Force a gc here. + Runtime.getRuntime().gc(); + // Delete the resources here after sending the broadcast to let + // other processes clean up before deleting resources. + if (info.args != null) { + synchronized (mInstallLock) { + info.args.doPostDeleteLI(deleteCodeAndResources); } } + return res; } + static class PackageRemovedInfo { String removedPackage; int uid = -1; @@ -6133,8 +6133,7 @@ class PackageManagerService extends IPackageManager.Stub { // Clean up resources deleted packages. InstallArgs args = null; - void sendBroadcast(boolean fullRemove, boolean replacing, - IIntentReceiver finishedReceiver) { + void sendBroadcast(boolean fullRemove, boolean replacing) { Bundle extras = new Bundle(1); extras.putInt(Intent.EXTRA_UID, removedUid >= 0 ? removedUid : uid); extras.putBoolean(Intent.EXTRA_DATA_REMOVED, fullRemove); @@ -6142,7 +6141,7 @@ class PackageManagerService extends IPackageManager.Stub { extras.putBoolean(Intent.EXTRA_REPLACING, true); } if (removedPackage != null) { - sendPackageBroadcast(Intent.ACTION_PACKAGE_REMOVED, removedPackage, extras, finishedReceiver); + sendPackageBroadcast(Intent.ACTION_PACKAGE_REMOVED, removedPackage, extras, null); } if (removedUid >= 0) { sendPackageBroadcast(Intent.ACTION_UID_REMOVED, null, extras, null); @@ -9795,7 +9794,7 @@ class PackageManagerService extends IPackageManager.Stub { } } if (returnCode != PackageManager.MOVE_SUCCEEDED) { - processPendingMove(new MoveParams(null, observer, 0, null), returnCode); + processPendingMove(new MoveParams(null, observer, 0, packageName), returnCode); } else { Message msg = mHandler.obtainMessage(INIT_COPY); InstallArgs srcArgs = createInstallArgs(currFlags, pkg.applicationInfo.sourceDir, @@ -9836,7 +9835,6 @@ class PackageManagerService extends IPackageManager.Stub { } if (returnCode == PackageManager.MOVE_SUCCEEDED) { // Send resources unavailable broadcast - // TODO Add an ordered broadcast receiver here. sendResourcesChangedBroadcast(false, pkgList, uidArr, null); // Update package code and resource paths synchronized (mInstallLock) { |