diff --git a/res/values/strings.xml b/res/values/strings.xml
index 860b96ef5d1..daba0be1b5e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7891,6 +7891,12 @@
Automatically set lower priority notifications to Gentle
+
+ Adaptive notification ranking
+
+
+ Automatically rank notifications by relevance
+
Suggested actions and replies
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index 2607c09126a..3ddf1dbfd8a 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -536,6 +536,11 @@
android:title="@string/asst_capability_prioritizer_title"
settings:controller="com.android.settings.notification.AssistantCapabilityPreferenceController" />
+
+
capabilities = mBackend.getAssistantAdjustments(mContext.getPackageName());
if (PRIORITIZER_KEY.equals(getPreferenceKey())) {
- return capabilities.contains(Adjustment.KEY_IMPORTANCE);
+ return capabilities.contains(Adjustment.KEY_IMPORTANCE);
+ } else if (RANKING_KEY.equals(getPreferenceKey())) {
+ return capabilities.contains(Adjustment.KEY_RANKING_SCORE);
} else if (SMART_KEY.equals(getPreferenceKey())) {
return capabilities.contains(Adjustment.KEY_CONTEXTUAL_ACTIONS)
&& capabilities.contains(Adjustment.KEY_TEXT_REPLIES);
@@ -57,6 +60,8 @@ public class AssistantCapabilityPreferenceController extends TogglePreferenceCon
public boolean setChecked(boolean isChecked) {
if (PRIORITIZER_KEY.equals(getPreferenceKey())) {
mBackend.allowAssistantAdjustment(Adjustment.KEY_IMPORTANCE, isChecked);
+ } else if (RANKING_KEY.equals(getPreferenceKey())) {
+ mBackend.allowAssistantAdjustment(Adjustment.KEY_RANKING_SCORE, isChecked);
} else if (SMART_KEY.equals(getPreferenceKey())) {
mBackend.allowAssistantAdjustment(Adjustment.KEY_CONTEXTUAL_ACTIONS, isChecked);
mBackend.allowAssistantAdjustment(Adjustment.KEY_TEXT_REPLIES, isChecked);
diff --git a/tests/robotests/src/com/android/settings/notification/AssistantCapabilityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/AssistantCapabilityPreferenceControllerTest.java
index 397b72e3561..5244c7e8ceb 100644
--- a/tests/robotests/src/com/android/settings/notification/AssistantCapabilityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/AssistantCapabilityPreferenceControllerTest.java
@@ -19,6 +19,7 @@ package com.android.settings.notification;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
import static com.android.settings.core.BasePreferenceController.DISABLED_DEPENDENT_SETTING;
import static com.android.settings.notification.AssistantCapabilityPreferenceController.PRIORITIZER_KEY;
+import static com.android.settings.notification.AssistantCapabilityPreferenceController.RANKING_KEY;
import static com.android.settings.notification.AssistantCapabilityPreferenceController.SMART_KEY;
import static com.google.common.truth.Truth.assertThat;
@@ -56,8 +57,10 @@ public class AssistantCapabilityPreferenceControllerTest {
private Context mContext;
private AssistantCapabilityPreferenceController mPrioritizerController;
+ private AssistantCapabilityPreferenceController mRankingController;
private AssistantCapabilityPreferenceController mChipController;
private Preference mPrioritizerPreference;
+ private Preference mRankingPreference;
private Preference mChipPreference;
@Before
@@ -71,6 +74,13 @@ public class AssistantCapabilityPreferenceControllerTest {
mPrioritizerPreference.setKey(mPrioritizerController.getPreferenceKey());
when(mScreen.findPreference(
mPrioritizerController.getPreferenceKey())).thenReturn(mPrioritizerPreference);
+ mRankingController = new AssistantCapabilityPreferenceController(
+ mContext, RANKING_KEY);
+ mRankingController.setBackend(mBackend);
+ mRankingPreference = new Preference(mContext);
+ mRankingPreference.setKey(mRankingController.getPreferenceKey());
+ when(mScreen.findPreference(
+ mRankingController.getPreferenceKey())).thenReturn(mRankingPreference);
mChipController = new AssistantCapabilityPreferenceController(mContext, SMART_KEY);
mChipController.setBackend(mBackend);
mChipPreference = new Preference(mContext);
@@ -111,6 +121,27 @@ public class AssistantCapabilityPreferenceControllerTest {
capabilities.add(Adjustment.KEY_IMPORTANCE);
when(mBackend.getAssistantAdjustments(anyString())).thenReturn(capabilities);
assertThat(mPrioritizerController.isChecked()).isTrue();
+
+ capabilities = new ArrayList<>();
+ capabilities.add(Adjustment.KEY_RANKING_SCORE);
+ when(mBackend.getAssistantAdjustments(anyString())).thenReturn(capabilities);
+ assertThat(mPrioritizerController.isChecked()).isFalse();
+ }
+
+ @Test
+ public void isChecked_rankingSettingIsOff_false() {
+ List capabilities = new ArrayList<>();
+ capabilities.add(Adjustment.KEY_IMPORTANCE);
+ when(mBackend.getAssistantAdjustments(anyString())).thenReturn(capabilities);
+ assertThat(mRankingController.isChecked()).isFalse();
+ }
+
+ @Test
+ public void isChecked_rankingSettingIsOn_true() {
+ List capabilities = new ArrayList<>();
+ capabilities.add(Adjustment.KEY_RANKING_SCORE);
+ when(mBackend.getAssistantAdjustments(anyString())).thenReturn(capabilities);
+ assertThat(mRankingController.isChecked()).isTrue();
}
@Test
@@ -120,6 +151,11 @@ public class AssistantCapabilityPreferenceControllerTest {
when(mBackend.getAssistantAdjustments(anyString())).thenReturn(capabilities);
assertThat(mChipController.isChecked()).isFalse();
+ capabilities = new ArrayList<>();
+ capabilities.add(Adjustment.KEY_RANKING_SCORE);
+ when(mBackend.getAssistantAdjustments(anyString())).thenReturn(capabilities);
+ assertThat(mChipController.isChecked()).isFalse();
+
capabilities = new ArrayList<>();
capabilities.add(Adjustment.KEY_CONTEXTUAL_ACTIONS);
when(mBackend.getAssistantAdjustments(anyString())).thenReturn(capabilities);
@@ -152,6 +188,18 @@ public class AssistantCapabilityPreferenceControllerTest {
verify(mBackend).allowAssistantAdjustment(Adjustment.KEY_IMPORTANCE, false);
}
+ @Test
+ public void onPreferenceChange_rankingOn() {
+ mRankingController.onPreferenceChange(mRankingPreference, true);
+ verify(mBackend).allowAssistantAdjustment(Adjustment.KEY_RANKING_SCORE, true);
+ }
+
+ @Test
+ public void onPreferenceChange_rankingOff() {
+ mRankingController.onPreferenceChange(mRankingPreference, false);
+ verify(mBackend).allowAssistantAdjustment(Adjustment.KEY_RANKING_SCORE, false);
+ }
+
@Test
public void onPreferenceChange_chipsOn() {
mChipController.onPreferenceChange(mChipPreference, true);