Merge "Add NAS#onNotificationClicked API and TestAPI for cts test"
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1486,6 +1486,11 @@ public abstract class NotificationListenerService extends Service {
|
||||
// no-op in the listener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotificationClicked(String key) {
|
||||
// no-op in the listener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAllowedAdjustmentsChanged() {
|
||||
// no-op in the listener
|
||||
|
||||
@@ -998,6 +998,7 @@ public class NotificationManagerService extends SystemService {
|
||||
REASON_CLICK, nv.rank, nv.count, null);
|
||||
nv.recycle();
|
||||
reportUserInteraction(r);
|
||||
mAssistants.notifyAssistantNotificationClicked(r);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9474,6 +9475,22 @@ public class NotificationManagerService extends SystemService {
|
||||
});
|
||||
}
|
||||
|
||||
@GuardedBy("mNotificationLock")
|
||||
void notifyAssistantNotificationClicked(final NotificationRecord r) {
|
||||
final String key = r.getSbn().getKey();
|
||||
notifyAssistantLocked(
|
||||
r.getSbn(),
|
||||
r.getNotificationType(),
|
||||
true /* sameUserOnly */,
|
||||
(assistant, sbnHolder) -> {
|
||||
try {
|
||||
assistant.onNotificationClicked(key);
|
||||
} catch (RemoteException ex) {
|
||||
Slog.e(TAG, "unable to notify assistant (clicked): " + assistant, ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies the assistant something about the specified notification, only assistant
|
||||
* that is visible to the notification will be notified.
|
||||
|
||||
Reference in New Issue
Block a user