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

Commit 2d66b51a authored by Gustav Sennton's avatar Gustav Sennton
Browse files

Add logcat logging for smart suggestions.

In cases where smart suggestions in notifications are not shown we want
to be able to debug why the suggestions are not shown.
With this CL we add logcat logs (conditional on log tags) to be able to
debug suggestions when we have physical access to a device.

Bug: 122895786
Test: 'adb shell setprop log.tag.ExtAssistant',
'adb shell setprop log.tag.NotificationContentView' and ensure the logs
are displayed when showing a notification.

Change-Id: I77a3fbc2b1b325d97d8e2306ffbcce17c84129f8
parent 81973983
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -216,6 +216,10 @@ public class Assistant extends NotificationAssistantService {
        }
        NotificationEntry entry = new NotificationEntry(mPackageManager, sbn, channel);
        SmartActionsHelper.SmartSuggestions suggestions = mSmartActionsHelper.suggest(entry);
        if (DEBUG) {
            Log.d(TAG, String.format("Creating Adjustment for %s, with %d actions, and %d replies.",
                    sbn.getKey(), suggestions.actions.size(), suggestions.replies.size()));
        }
        return createEnqueuedNotificationAdjustment(
                entry, suggestions.actions, suggestions.replies);
    }
+13 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ import java.util.List;
public class NotificationContentView extends FrameLayout {

    private static final String TAG = "NotificationContentView";
    private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
    public static final int VISIBLE_TYPE_CONTRACTED = 0;
    public static final int VISIBLE_TYPE_EXPANDED = 1;
    public static final int VISIBLE_TYPE_HEADSUP = 2;
@@ -1319,6 +1320,14 @@ public class NotificationContentView extends FrameLayout {

        SmartRepliesAndActions smartRepliesAndActions =
                chooseSmartRepliesAndActions(mSmartReplyConstants, entry);
        if (DEBUG) {
            Log.d(TAG, String.format("Adding suggestions for %s, %d actions, and %d replies.",
                    entry.notification.getKey(),
                    smartRepliesAndActions.smartActions == null ? 0 :
                            smartRepliesAndActions.smartActions.actions.size(),
                    smartRepliesAndActions.smartReplies == null ? 0 :
                            smartRepliesAndActions.smartReplies.choices.length));
        }

        applyRemoteInput(entry, smartRepliesAndActions.hasFreeformRemoteInput);
        applySmartReplyView(smartRepliesAndActions, entry);
@@ -1341,6 +1350,10 @@ public class NotificationContentView extends FrameLayout {
                notification.findRemoteInputActionPair(true /* freeform */);

        if (!smartReplyConstants.isEnabled()) {
            if (DEBUG) {
                Log.d(TAG, "Smart suggestions not enabled, not adding suggestions for "
                        + entry.notification.getKey());
            }
            return new SmartRepliesAndActions(null, null, freeformRemoteInputActionPair != null);
        }
        // Only use smart replies from the app if they target P or above. We have this check because