Automated import from //branches/donutburger/...@141523,141523
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java
index edbb0ce..7fffcb9 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -3900,14 +3900,26 @@
     private boolean deletePackageX(String packageName, boolean sendBroadCast,
                                    boolean deleteCodeAndResources, int flags) {
         PackageRemovedInfo info = new PackageRemovedInfo();
-        boolean res = false;
+        boolean res;
 
         synchronized (mInstallLock) {
             res = deletePackageLI(packageName, deleteCodeAndResources, flags, info);
         }
         
         if(res && sendBroadCast) {
-            info.sendBroadcast(deleteCodeAndResources, false);
+            boolean systemUpdate = info.isRemovedPackageSystemUpdate;
+            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
+            if (systemUpdate) {
+                Bundle extras = new Bundle(1);
+                extras.putInt(Intent.EXTRA_UID, info.removedUid >= 0 ? info.removedUid : info.uid);
+                extras.putBoolean(Intent.EXTRA_REPLACING, true);
+
+                sendPackageBroadcast(Intent.ACTION_PACKAGE_ADDED, packageName, extras);
+                sendPackageBroadcast(Intent.ACTION_PACKAGE_REPLACED, packageName, extras);
+            }
         }
         return res;
     }
@@ -3916,7 +3928,8 @@
         String removedPackage;
         int uid = -1;
         int removedUid = -1;
-        
+        boolean isRemovedPackageSystemUpdate = false;
+
         void sendBroadcast(boolean fullRemove, boolean replacing) {
             Bundle extras = new Bundle(1);
             extras.putInt(Intent.EXTRA_UID, removedUid >= 0 ? removedUid : uid);
@@ -4002,6 +4015,7 @@
             Log.i(TAG, "Deleting system pkg from data partition");
         }
         // Delete the updated package
+        outInfo.isRemovedPackageSystemUpdate = true;
         boolean ret = deleteInstalledPackageLI(p, deleteCodeAndResources, flags, outInfo);
         if (!ret) {
             return false;