Skip to content

Commit 26ece57

Browse files
committed
Be more discriminating when canceling notifications on changing packages.
Specifically: don't do it if the package is enabled at the time the PACKAGE_CHANGED broadcast is sent. (We only want to cancel notifications when packages enter the disabled state.) Bug: 6589355 Change-Id: Iba754cef27e2bdff35a13e403a867933c996f562
1 parent 046fddf commit 26ece57

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

services/java/com/android/server/NotificationManagerService.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,10 +494,11 @@ public void onReceive(Context context, Intent intent) {
494494
String action = intent.getAction();
495495

496496
boolean queryRestart = false;
497+
boolean packageChanged = false;
497498

498499
if (action.equals(Intent.ACTION_PACKAGE_REMOVED)
499500
|| action.equals(Intent.ACTION_PACKAGE_RESTARTED)
500-
|| action.equals(Intent.ACTION_PACKAGE_CHANGED)
501+
|| (packageChanged=action.equals(Intent.ACTION_PACKAGE_CHANGED))
501502
|| (queryRestart=action.equals(Intent.ACTION_QUERY_PACKAGE_RESTART))
502503
|| action.equals(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE)) {
503504
String pkgList[] = null;
@@ -514,6 +515,15 @@ public void onReceive(Context context, Intent intent) {
514515
if (pkgName == null) {
515516
return;
516517
}
518+
if (packageChanged) {
519+
// We cancel notifications for packages which have just been disabled
520+
final int enabled = mContext.getPackageManager()
521+
.getApplicationEnabledSetting(pkgName);
522+
if (enabled == PackageManager.COMPONENT_ENABLED_STATE_ENABLED
523+
|| enabled == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT) {
524+
return;
525+
}
526+
}
517527
pkgList = new String[]{pkgName};
518528
}
519529
if (pkgList != null && (pkgList.length > 0)) {

0 commit comments

Comments
 (0)