Merge "Don't crash when component enable/disable broadcasts race with uninstall" into klp-dev

This commit is contained in:
Christopher Tate
2013-10-09 22:18:41 +00:00
committed by Android (Google) Code Review

View File

@ -1167,11 +1167,19 @@ public class NotificationManagerService extends INotificationManager.Stub
} }
if (packageChanged) { if (packageChanged) {
// We cancel notifications for packages which have just been disabled // We cancel notifications for packages which have just been disabled
final int enabled = mContext.getPackageManager() try {
.getApplicationEnabledSetting(pkgName); final int enabled = mContext.getPackageManager()
if (enabled == PackageManager.COMPONENT_ENABLED_STATE_ENABLED .getApplicationEnabledSetting(pkgName);
|| enabled == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT) { if (enabled == PackageManager.COMPONENT_ENABLED_STATE_ENABLED
cancelNotifications = false; || 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}; pkgList = new String[]{pkgName};