summaryrefslogtreecommitdiffstats
path: root/services/java/com
diff options
context:
space:
mode:
authorChristopher Tate <ctate@google.com>2013-11-14 15:44:40 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2013-11-14 15:44:40 -0800
commita5acd62bdefe5b616c0ea080434e9dd221169527 (patch)
tree7e6ff24a50b1dd5a286b142e6aef621712533efe /services/java/com
parent8e9b5fc93278084487fd98726c6e20333d675c40 (diff)
parent6e5cf573f2f2e17825af2973daeba893c6aa5855 (diff)
downloadframeworks_base-a5acd62bdefe5b616c0ea080434e9dd221169527.zip
frameworks_base-a5acd62bdefe5b616c0ea080434e9dd221169527.tar.gz
frameworks_base-a5acd62bdefe5b616c0ea080434e9dd221169527.tar.bz2
am 6e5cf573: am 99437f25: Merge "Ensure recipient can be launched before attempting broadcast delivery" into klp-dev
* commit '6e5cf573f2f2e17825af2973daeba893c6aa5855': Ensure recipient can be launched before attempting broadcast delivery
Diffstat (limited to 'services/java/com')
-rw-r--r--services/java/com/android/server/am/BroadcastQueue.java21
-rwxr-xr-xservices/java/com/android/server/pm/PackageManagerService.java18
2 files changed, 39 insertions, 0 deletions
diff --git a/services/java/com/android/server/am/BroadcastQueue.java b/services/java/com/android/server/am/BroadcastQueue.java
index dd3d8aa..bfb667f 100644
--- a/services/java/com/android/server/am/BroadcastQueue.java
+++ b/services/java/com/android/server/am/BroadcastQueue.java
@@ -27,6 +27,7 @@ import android.content.ComponentName;
import android.content.IIntentReceiver;
import android.content.Intent;
import android.content.pm.ActivityInfo;
+import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
@@ -814,6 +815,26 @@ public final class BroadcastQueue {
+ " to " + r.curApp + ": process crashing");
skip = true;
}
+ if (!skip) {
+ boolean isAvailable = false;
+ try {
+ isAvailable = AppGlobals.getPackageManager().isPackageAvailable(
+ info.activityInfo.packageName,
+ UserHandle.getUserId(info.activityInfo.applicationInfo.uid));
+ } catch (Exception e) {
+ // all such failures mean we skip this receiver
+ Slog.w(TAG, "Exception getting recipient info for "
+ + info.activityInfo.packageName, e);
+ }
+ if (!isAvailable) {
+ if (DEBUG_BROADCAST) {
+ Slog.v(TAG, "Skipping delivery to " + info.activityInfo.packageName
+ + " / " + info.activityInfo.applicationInfo.uid
+ + " : package no longer available");
+ }
+ skip = true;
+ }
+ }
if (skip) {
if (DEBUG_BROADCAST) Slog.v(TAG,
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java
index 841a531..0212bcf 100755
--- a/services/java/com/android/server/pm/PackageManagerService.java
+++ b/services/java/com/android/server/pm/PackageManagerService.java
@@ -1771,6 +1771,24 @@ public class PackageManagerService extends IPackageManager.Stub {
state, userId);
}
+ public boolean isPackageAvailable(String packageName, int userId) {
+ if (!sUserManager.exists(userId)) return false;
+ enforceCrossUserPermission(Binder.getCallingUid(), userId, false, "is package available");
+ synchronized (mPackages) {
+ PackageParser.Package p = mPackages.get(packageName);
+ if (p != null) {
+ final PackageSetting ps = (PackageSetting) p.mExtras;
+ if (ps != null) {
+ final PackageUserState state = ps.readUserState(userId);
+ if (state != null) {
+ return PackageParser.isAvailable(state);
+ }
+ }
+ }
+ }
+ return false;
+ }
+
@Override
public PackageInfo getPackageInfo(String packageName, int flags, int userId) {
if (!sUserManager.exists(userId)) return null;