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

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

Merge changes I7021de43,I2854764d

* changes:
  Ignore notification from other users
  Fix smart action is not enabled in first whatsapp notification
parents 5c20c8dd c68b280d
Loading
Loading
Loading
Loading
+26 −1
Original line number Diff line number Diff line
@@ -19,9 +19,11 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.Notification;
import android.app.RemoteAction;
import android.app.RemoteInput;
import android.content.Context;
import android.os.Bundle;
import android.os.Parcelable;
import android.os.Process;
import android.service.notification.StatusBarNotification;
import android.text.TextUtils;
import android.util.ArrayMap;
@@ -87,6 +89,9 @@ public class SmartActionsHelper {
    private boolean isEligibleForActionAdjustment(@NonNull StatusBarNotification sbn) {
        Notification notification = sbn.getNotification();
        String pkg = sbn.getPackageName();
        if (!Process.myUserHandle().equals(sbn.getUser())) {
            return false;
        }
        if (notification.actions != null
                && notification.actions.length >= Notification.MAX_ACTION_BUTTONS) {
            return false;
@@ -99,7 +104,27 @@ public class SmartActionsHelper {
        }
        // For now, we are only interested in messages.
        return Notification.CATEGORY_MESSAGE.equals(notification.category)
                || Notification.MessagingStyle.class.equals(notification.getNotificationStyle());
                || Notification.MessagingStyle.class.equals(notification.getNotificationStyle())
                || hasInlineReply(notification);
    }

    private boolean hasInlineReply(Notification notification) {
        Notification.Action[] actions = notification.actions;
        if (actions == null) {
            return false;
        }
        for (Notification.Action action : actions) {
            RemoteInput[] remoteInputs = action.getRemoteInputs();
            if (remoteInputs == null) {
                continue;
            }
            for (RemoteInput remoteInput : remoteInputs) {
                if (remoteInput.getAllowFreeFormInput()) {
                    return true;
                }
            }
        }
        return false;
    }

    /** Returns the text most salient for action extraction in a notification. */