Merge "Don't increase notif importance when shouldSilence"
This commit is contained in:
committed by
Android (Google) Code Review
commit
d41e8b49de
@@ -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(
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user