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

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

Merge "Introduce onNotificationExpansionChanged and onNotificationDirectReplied .. in NAS"

parents 8df41524 eda84a7b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -5076,8 +5076,10 @@ package android.service.notification {
    method public final void adjustNotification(android.service.notification.Adjustment);
    method public final void adjustNotifications(java.util.List<android.service.notification.Adjustment>);
    method public final android.os.IBinder onBind(android.content.Intent);
    method public void onNotificationDirectReply(java.lang.String);
    method public android.service.notification.Adjustment onNotificationEnqueued(android.service.notification.StatusBarNotification);
    method public android.service.notification.Adjustment onNotificationEnqueued(android.service.notification.StatusBarNotification, android.app.NotificationChannel);
    method public void onNotificationExpansionChanged(java.lang.String, boolean, boolean);
    method public void onNotificationRemoved(android.service.notification.StatusBarNotification, android.service.notification.NotificationListenerService.RankingMap, android.service.notification.NotificationStats, int);
    method public abstract void onNotificationSnoozedUntilContext(android.service.notification.StatusBarNotification, java.lang.String);
    method public void onNotificationsSeen(java.util.List<java.lang.String>);
+2 −0
Original line number Diff line number Diff line
@@ -1156,8 +1156,10 @@ package android.service.notification {
    method public final void adjustNotification(android.service.notification.Adjustment);
    method public final void adjustNotifications(java.util.List<android.service.notification.Adjustment>);
    method public final android.os.IBinder onBind(android.content.Intent);
    method public void onNotificationDirectReply(java.lang.String);
    method public android.service.notification.Adjustment onNotificationEnqueued(android.service.notification.StatusBarNotification);
    method public android.service.notification.Adjustment onNotificationEnqueued(android.service.notification.StatusBarNotification, android.app.NotificationChannel);
    method public void onNotificationExpansionChanged(java.lang.String, boolean, boolean);
    method public abstract void onNotificationSnoozedUntilContext(android.service.notification.StatusBarNotification, java.lang.String);
    method public void onNotificationsSeen(java.util.List<java.lang.String>);
    method public final void unsnoozeNotification(java.lang.String);
+2 −0
Original line number Diff line number Diff line
@@ -47,4 +47,6 @@ 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 onNotificationExpansionChanged(String key, boolean userAction, boolean expanded);
    void onNotificationDirectReply(String key);
}
+52 −0
Original line number Diff line number Diff line
@@ -159,6 +159,21 @@ public abstract class NotificationAssistantService extends NotificationListenerS

    }

    /**
     * Implement this to know when a notification is expanded / collapsed.
     * @param key the notification key
     * @param isUserAction whether the expanded change is caused by user action.
     * @param isExpanded whether the notification is expanded.
     */
    public void onNotificationExpansionChanged(
            String key, boolean isUserAction, boolean isExpanded) {}

    /**
     * Implement this to know when a direct reply is sent from a notification.
     * @param key the notification key
     */
    public void onNotificationDirectReply(String key) {}

    /**
     * Updates a notification.  N.B. this won’t cause
     * an existing notification to alert, but might allow a future update to
@@ -255,12 +270,33 @@ public abstract class NotificationAssistantService extends NotificationListenerS
            mHandler.obtainMessage(MyHandler.MSG_ON_NOTIFICATIONS_SEEN,
                    args).sendToTarget();
        }

        @Override
        public void onNotificationExpansionChanged(String key, boolean isUserAction,
                boolean isExpanded) {
            SomeArgs args = SomeArgs.obtain();
            args.arg1 = key;
            args.argi1 = isUserAction ? 1 : 0;
            args.argi2 = isExpanded ? 1 : 0;
            mHandler.obtainMessage(MyHandler.MSG_ON_NOTIFICATION_EXPANSION_CHANGED, args)
                    .sendToTarget();
        }

        @Override
        public void onNotificationDirectReply(String key) {
            SomeArgs args = SomeArgs.obtain();
            args.arg1 = key;
            mHandler.obtainMessage(MyHandler.MSG_ON_NOTIFICATION_DIRECT_REPLY_SENT, args)
                    .sendToTarget();
        }
    }

    private final class MyHandler extends Handler {
        public static final int MSG_ON_NOTIFICATION_ENQUEUED = 1;
        public static final int MSG_ON_NOTIFICATION_SNOOZED = 2;
        public static final int MSG_ON_NOTIFICATIONS_SEEN = 3;
        public static final int MSG_ON_NOTIFICATION_EXPANSION_CHANGED = 4;
        public static final int MSG_ON_NOTIFICATION_DIRECT_REPLY_SENT = 5;

        public MyHandler(Looper looper) {
            super(looper, null, false);
@@ -305,6 +341,22 @@ public abstract class NotificationAssistantService extends NotificationListenerS
                    onNotificationsSeen(keys);
                    break;
                }
                case MSG_ON_NOTIFICATION_EXPANSION_CHANGED: {
                    SomeArgs args = (SomeArgs) msg.obj;
                    String key = (String) args.arg1;
                    boolean isUserAction = args.argi1 == 1;
                    boolean isExpanded = args.argi2 == 1;
                    args.recycle();
                    onNotificationExpansionChanged(key, isUserAction, isExpanded);
                    break;
                }
                case MSG_ON_NOTIFICATION_DIRECT_REPLY_SENT: {
                    SomeArgs args = (SomeArgs) msg.obj;
                    String key = (String) args.arg1;
                    args.recycle();
                    onNotificationDirectReply(key);
                    break;
                }
            }
        }
    }
+11 −0
Original line number Diff line number Diff line
@@ -1365,6 +1365,17 @@ public abstract class NotificationListenerService extends Service {
            // no-op in the listener
        }

        @Override
        public void onNotificationExpansionChanged(
                String key, boolean isUserAction, boolean isExpanded) {
            // no-op in the listener
        }

        @Override
        public void onNotificationDirectReply(String key) {
            // no-op in the listener
        }

        @Override
        public void onNotificationChannelModification(String pkgName, UserHandle user,
                NotificationChannel channel,
Loading