From 06e5fed139b69eb231a6e26c67b462a515aba469 Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Wed, 9 Oct 2013 14:39:15 -0700 Subject: Don't crash when component enable/disable broadcasts race with uninstall Bug 11154482 Change-Id: I55107fec51bf5efada136052c451f293976360d6 --- .../com/android/server/NotificationManagerService.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'services/java/com/android/server/NotificationManagerService.java') diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java index b881934..7431f1d 100644 --- a/services/java/com/android/server/NotificationManagerService.java +++ b/services/java/com/android/server/NotificationManagerService.java @@ -1167,11 +1167,19 @@ public class NotificationManagerService extends INotificationManager.Stub } if (packageChanged) { // We cancel notifications for packages which have just been disabled - final int enabled = mContext.getPackageManager() - .getApplicationEnabledSetting(pkgName); - if (enabled == PackageManager.COMPONENT_ENABLED_STATE_ENABLED - || enabled == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT) { - cancelNotifications = false; + try { + final int enabled = mContext.getPackageManager() + .getApplicationEnabledSetting(pkgName); + if (enabled == PackageManager.COMPONENT_ENABLED_STATE_ENABLED + || enabled == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT) { + cancelNotifications = false; + } + } catch (IllegalArgumentException e) { + // Package doesn't exist; probably racing with uninstall. + // cancelNotifications is already true, so nothing to do here. + if (DBG) { + Slog.i(TAG, "Exception trying to look up app enabled setting", e); + } } } pkgList = new String[]{pkgName}; -- cgit v1.1