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

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

Merge "Adding additional listeners (onNotificationVisibilityChanged,...

Merge "Adding additional listeners (onNotificationVisibilityChanged, onPanelHidden, onPanelRevealed) to NotificationAssistantService."
parents d321ba1d 509e5548
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -8667,7 +8667,10 @@ package android.service.notification {
    method @Nullable public android.service.notification.Adjustment onNotificationEnqueued(@NonNull android.service.notification.StatusBarNotification, @NonNull android.app.NotificationChannel);
    method public void onNotificationExpansionChanged(@NonNull String, boolean, boolean);
    method public abstract void onNotificationSnoozedUntilContext(@NonNull android.service.notification.StatusBarNotification, @NonNull String);
    method public void onNotificationVisibilityChanged(@NonNull String, boolean);
    method public void onNotificationsSeen(@NonNull java.util.List<java.lang.String>);
    method public void onPanelHidden();
    method public void onPanelRevealed(int);
    method public void onSuggestedReplySent(@NonNull String, @NonNull CharSequence, int);
    method public final void unsnoozeNotification(@NonNull String);
    field public static final String SERVICE_INTERFACE = "android.service.notification.NotificationAssistantService";
+5 −0
Original line number Diff line number Diff line
@@ -435,6 +435,8 @@ package android.app {
  }

  public class StatusBarManager {
    method public void collapsePanels();
    method public void expandNotificationsPanel();
    method @NonNull @RequiresPermission(android.Manifest.permission.STATUS_BAR) public android.app.StatusBarManager.DisableInfo getDisableInfo();
    method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public void setDisabledForSetup(boolean);
    method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public void setDisabledForSimNetworkLock(boolean);
@@ -2929,7 +2931,10 @@ package android.service.notification {
    method @Nullable public android.service.notification.Adjustment onNotificationEnqueued(@NonNull android.service.notification.StatusBarNotification, @NonNull android.app.NotificationChannel);
    method public void onNotificationExpansionChanged(@NonNull String, boolean, boolean);
    method public abstract void onNotificationSnoozedUntilContext(@NonNull android.service.notification.StatusBarNotification, @NonNull String);
    method public void onNotificationVisibilityChanged(@NonNull String, boolean);
    method public void onNotificationsSeen(@NonNull java.util.List<java.lang.String>);
    method public void onPanelHidden();
    method public void onPanelRevealed(int);
    method public void onSuggestedReplySent(@NonNull String, @NonNull CharSequence, int);
    method public final void unsnoozeNotification(@NonNull String);
    field public static final String SERVICE_INTERFACE = "android.service.notification.NotificationAssistantService";
+2 −0
Original line number Diff line number Diff line
@@ -267,6 +267,7 @@ public class StatusBarManager {
     * @hide
     */
    @UnsupportedAppUsage
    @TestApi
    public void expandNotificationsPanel() {
        try {
            final IStatusBarService svc = getService();
@@ -284,6 +285,7 @@ public class StatusBarManager {
     * @hide
     */
    @UnsupportedAppUsage
    @TestApi
    public void collapsePanels() {
        try {
            final IStatusBarService svc = getService();
+3 −0
Original line number Diff line number Diff line
@@ -49,6 +49,9 @@ oneway interface INotificationListener
    void onNotificationEnqueuedWithChannel(in IStatusBarNotificationHolder notificationHolder, in NotificationChannel channel);
    void onNotificationSnoozedUntilContext(in IStatusBarNotificationHolder notificationHolder, String snoozeCriterionId);
    void onNotificationsSeen(in List<String> keys);
    void onPanelRevealed(int items);
    void onPanelHidden();
    void onNotificationVisibilityChanged(String key, boolean isVisible);
    void onNotificationExpansionChanged(String key, boolean userAction, boolean expanded);
    void onNotificationDirectReply(String key);
    void onSuggestedReplySent(String key, in CharSequence reply, int source);
+72 −0
Original line number Diff line number Diff line
@@ -181,6 +181,32 @@ public abstract class NotificationAssistantService extends NotificationListenerS

    }

    /**
     * Implement this to know when the notification panel is revealed
     *
     * @param items Number of items on the panel at time of opening
     */
    public void onPanelRevealed(int items) {

    }

    /**
     * Implement this to know when the notification panel is hidden
     */
    public void onPanelHidden() {

    }

    /**
     * Implement this to know when a notification becomes visible or hidden from the user.
     *
     * @param key the notification key
     * @param isVisible whether the notification is visible.
     */
    public void onNotificationVisibilityChanged(@NonNull String key, boolean isVisible) {

    }

    /**
     * Implement this to know when a notification change (expanded / collapsed) is visible to user.
     *
@@ -336,6 +362,30 @@ public abstract class NotificationAssistantService extends NotificationListenerS
                    args).sendToTarget();
        }

        @Override
        public void onPanelRevealed(int items) {
            SomeArgs args = SomeArgs.obtain();
            args.argi1 = items;
            mHandler.obtainMessage(MyHandler.MSG_ON_PANEL_REVEALED,
                    args).sendToTarget();
        }

        @Override
        public void onPanelHidden() {
            SomeArgs args = SomeArgs.obtain();
            mHandler.obtainMessage(MyHandler.MSG_ON_PANEL_HIDDEN,
                    args).sendToTarget();
        }

        @Override
        public void onNotificationVisibilityChanged(String key, boolean isVisible) {
            SomeArgs args = SomeArgs.obtain();
            args.arg1 = key;
            args.argi1 = isVisible ? 1 : 0;
            mHandler.obtainMessage(MyHandler.MSG_ON_NOTIFICATION_VISIBILITY_CHANGED,
                    args).sendToTarget();
        }

        @Override
        public void onNotificationExpansionChanged(String key, boolean isUserAction,
                boolean isExpanded) {
@@ -394,6 +444,9 @@ public abstract class NotificationAssistantService extends NotificationListenerS
        public static final int MSG_ON_SUGGESTED_REPLY_SENT = 6;
        public static final int MSG_ON_ACTION_INVOKED = 7;
        public static final int MSG_ON_ALLOWED_ADJUSTMENTS_CHANGED = 8;
        public static final int MSG_ON_PANEL_REVEALED = 9;
        public static final int MSG_ON_PANEL_HIDDEN = 10;
        public static final int MSG_ON_NOTIFICATION_VISIBILITY_CHANGED = 11;

        public MyHandler(Looper looper) {
            super(looper, null, false);
@@ -480,6 +533,25 @@ public abstract class NotificationAssistantService extends NotificationListenerS
                    onAllowedAdjustmentsChanged();
                    break;
                }
                case MSG_ON_PANEL_REVEALED: {
                    SomeArgs args = (SomeArgs) msg.obj;
                    int items = args.argi1;
                    args.recycle();
                    onPanelRevealed(items);
                    break;
                }
                case MSG_ON_PANEL_HIDDEN: {
                    onPanelHidden();
                    break;
                }
                case MSG_ON_NOTIFICATION_VISIBILITY_CHANGED: {
                    SomeArgs args = (SomeArgs) msg.obj;
                    String key = (String) args.arg1;
                    boolean isVisible = args.argi1 == 1;
                    args.recycle();
                    onNotificationVisibilityChanged(key, isVisible);
                    break;
                }
            }
        }
    }
Loading