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

Commit c8d49fce authored by Chloris Kuo's avatar Chloris Kuo Committed by Android (Google) Code Review
Browse files

Merge "Add NAS#onNotificationClicked API and TestAPI for cts test"

parents bf1c45fe dde50e8d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -9743,6 +9743,7 @@ package android.service.notification {
    method public void onActionInvoked(@NonNull String, @NonNull android.app.Notification.Action, int);
    method public void onAllowedAdjustmentsChanged();
    method @NonNull public final android.os.IBinder onBind(@Nullable android.content.Intent);
    method public void onNotificationClicked(@NonNull String);
    method public void onNotificationDirectReplied(@NonNull String);
    method @Nullable public abstract android.service.notification.Adjustment onNotificationEnqueued(@NonNull android.service.notification.StatusBarNotification);
    method @Nullable public android.service.notification.Adjustment onNotificationEnqueued(@NonNull android.service.notification.StatusBarNotification, @NonNull android.app.NotificationChannel);
+1 −0
Original line number Diff line number Diff line
@@ -292,6 +292,7 @@ package android.app {
  }

  public class StatusBarManager {
    method public void clickNotification(@Nullable String, int, int, boolean);
    method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public void collapsePanels();
    method public void expandNotificationsPanel();
    method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public void setExpansionDisabledForSimNetworkLock(boolean);
+23 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.util.Slog;
import android.view.View;

import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.statusbar.NotificationVisibility;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -262,6 +263,28 @@ public class StatusBarManager {
        }
    }

    /**
     * Simulate notification click for testing
     *
     * @hide
     */
    @TestApi
    public void clickNotification(@Nullable String key, int rank, int count, boolean visible) {
        clickNotificationInternal(key, rank, count, visible);
    }

    private void clickNotificationInternal(String key, int rank, int count, boolean visible) {
        try {
            final IStatusBarService svc = getService();
            if (svc != null) {
                svc.onNotificationClick(key,
                        NotificationVisibility.obtain(key, rank, count, visible));
            }
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
    }

    /**
     * Expand the notifications panel.
     *
+1 −0
Original line number Diff line number Diff line
@@ -56,5 +56,6 @@ oneway interface INotificationListener
    void onNotificationDirectReply(String key);
    void onSuggestedReplySent(String key, in CharSequence reply, int source);
    void onActionClicked(String key, in Notification.Action action, int source);
    void onNotificationClicked(String key);
    void onAllowedAdjustmentsChanged();
}
+22 −0
Original line number Diff line number Diff line
@@ -241,6 +241,13 @@ public abstract class NotificationAssistantService extends NotificationListenerS
            @Source int source) {
    }

    /**
     * Implement this to know when a notification is clicked by user.
     * @param key the notification key
     */
    public void onNotificationClicked(@NonNull String key) {
    }

    /**
     * Implement this to know when a user has changed which features of
     * their notifications the assistant can modify.
@@ -421,6 +428,13 @@ public abstract class NotificationAssistantService extends NotificationListenerS
            mHandler.obtainMessage(MyHandler.MSG_ON_ACTION_INVOKED, args).sendToTarget();
        }

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

        @Override
        public void onAllowedAdjustmentsChanged() {
            mHandler.obtainMessage(MyHandler.MSG_ON_ALLOWED_ADJUSTMENTS_CHANGED).sendToTarget();
@@ -445,6 +459,7 @@ public abstract class NotificationAssistantService extends NotificationListenerS
        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 static final int MSG_ON_NOTIFICATION_CLICKED = 12;

        public MyHandler(Looper looper) {
            super(looper, null, false);
@@ -550,6 +565,13 @@ public abstract class NotificationAssistantService extends NotificationListenerS
                    onNotificationVisibilityChanged(key, isVisible);
                    break;
                }
                case MSG_ON_NOTIFICATION_CLICKED: {
                    SomeArgs args = (SomeArgs) msg.obj;
                    String key = (String) args.arg1;
                    args.recycle();
                    onNotificationClicked(key);
                    break;
                }
            }
        }
    }
Loading