Automated import from //branches/master/...@140830,140830
diff --git a/api/current.xml b/api/current.xml
index 30c20a4..e468f9d 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -28390,6 +28390,17 @@
visibility="public"
>
</field>
+<field name="ACTION_PACKAGE_REPLACED"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value=""android.intent.action.PACKAGE_REPLACED""
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
<field name="ACTION_PACKAGE_RESTARTED"
type="java.lang.String"
transient="false"
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 306c02e..c514df7 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -1125,7 +1125,8 @@
public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
/**
* Broadcast Action: A new application package has been installed on the
- * device. The data contains the name of the package.
+ * device. The data contains the name of the package. Note that the
+ * newly installed package does <em>not</em> receive this broadcast.
* <p>My include the following extras:
* <ul>
* <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
@@ -1136,6 +1137,17 @@
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
/**
+ * Broadcast Action: A new version of an application package has been
+ * installed, replacing an existing version that was previously installed.
+ * The data contains the name of the package.
+ * <p>My include the following extras:
+ * <ul>
+ * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
+ * </ul>
+ */
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
+ /**
* Broadcast Action: An existing application package has been removed from
* the device. The data contains the name of the package. The package
* that is being installed does <em>not</em> receive this Intent.
@@ -1163,7 +1175,9 @@
* Broadcast Action: The user has restarted a package, and all of its
* processes have been killed. All runtime state
* associated with it (processes, alarms, notifications, etc) should
- * be removed. The data contains the name of the package.
+ * be removed. Note that the restarted package does <em>not</em>
+ * receive this broadcast.
+ * The data contains the name of the package.
* <ul>
* <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
* </ul>
@@ -1173,8 +1187,9 @@
/**
* Broadcast Action: The user has cleared the data of a package. This should
* be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
- * its persistent data is erased and this broadcast sent. The data contains
- * the name of the package.
+ * its persistent data is erased and this broadcast sent.
+ * Note that the cleared package does <em>not</em>
+ * receive this broadcast. The data contains the name of the package.
* <ul>
* <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
* </ul>
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java
index 2cf47df..edbb0ce 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -3248,12 +3248,18 @@
res.removedInfo.sendBroadcast(false, true);
Bundle extras = new Bundle(1);
extras.putInt(Intent.EXTRA_UID, res.uid);
- if (res.removedInfo.removedPackage != null) {
+ final boolean update = res.removedInfo.removedPackage != null;
+ if (update) {
extras.putBoolean(Intent.EXTRA_REPLACING, true);
}
sendPackageBroadcast(Intent.ACTION_PACKAGE_ADDED,
res.pkg.applicationInfo.packageName,
extras);
+ if (update) {
+ sendPackageBroadcast(Intent.ACTION_PACKAGE_REPLACED,
+ res.pkg.applicationInfo.packageName,
+ extras);
+ }
}
Runtime.getRuntime().gc();
}
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 9e2ecba..da567a8 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -10142,11 +10142,7 @@
// this decision.
boolean skip = false;
if (intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())) {
- // If this is replacing an existing package, then we allow it
- // to see the broadcast for it to restart itself.
- if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) {
- skip = true;
- }
+ skip = true;
} else if (intent.ACTION_PACKAGE_RESTARTED.equals(intent.getAction())) {
skip = true;
} else if (intent.ACTION_PACKAGE_DATA_CLEARED.equals(intent.getAction())) {