diff options
7 files changed, 59 insertions, 32 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ActionClickLogger.kt b/packages/SystemUI/src/com/android/systemui/statusbar/ActionClickLogger.kt index d3c19b75a71d..5042f1b279e2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ActionClickLogger.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ActionClickLogger.kt @@ -31,56 +31,68 @@ class ActionClickLogger @Inject constructor(  ) {      fun logInitialClick(          entry: NotificationEntry?, +        index: Integer?,          pendingIntent: PendingIntent      ) {          buffer.log(TAG, LogLevel.DEBUG, {              str1 = entry?.key              str2 = entry?.ranking?.channel?.id -            str3 = pendingIntent.intent.toString() +            str3 = pendingIntent.toString() +            int1 = index?.toInt() ?: Int.MIN_VALUE          }, { -            "ACTION CLICK $str1 (channel=$str2) for pending intent $str3" +            "ACTION CLICK $str1 (channel=$str2) for pending intent $str3 at index $int1"          })      }      fun logRemoteInputWasHandled( -        entry: NotificationEntry? +        entry: NotificationEntry?, +        index: Int?      ) {          buffer.log(TAG, LogLevel.DEBUG, {              str1 = entry?.key +            int1 = index ?: Int.MIN_VALUE          }, { -            "  [Action click] Triggered remote input (for $str1))" +            "  [Action click] Triggered remote input (for $str1) at index $int1"          })      }      fun logStartingIntentWithDefaultHandler(          entry: NotificationEntry?, -        pendingIntent: PendingIntent +        pendingIntent: PendingIntent, +        index: Int?      ) {          buffer.log(TAG, LogLevel.DEBUG, {              str1 = entry?.key -            str2 = pendingIntent.intent.toString() +            str2 = pendingIntent.toString() +            int1 = index ?: Int.MIN_VALUE          }, { -            "  [Action click] Launching intent $str2 via default handler (for $str1)" +            "  [Action click] Launching intent $str2 via default handler (for $str1 at index $int1)"          })      }      fun logWaitingToCloseKeyguard( -        pendingIntent: PendingIntent +        pendingIntent: PendingIntent, +        index: Int?      ) {          buffer.log(TAG, LogLevel.DEBUG, { -            str1 = pendingIntent.intent.toString() +            str1 = pendingIntent.toString() +            int1 = index ?: Int.MIN_VALUE          }, { -            "  [Action click] Intent $str1 launches an activity, dismissing keyguard first..." +            "  [Action click] Intent $str1 at index $int1 launches an activity, dismissing " + +                    "keyguard first..."          })      }      fun logKeyguardGone( -        pendingIntent: PendingIntent +        pendingIntent: PendingIntent, +        index: Int?      ) {          buffer.log(TAG, LogLevel.DEBUG, { -            str1 = pendingIntent.intent.toString() +            str1 = pendingIntent.toString() +            int1 = index ?: Int.MIN_VALUE          }, { -            "  [Action click] Keyguard dismissed, calling default handler for intent $str1" +            "  [Action click] Keyguard dismissed, calling default handler for intent $str1 at " + +                    "index $int1"          })      }  } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationClickNotifier.kt b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationClickNotifier.kt index abf81c5c4cb6..692a9977c364 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationClickNotifier.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationClickNotifier.kt @@ -2,10 +2,12 @@ package com.android.systemui.statusbar  import android.app.Notification  import android.os.RemoteException +import android.util.Log  import com.android.internal.statusbar.IStatusBarService  import com.android.internal.statusbar.NotificationVisibility  import com.android.systemui.dagger.SysUISingleton  import com.android.systemui.dagger.qualifiers.Main +import com.android.systemui.dagger.qualifiers.UiBackground  import com.android.systemui.util.Assert  import java.util.concurrent.Executor  import javax.inject.Inject @@ -21,7 +23,8 @@ import javax.inject.Inject  @SysUISingleton  public class NotificationClickNotifier @Inject constructor(      val barService: IStatusBarService, -    @Main val mainExecutor: Executor +    @Main val mainExecutor: Executor, +    @UiBackground val backgroundExecutor: Executor  ) {      val listeners = mutableListOf<NotificationInteractionListener>() @@ -48,13 +51,14 @@ public class NotificationClickNotifier @Inject constructor(          visibility: NotificationVisibility,          generatedByAssistant: Boolean      ) { -        try { -            barService.onNotificationActionClick( -                    key, actionIndex, action, visibility, generatedByAssistant) -        } catch (e: RemoteException) { -            // nothing +        backgroundExecutor.execute { +            try { +                barService.onNotificationActionClick( +                        key, actionIndex, action, visibility, generatedByAssistant) +            } catch (e: RemoteException) { +                // nothing +            }          } -          mainExecutor.execute {              notifyListenersAboutInteraction(key)          } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java index da84afef42c5..8089fd94f7db 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java @@ -119,11 +119,14 @@ public class NotificationRemoteInputManager implements Dumpable {              mPowerInteractor.wakeUpIfDozing(                      "NOTIFICATION_CLICK", PowerManager.WAKE_REASON_GESTURE); +            Integer actionIndex = (Integer) +                    view.getTag(com.android.internal.R.id.notification_action_index_tag); +              final NotificationEntry entry = getNotificationForParent(view.getParent()); -            mLogger.logInitialClick(entry, pendingIntent); +            mLogger.logInitialClick(entry, actionIndex, pendingIntent);              if (handleRemoteInput(view, pendingIntent)) { -                mLogger.logRemoteInputWasHandled(entry); +                mLogger.logRemoteInputWasHandled(entry, actionIndex);                  return true;              } @@ -141,9 +144,9 @@ public class NotificationRemoteInputManager implements Dumpable {              }              Notification.Action action = getActionFromView(view, entry, pendingIntent);              return mCallback.handleRemoteViewClick(view, pendingIntent, -                    action == null ? false : action.isAuthenticationRequired(), () -> { +                    action == null ? false : action.isAuthenticationRequired(), actionIndex, () -> {                      Pair<Intent, ActivityOptions> options = response.getLaunchOptions(view); -                    mLogger.logStartingIntentWithDefaultHandler(entry, pendingIntent); +                    mLogger.logStartingIntentWithDefaultHandler(entry, pendingIntent, actionIndex);                      boolean started = RemoteViews.startPendingIntent(view, pendingIntent, options);                      if (started) releaseNotificationIfKeptForRemoteInputHistory(entry);                      return started; @@ -692,11 +695,13 @@ public class NotificationRemoteInputManager implements Dumpable {           * @param view           * @param pendingIntent           * @param appRequestedAuth +         * @param actionIndex           * @param defaultHandler           * @return  true iff the click was handled           */          boolean handleRemoteViewClick(View view, PendingIntent pendingIntent, -                boolean appRequestedAuth, ClickHandler defaultHandler); +                boolean appRequestedAuth, @Nullable Integer actionIndex, +                ClickHandler defaultHandler);      }      /** diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarRemoteInputCallback.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarRemoteInputCallback.java index 7fe01825890f..a6284e3f62ab 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarRemoteInputCallback.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarRemoteInputCallback.java @@ -32,6 +32,8 @@ import android.os.UserHandle;  import android.view.View;  import android.view.ViewParent; +import androidx.annotation.Nullable; +  import com.android.systemui.ActivityIntentHelper;  import com.android.systemui.dagger.SysUISingleton;  import com.android.systemui.dagger.qualifiers.Main; @@ -254,16 +256,16 @@ public class StatusBarRemoteInputCallback implements Callback, Callbacks,      @Override      public boolean handleRemoteViewClick(View view, PendingIntent pendingIntent, -            boolean appRequestedAuth, +            boolean appRequestedAuth, @Nullable Integer actionIndex,              NotificationRemoteInputManager.ClickHandler defaultHandler) {          final boolean isActivity = pendingIntent.isActivity();          if (isActivity || appRequestedAuth) { -            mActionClickLogger.logWaitingToCloseKeyguard(pendingIntent); +            mActionClickLogger.logWaitingToCloseKeyguard(pendingIntent, actionIndex);              final boolean afterKeyguardGone = mActivityIntentHelper                      .wouldPendingLaunchResolverActivity(pendingIntent,                              mLockscreenUserManager.getCurrentUserId());              mActivityStarter.dismissKeyguardThenExecute(() -> { -                mActionClickLogger.logKeyguardGone(pendingIntent); +                mActionClickLogger.logKeyguardGone(pendingIntent, actionIndex);                  try {                      ActivityManager.getService().resumeAppSwitches(); diff --git a/services/core/java/com/android/server/EventLogTags.logtags b/services/core/java/com/android/server/EventLogTags.logtags index b67e62703067..d47a3991a966 100644 --- a/services/core/java/com/android/server/EventLogTags.logtags +++ b/services/core/java/com/android/server/EventLogTags.logtags @@ -81,7 +81,7 @@ option java_package com.android.server  # when a notification has been clicked  27520 notification_clicked (key|3),(lifespan|1),(freshness|1),(exposure|1),(rank|1),(count|1)  # when a notification action button has been clicked -27521 notification_action_clicked (key|3),(action_index|1),(lifespan|1),(freshness|1),(exposure|1),(rank|1),(count|1) +27521 notification_action_clicked (key|3),(piIdentifier|3),(pendingIntent|3),(action_index|1),(lifespan|1),(freshness|1),(exposure|1),(rank|1),(count|1)  # when a notification has been canceled  27530 notification_canceled (key|3),(reason|1),(lifespan|1),(freshness|1),(exposure|1),(rank|1),(count|1),(listener|3)  # replaces 27510 with a row per notification diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index e782ea937c50..009cc3b57594 100755 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -1239,7 +1239,9 @@ public class NotificationManagerService extends SystemService {                  mNotificationRecordLogger.log(                          NotificationRecordLogger.NotificationEvent.fromAction(actionIndex,                                  generatedByAssistant, action.isContextual()), r); -                EventLogTags.writeNotificationActionClicked(key, actionIndex, +                EventLogTags.writeNotificationActionClicked(key, +                        action.actionIntent.getTarget().toString(), +                        action.actionIntent.getIntent().toString(), actionIndex,                          r.getLifespanMs(now), r.getFreshnessMs(now), r.getExposureMs(now),                          nv.rank, nv.count);                  nv.recycle(); diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java index e1f3c2b9e62c..57aa0b96a56a 100755 --- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java @@ -7753,7 +7753,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {      public void testOnNotificationActionClick() {          final int actionIndex = 2;          final Notification.Action action = -                new Notification.Action.Builder(null, "text", null).build(); +                new Notification.Action.Builder(null, "text", PendingIntent.getActivity( +                        mContext, 0, new Intent(), PendingIntent.FLAG_IMMUTABLE)).build();          final boolean generatedByAssistant = false;          NotificationRecord r = generateNotificationRecord(mTestNotificationChannel); @@ -7777,7 +7778,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {      public void testOnAssistantNotificationActionClick() {          final int actionIndex = 1;          final Notification.Action action = -                new Notification.Action.Builder(null, "text", null).build(); +                new Notification.Action.Builder(null, "text", PendingIntent.getActivity( +                        mContext, 0, new Intent(), PendingIntent.FLAG_IMMUTABLE)).build();          final boolean generatedByAssistant = true;          NotificationRecord r = generateNotificationRecord(mTestNotificationChannel);  |