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

Commit fd4099d7 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Add ability to pass user sentiment to assistant

Test: runtest systemui-notification
Bug: 4798501
Change-Id: Ied0d0a83c4fbbdde59ee8f4e9394161792c42c03
parent cfd2692a
Loading
Loading
Loading
Loading
+49 −1
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ public final class NotificationStats implements Parcelable {
    /**
     * Notification has not been dismissed yet.
     */
    public static final int DISMISSAL_NOT_DISMISSED = -1;
    public static final int DISMISSAL_NOT_DISMISSED = -1000;
    /**
     * Notification has been dismissed from a {@link NotificationListenerService} or the app
     * itself.
@@ -71,6 +71,37 @@ public final class NotificationStats implements Parcelable {
     */
    public static final int DISMISSAL_SHADE = 3;

    /** @hide */
    @IntDef(prefix = { "DISMISS_SENTIMENT_" }, value = {
            DISMISS_SENTIMENT_UNKNOWN, DISMISS_SENTIMENT_NEGATIVE, DISMISS_SENTIMENT_NEUTRAL,
            DISMISS_SENTIMENT_POSITIVE
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface DismissalSentiment {}

    /**
     * No information is available about why this notification was dismissed, or the notification
     * isn't dismissed yet.
     */
    public static final int DISMISS_SENTIMENT_UNKNOWN = -1000;
    /**
     * The user indicated while dismissing that they did not like the notification.
     */
    public static final int DISMISS_SENTIMENT_NEGATIVE = 0;
    /**
     * The user didn't indicate one way or another how they felt about the notification while
     * dismissing it.
     */
    public static final int DISMISS_SENTIMENT_NEUTRAL = 1;
    /**
     * The user indicated while dismissing that they did like the notification.
     */
    public static final int DISMISS_SENTIMENT_POSITIVE = 2;


    private @DismissalSentiment
    int mDismissalSentiment = DISMISS_SENTIMENT_UNKNOWN;

    public NotificationStats() {
    }

@@ -82,6 +113,7 @@ public final class NotificationStats implements Parcelable {
        mViewedSettings = in.readByte() != 0;
        mInteracted = in.readByte() != 0;
        mDismissalSurface = in.readInt();
        mDismissalSentiment = in.readInt();
    }

    @Override
@@ -93,6 +125,7 @@ public final class NotificationStats implements Parcelable {
        dest.writeByte((byte) (mViewedSettings ? 1 : 0));
        dest.writeByte((byte) (mInteracted ? 1 : 0));
        dest.writeInt(mDismissalSurface);
        dest.writeInt(mDismissalSentiment);
    }

    @Override
@@ -212,6 +245,21 @@ public final class NotificationStats implements Parcelable {
        mDismissalSurface = dismissalSurface;
    }

    /**
     * Records whether the user indicated how they felt about a notification before or
     * during dismissal.
     */
    public void setDismissalSentiment(@DismissalSentiment int dismissalSentiment) {
        mDismissalSentiment = dismissalSentiment;
    }

    /**
     * Returns how the user indicated they felt about a notification before or during dismissal.
     */
    public @DismissalSentiment int getDismissalSentiment() {
        return mDismissalSentiment;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ interface IStatusBarService
            int uid, int initialPid, String message, int userId);
    void onClearAllNotifications(int userId);
    void onNotificationClear(String pkg, String tag, int id, int userId, String key,
            int dismissalSurface, in NotificationVisibility nv);
            int dismissalSurface, int dismissalSentiment, in NotificationVisibility nv);
    void onNotificationVisibilityChanged( in NotificationVisibility[] newlyVisibleKeys,
            in NotificationVisibility[] noLongerVisibleKeys);
    void onNotificationExpansionChanged(in String key, in boolean userAction, in boolean expanded);
+13 −9
Original line number Diff line number Diff line
@@ -316,7 +316,7 @@ public class Assistant extends NotificationAssistantService {
                saveFile();
            }
        } catch (Throwable e) {
            Slog.e(TAG, "Error occurred processing removal", e);
            Slog.e(TAG, "Error occurred processing removal of " + sbn, e);
        }
    }

@@ -327,6 +327,7 @@ public class Assistant extends NotificationAssistantService {

    @Override
    public void onNotificationsSeen(List<String> keys) {
        try {
            if (keys == null) {
                return;
            }
@@ -339,6 +340,9 @@ public class Assistant extends NotificationAssistantService {
                    mAgingHelper.onNotificationSeen(entry);
                }
            }
        } catch (Throwable e) {
            Slog.e(TAG, "Error occurred processing seen", e);
        }
    }

    @Override
+3 −1
Original line number Diff line number Diff line
@@ -414,7 +414,9 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
            } else if (mListContainer.hasPulsingNotifications()) {
                dismissalSurface = NotificationStats.DISMISSAL_AOD;
            }
            mBarService.onNotificationClear(pkg, tag, id, userId, n.getKey(), dismissalSurface, nv);
            int dismissalSentiment = NotificationStats.DISMISS_SENTIMENT_NEUTRAL;
            mBarService.onNotificationClear(pkg, tag, id, userId, n.getKey(), dismissalSurface,
                    dismissalSentiment, nv);
            removeNotification(n.getKey(), null);

        } catch (RemoteException ex) {
+1 −0
Original line number Diff line number Diff line
@@ -1307,6 +1307,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        }
        setDismissed(fromAccessibility);
        if (isClearable()) {
            // TODO: track dismiss sentiment
            if (mOnDismissRunnable != null) {
                mOnDismissRunnable.run();
            }
Loading