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

Commit d04bce90 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Store inflation error boolean on NotifEntries"

parents ac3def40 6e6ce1bf
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -294,6 +294,10 @@ public class NotificationEntryManager implements
     * WARNING: this will call back into us.  Don't hold any locks.
     */
    @Override
    public void handleInflationException(NotificationEntry n, Exception e) {
        handleInflationException(n.getSbn(), e);
    }

    public void handleInflationException(StatusBarNotification n, Exception e) {
        removeNotificationInternal(
                n.getKey(), null, null, true /* forceRemove */, false /* removedByUser */,
+7 −4
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ import javax.inject.Singleton;
/**
 * Handles notification inflating, rebinding, and inflation aborting.
 *
 * Currently a wrapper for NotificationRowBinderImpl which requires some TLC.
 * Currently a wrapper for NotificationRowBinderImpl.
 */
@Singleton
public class NotifInflaterImpl implements NotifInflater {
@@ -58,7 +58,7 @@ public class NotifInflaterImpl implements NotifInflater {
     */
    public void setRowBinder(NotificationRowBinderImpl rowBinder) {
        mNotificationRowBinder = rowBinder;
        requireBinder().setInflationCallback(mInflationCallback);
        mNotificationRowBinder.setInflationCallback(mInflationCallback);
    }

    @Override
@@ -78,9 +78,10 @@ public class NotifInflaterImpl implements NotifInflater {
    @Override
    public void inflateViews(NotificationEntry entry) {
        try {
            entry.setHasInflationError(false);
            requireBinder().inflateViews(entry, getDismissCallback(entry));
        } catch (InflationException e) {
            // logged in the inflation callback
            // logged in mInflationCallback.handleInflationException
        }
    }

@@ -126,9 +127,11 @@ public class NotifInflaterImpl implements NotifInflater {
            new NotificationContentInflater.InflationCallback() {
                @Override
                public void handleInflationException(
                        StatusBarNotification sbn,
                        NotificationEntry entry,
                        Exception e) {
                    entry.setHasInflationError(true);
                    try {
                        final StatusBarNotification sbn = entry.getSbn();
                        // report notification inflation errors back up
                        // to notification delegates
                        mStatusBarService.onNotificationError(
+15 −0
Original line number Diff line number Diff line
@@ -102,6 +102,9 @@ public final class NotificationEntry extends ListEntry {
    /** If this was a group child that was promoted to the top level, then who did the promoting. */
    @Nullable NotifPromoter mNotifPromoter;

    /** If this notification had an issue with inflating. Only used with the NewNotifPipeline **/
    private boolean mHasInflationError;


    /*
    * Old members
@@ -576,6 +579,18 @@ public final class NotificationEntry extends ListEntry {
        remoteInputTextWhenReset = null;
    }

    void setHasInflationError(boolean hasError) {
        mHasInflationError = hasError;
    }

    /**
     * Whether this notification had an error when attempting to inflate. This is only used in
     * the NewNotifPipeline
     */
    public boolean hasInflationError() {
        return mHasInflationError;
    }

    public void setHasSentReply() {
        hasSentReply = true;
    }
+22 −3
Original line number Diff line number Diff line
@@ -57,7 +57,8 @@ public class PreparationCoordinator implements Coordinator {
    @Override
    public void attach(NotifCollection notifCollection, NotifListBuilder notifListBuilder) {
        notifCollection.addCollectionListener(mNotifCollectionListener);
        notifListBuilder.addPreRenderFilter(mNotifFilter);
        notifListBuilder.addPreRenderFilter(mNotifInflationErrorFilter);
        notifListBuilder.addPreRenderFilter(mNotifInflatingFilter);
    }

    private final NotifCollectionListener mNotifCollectionListener = new NotifCollectionListener() {
@@ -77,7 +78,25 @@ public class PreparationCoordinator implements Coordinator {
        }
    };

    private final NotifFilter mNotifFilter = new NotifFilter(TAG) {
    private final NotifFilter mNotifInflationErrorFilter = new NotifFilter(
            TAG + "InflationError") {
        /**
         * Filters out notifications that threw an error when attempting to inflate.
         */
        @Override
        public boolean shouldFilterOut(NotificationEntry entry, long now) {
            if (entry.hasInflationError()) {
                mPendingNotifications.remove(entry);
                return true;
            }
            return false;
        }
    };

    private final NotifFilter mNotifInflatingFilter = new NotifFilter(TAG + "Inflating") {
        /**
         * Filters out notifications that haven't been inflated yet
         */
        @Override
        public boolean shouldFilterOut(NotificationEntry entry, long now) {
            return mPendingNotifications.contains(entry);
@@ -90,7 +109,7 @@ public class PreparationCoordinator implements Coordinator {
        public void onInflationFinished(NotificationEntry entry) {
            mNotifLog.log(NotifEvent.INFLATED, entry);
            mPendingNotifications.remove(entry);
            mNotifFilter.invalidateList();
            mNotifInflatingFilter.invalidateList();
        }
    };

+5 −5
Original line number Diff line number Diff line
@@ -397,7 +397,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder
                    existingWrapper.onReinflated();
                }
            } catch (Exception e) {
                handleInflationError(runningInflations, e, row.getEntry().getSbn(), callback);
                handleInflationError(runningInflations, e, row.getEntry(), callback);
                // Add a running inflation to make sure we don't trigger callbacks.
                // Safe to do because only happens in tests.
                runningInflations.put(inflationId, new CancellationSignal());
@@ -448,7 +448,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder
                    onViewApplied(newView);
                } catch (Exception anotherException) {
                    runningInflations.remove(inflationId);
                    handleInflationError(runningInflations, e, row.getEntry().getSbn(),
                    handleInflationError(runningInflations, e, row.getEntry(),
                            callback);
                }
            }
@@ -474,7 +474,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder

    private static void handleInflationError(
            HashMap<Integer, CancellationSignal> runningInflations, Exception e,
            StatusBarNotification notification, @Nullable InflationCallback callback) {
            NotificationEntry notification, @Nullable InflationCallback callback) {
        Assert.isMainThread();
        runningInflations.values().forEach(CancellationSignal::cancel);
        if (callback != null) {
@@ -707,7 +707,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder
                    + Integer.toHexString(sbn.getId());
            Log.e(StatusBar.TAG, "couldn't inflate view for notification " + ident, e);
            if (mCallback != null) {
                mCallback.handleInflationException(sbn,
                mCallback.handleInflationException(mRow.getEntry(),
                        new InflationException("Couldn't inflate contentViews" + e));
            }
        }
@@ -729,7 +729,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder
        }

        @Override
        public void handleInflationException(StatusBarNotification notification, Exception e) {
        public void handleInflationException(NotificationEntry entry, Exception e) {
            handleError(e);
        }

Loading