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

Commit ca1b6f74 authored by Gus Prevas's avatar Gus Prevas
Browse files

Removes dependency of NotificationEntryManager on IStatusBarService.

This change moves the logic in NotificationEntryManager which logs
notification removal and inflation errors via the IStatusBarService to
the NotificationLogger, which is already logging visibility changes to
that service.

Test: atest SystemUITests, manual
Change-Id: I895a36db505a165c4e6684d1d6e66592e62ef1f7
parent 18e35038
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import android.util.Log;
import android.view.View;
import android.widget.ImageView;

import com.android.internal.statusbar.NotificationVisibility;
import com.android.systemui.Dependency;
import com.android.systemui.Dumpable;
import com.android.systemui.Interpolators;
@@ -159,6 +160,7 @@ public class NotificationMediaManager implements Dumpable {
                    Entry entry,
                    String key,
                    StatusBarNotification old,
                    NotificationVisibility visibility,
                    boolean lifetimeExtended,
                    boolean removedByUser) {
                if (!lifetimeExtended) {
+1 −0
Original line number Diff line number Diff line
@@ -255,6 +255,7 @@ public class NotificationRemoteInputManager implements Dumpable {
                    NotificationData.Entry entry,
                    String key,
                    StatusBarNotification old,
                    NotificationVisibility visibility,
                    boolean lifetimeExtended,
                    boolean removedByUser) {
                if (removedByUser) {
+2 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.app.Notification;
import android.service.notification.StatusBarNotification;
import android.util.Log;

import com.android.internal.statusbar.NotificationVisibility;
import com.android.systemui.statusbar.AlertingNotificationManager;
import com.android.systemui.statusbar.AmbientPulseManager;
import com.android.systemui.statusbar.NotificationListener;
@@ -84,6 +85,7 @@ public class NotificationAlertingManager {
                    NotificationData.Entry entry,
                    String key,
                    StatusBarNotification old,
                    NotificationVisibility visibility,
                    boolean lifetimeExtended,
                    boolean removedByUser) {
                stopAlerting(key);
+12 −0
Original line number Diff line number Diff line
@@ -15,8 +15,10 @@
 */
package com.android.systemui.statusbar.notification;

import android.annotation.Nullable;
import android.service.notification.StatusBarNotification;

import com.android.internal.statusbar.NotificationVisibility;
import com.android.systemui.statusbar.notification.row.NotificationInflater;

/**
@@ -58,6 +60,12 @@ public interface NotificationEntryListener {
    default void onEntryReinflated(NotificationData.Entry entry) {
    }

    /**
     * Called when an error occurred inflating the views for a notification.
     */
    default void onInflationError(StatusBarNotification notification, Exception exception) {
    }

    /**
     * Called when a notification has been removed (either because the user swiped it away or
     * because the developer retracted it).
@@ -65,6 +73,9 @@ public interface NotificationEntryListener {
     *              removed key at the time of removal.
     * @param key key of notification that was removed
     * @param old StatusBarNotification of the notification before it was removed
     * @param visibility logging data related to the visibility of the notification at the time of
     *                   removal, if it was removed by a user action.  Null if it was not removed by
     *                   a user action.
     * @param lifetimeExtended true if something is artificially extending how long the notification
     * @param removedByUser true if the notification was removed by a user action
     */
@@ -72,6 +83,7 @@ public interface NotificationEntryListener {
            NotificationData.Entry entry,
            String key,
            StatusBarNotification old,
            @Nullable NotificationVisibility visibility,
            boolean lifetimeExtended,
            boolean removedByUser) {
    }
+8 −35
Original line number Diff line number Diff line
@@ -22,18 +22,14 @@ import android.app.Notification;
import android.content.Context;
import android.os.Handler;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.service.notification.NotificationListenerService;
import android.service.notification.NotificationStats;
import android.service.notification.StatusBarNotification;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Log;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.statusbar.NotificationVisibility;
import com.android.systemui.Dependency;
import com.android.systemui.Dumpable;
@@ -98,7 +94,6 @@ public class NotificationEntryManager implements
    private final Handler mDeferredNotificationViewUpdateHandler;
    private Runnable mUpdateNotificationViewsCallback;

    protected IStatusBarService mBarService;
    private NotificationPresenter mPresenter;
    protected PowerManager mPowerManager;
    private NotificationListenerService.RankingMap mLatestRankingMap;
@@ -139,8 +134,6 @@ public class NotificationEntryManager implements
    public NotificationEntryManager(Context context) {
        mContext = context;
        mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
        mBarService = IStatusBarService.Stub.asInterface(
                ServiceManager.getService(Context.STATUS_BAR_SERVICE));
        mBubbleController.setDismissListener(this /* bubbleEventListener */);
        mNotificationData = new NotificationData();
        mDeferredNotificationViewUpdateHandler = new Handler();
@@ -215,26 +208,8 @@ public class NotificationEntryManager implements
        final int count = mNotificationData.getActiveNotifications().size();
        final NotificationVisibility nv = NotificationVisibility.obtain(n.getKey(), rank, count,
                true);

        final String pkg = n.getPackageName();
        final String tag = n.getTag();
        final int id = n.getId();
        final int userId = n.getUserId();
        try {
            int dismissalSurface = NotificationStats.DISMISSAL_SHADE;
            if (mHeadsUpManager.isAlerting(n.getKey())) {
                dismissalSurface = NotificationStats.DISMISSAL_PEEK;
            } else if (mListContainer.hasPulsingNotifications()) {
                dismissalSurface = NotificationStats.DISMISSAL_AOD;
            }
            int dismissalSentiment = NotificationStats.DISMISS_SENTIMENT_NEUTRAL;
            mBarService.onNotificationClear(pkg, tag, id, userId, n.getKey(), dismissalSurface,
                    dismissalSentiment, nv);
        removeNotificationInternal(
                    n.getKey(), null, false /* forceRemove */, true /* removedByUser */);
        } catch (RemoteException ex) {
            // system process is dead if we're here.
        }
                n.getKey(), null, nv, false /* forceRemove */, true /* removedByUser */);
    }

    @Override
@@ -275,12 +250,9 @@ public class NotificationEntryManager implements
    @Override
    public void handleInflationException(StatusBarNotification n, Exception e) {
        removeNotificationInternal(
                n.getKey(), null, true /* forceRemove */, false /* removedByUser */);
        try {
            mBarService.onNotificationError(n.getPackageName(), n.getTag(), n.getId(), n.getUid(),
                    n.getInitialPid(), e.getMessage(), n.getUserId());
        } catch (RemoteException ex) {
            // The end is nigh.
                n.getKey(), null, null, true /* forceRemove */, false /* removedByUser */);
        for (NotificationEntryListener listener : mNotificationEntryListeners) {
            listener.onInflationError(n, e);
        }
    }

@@ -333,12 +305,13 @@ public class NotificationEntryManager implements
    @Override
    public void removeNotification(String key, NotificationListenerService.RankingMap ranking) {
        removeNotificationInternal(
                key, ranking, false /* forceRemove */, false /* removedByUser */);
                key, ranking, null, false /* forceRemove */, false /* removedByUser */);
    }

    private void removeNotificationInternal(
            String key,
            @Nullable NotificationListenerService.RankingMap ranking,
            @Nullable NotificationVisibility visibility,
            boolean forceRemove,
            boolean removedByUser) {
        final NotificationData.Entry entry = mNotificationData.get(key);
@@ -385,7 +358,7 @@ public class NotificationEntryManager implements
        }

        for (NotificationEntryListener listener : mNotificationEntryListeners) {
            listener.onEntryRemoved(entry, key, old, lifetimeExtended, removedByUser);
            listener.onEntryRemoved(entry, key, old, visibility, lifetimeExtended, removedByUser);
        }
    }

Loading