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

Commit 6b531357 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Cache notifications less aggressively.

Bug: 25694023
Change-Id: Ie8f1b518fdcb72cfbd982908aa30cdb8ebbb2f02
parent 089e3e45
Loading
Loading
Loading
Loading
+12 −19
Original line number Diff line number Diff line
@@ -105,36 +105,29 @@ public class NotificationData {
        }

        public boolean cacheContentViews(Context ctx, Notification updatedNotification) {
            boolean cached = false;
            boolean applyInPlace = false;
            if (updatedNotification != null) {
                final Notification.Builder updatedNotificationBuilder
                        = Notification.Builder.recoverBuilder(ctx, updatedNotification);
                final RemoteViews newContentView = updatedNotificationBuilder.makeContentView();
                if (!compareRemoteViews(cachedContentView, newContentView)) {
                    cachedContentView = newContentView;
                    cached |= true;
                }
                final RemoteViews newBigContentView =
                        updatedNotificationBuilder.makeBigContentView();
                if (!compareRemoteViews(cachedBigContentView, newBigContentView)) {
                    cachedBigContentView = newBigContentView;
                    cached |= true;
                }
                final RemoteViews newHeadsUpContentView =
                        updatedNotificationBuilder.makeHeadsUpContentView();
                if (!compareRemoteViews(cachedHeadsUpContentView, newBigContentView)) {
                    cachedHeadsUpContentView = newHeadsUpContentView;
                    cached |= true;
                }
                final Notification updatedPublicNotification = updatedNotification.publicVersion;
                final RemoteViews newPubContentView = (updatedPublicNotification != null)
                        ? Notification.Builder.recoverBuilder(
                                ctx, updatedPublicNotification).makeContentView()
                        : null;
                if (!compareRemoteViews(cachedPublicContentView, newPubContentView)) {

                applyInPlace = compareRemoteViews(cachedContentView, newContentView)
                        && compareRemoteViews(cachedBigContentView, newBigContentView)
                        && compareRemoteViews(cachedHeadsUpContentView, newHeadsUpContentView)
                        && compareRemoteViews(cachedPublicContentView, newPubContentView);
                cachedPublicContentView = newPubContentView;
                    cached |= true;
                }
                cachedHeadsUpContentView = newHeadsUpContentView;
                cachedBigContentView = newBigContentView;
                cachedContentView = newContentView;
            } else {
                final Notification.Builder builder
                        = Notification.Builder.recoverBuilder(ctx, notification.getNotification());
@@ -150,9 +143,9 @@ public class NotificationData {
                            = Notification.Builder.recoverBuilder(ctx, publicNotification);
                    cachedPublicContentView = publicBuilder.makeContentView();
                }
                cached = true;
                applyInPlace = false;
            }
            return cached;
            return applyInPlace;
        }

        // Returns true if the RemoteViews are the same.