Add flag to allow NAS to peform ranking

This will be used by implementations of NotificationAssistantService to
rerank notifications within the same importance bucket.

Bug: 146443378
Test: atest
Change-Id: I95e45081ae90f1e60de86b1b850ad18f33eb803b
This commit is contained in:
Alex Mang
2019-12-04 13:25:32 -08:00
parent 84a23d37fb
commit 8f966787d9
4 changed files with 65 additions and 1 deletions

View File

@@ -28,6 +28,7 @@ import java.util.List;
public class AssistantCapabilityPreferenceController extends TogglePreferenceController {
static final String PRIORITIZER_KEY = "asst_capability_prioritizer";
static final String RANKING_KEY = "asst_capability_ranking";
static final String SMART_KEY = "asst_capabilities_actions_replies";
private NotificationBackend mBackend;
@@ -45,7 +46,9 @@ public class AssistantCapabilityPreferenceController extends TogglePreferenceCon
public boolean isChecked() {
List<String> 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);