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

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

Merge "Don't increase notif importance when shouldSilence"

parents d5705da0 067a739a
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import static android.service.notification.NotificationListenerService.Ranking
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityThread;
import android.app.AlarmManager;
import android.app.INotificationManager;
import android.app.Notification;
import android.app.NotificationChannel;
@@ -224,8 +223,9 @@ public class Assistant extends NotificationAssistantService {
    }

    /** A convenience helper for creating an adjustment for an SBN. */
    @VisibleForTesting
    @Nullable
    private Adjustment createEnqueuedNotificationAdjustment(
    Adjustment createEnqueuedNotificationAdjustment(
            @NonNull NotificationEntry entry,
            @NonNull ArrayList<Notification.Action> smartActions,
            @NonNull ArrayList<CharSequence> smartReplies) {
@@ -237,7 +237,9 @@ public class Assistant extends NotificationAssistantService {
            signals.putCharSequenceArrayList(Adjustment.KEY_SMART_REPLIES, smartReplies);
        }
        if (mNotificationCategorizer.shouldSilence(entry)) {
            signals.putInt(KEY_IMPORTANCE, IMPORTANCE_LOW);
            final int importance = entry.getImportance() < IMPORTANCE_LOW ? entry.getImportance()
                    : IMPORTANCE_LOW;
            signals.putInt(KEY_IMPORTANCE, importance);
        }

        return new Adjustment(
+9 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.util.ArrayList;

public class AssistantTest extends ServiceTestCase<Assistant> {

@@ -466,4 +467,12 @@ public class AssistantTest extends ServiceTestCase<Assistant> {

        assertFalse(mAssistant.mLiveNotifications.containsKey(sbn.getKey()));
    }

    @Test
    public void testAssistantNeverIncreasesImportanceWhenSuggestingSilent() throws Exception {
        StatusBarNotification sbn = generateSbn(PKG1, UID1, P1C3, "min notif!", null);
        Adjustment adjust = mAssistant.createEnqueuedNotificationAdjustment(new NotificationEntry(
                mPackageManager, sbn, P1C3), new ArrayList<>(), new ArrayList<>());
        assertEquals(IMPORTANCE_MIN, adjust.getSignals().getInt(Adjustment.KEY_IMPORTANCE));
    }
}