Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 26ece57d authored by Daniel Sandler's avatar Daniel Sandler
Browse files

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
parent 046fddff
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -494,10 +494,11 @@ public class NotificationManagerService extends INotificationManager.Stub
            String action = intent.getAction();

            boolean queryRestart = false;
            boolean packageChanged = false;
            
            if (action.equals(Intent.ACTION_PACKAGE_REMOVED)
                    || action.equals(Intent.ACTION_PACKAGE_RESTARTED)
                    || action.equals(Intent.ACTION_PACKAGE_CHANGED)
                    || (packageChanged=action.equals(Intent.ACTION_PACKAGE_CHANGED))
                    || (queryRestart=action.equals(Intent.ACTION_QUERY_PACKAGE_RESTART))
                    || action.equals(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE)) {
                String pkgList[] = null;
@@ -514,6 +515,15 @@ public class NotificationManagerService extends INotificationManager.Stub
                    if (pkgName == null) {
                        return;
                    }
                    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) {
                            return;
                        }
                    }
                    pkgList = new String[]{pkgName};
                }
                if (pkgList != null && (pkgList.length > 0)) {