Loading packages/ExtServices/src/android/ext/services/notification/Assistant.java +5 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) { Loading @@ -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( Loading packages/ExtServices/tests/src/android/ext/services/notification/AssistantTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -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> { Loading Loading @@ -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)); } } Loading
packages/ExtServices/src/android/ext/services/notification/Assistant.java +5 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) { Loading @@ -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( Loading
packages/ExtServices/tests/src/android/ext/services/notification/AssistantTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -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> { Loading Loading @@ -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)); } }