Changes for renamed API
Test: atest Bug: 130224929 Change-Id: Ia5003a31153da74347a3251a71dfcd423e65a462
This commit is contained in:
@@ -17,7 +17,6 @@
|
|||||||
package com.android.settings.notification;
|
package com.android.settings.notification;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.UserHandle;
|
|
||||||
import android.service.notification.Adjustment;
|
import android.service.notification.Adjustment;
|
||||||
|
|
||||||
import com.android.settings.core.TogglePreferenceController;
|
import com.android.settings.core.TogglePreferenceController;
|
||||||
@@ -44,7 +43,7 @@ public class AssistantCapabilityPreferenceController extends TogglePreferenceCon
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChecked() {
|
public boolean isChecked() {
|
||||||
List<String> capabilities = mBackend.getAssistantCapabilities(mContext.getPackageName());
|
List<String> capabilities = mBackend.getAssistantAdjustments(mContext.getPackageName());
|
||||||
if (PRIORITIZER_KEY.equals(getPreferenceKey())) {
|
if (PRIORITIZER_KEY.equals(getPreferenceKey())) {
|
||||||
return capabilities.contains(Adjustment.KEY_IMPORTANCE);
|
return capabilities.contains(Adjustment.KEY_IMPORTANCE);
|
||||||
} else if (SMART_KEY.equals(getPreferenceKey())) {
|
} else if (SMART_KEY.equals(getPreferenceKey())) {
|
||||||
@@ -57,10 +56,10 @@ public class AssistantCapabilityPreferenceController extends TogglePreferenceCon
|
|||||||
@Override
|
@Override
|
||||||
public boolean setChecked(boolean isChecked) {
|
public boolean setChecked(boolean isChecked) {
|
||||||
if (PRIORITIZER_KEY.equals(getPreferenceKey())) {
|
if (PRIORITIZER_KEY.equals(getPreferenceKey())) {
|
||||||
mBackend.allowAssistantCapability(Adjustment.KEY_IMPORTANCE, isChecked);
|
mBackend.allowAssistantAdjustment(Adjustment.KEY_IMPORTANCE, isChecked);
|
||||||
} else if (SMART_KEY.equals(getPreferenceKey())) {
|
} else if (SMART_KEY.equals(getPreferenceKey())) {
|
||||||
mBackend.allowAssistantCapability(Adjustment.KEY_CONTEXTUAL_ACTIONS, isChecked);
|
mBackend.allowAssistantAdjustment(Adjustment.KEY_CONTEXTUAL_ACTIONS, isChecked);
|
||||||
mBackend.allowAssistantCapability(Adjustment.KEY_TEXT_REPLIES, isChecked);
|
mBackend.allowAssistantAdjustment(Adjustment.KEY_TEXT_REPLIES, isChecked);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -339,21 +339,21 @@ public class NotificationBackend {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void allowAssistantCapability(String capability, boolean allowed) {
|
public void allowAssistantAdjustment(String capability, boolean allowed) {
|
||||||
try {
|
try {
|
||||||
if (allowed) {
|
if (allowed) {
|
||||||
sINM.allowAssistantCapability(capability);
|
sINM.allowAssistantAdjustment(capability);
|
||||||
} else {
|
} else {
|
||||||
sINM.disallowAssistantCapability(capability);
|
sINM.disallowAssistantAdjustment(capability);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.w(TAG, "Error calling NoMan", e);
|
Log.w(TAG, "Error calling NoMan", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getAssistantCapabilities(String pkg) {
|
public List<String> getAssistantAdjustments(String pkg) {
|
||||||
try {
|
try {
|
||||||
return sINM.getAllowedAssistantCapabilities(pkg);
|
return sINM.getAllowedAssistantAdjustments(pkg);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.w(TAG, "Error calling NoMan", e);
|
Log.w(TAG, "Error calling NoMan", e);
|
||||||
}
|
}
|
||||||
|
@@ -101,7 +101,7 @@ public class AssistantCapabilityPreferenceControllerTest {
|
|||||||
public void isChecked_prioritizerSettingIsOff_false() {
|
public void isChecked_prioritizerSettingIsOff_false() {
|
||||||
List<String> capabilities = new ArrayList<>();
|
List<String> capabilities = new ArrayList<>();
|
||||||
capabilities.add(Adjustment.KEY_USER_SENTIMENT);
|
capabilities.add(Adjustment.KEY_USER_SENTIMENT);
|
||||||
when(mBackend.getAssistantCapabilities(anyString())).thenReturn(capabilities);
|
when(mBackend.getAssistantAdjustments(anyString())).thenReturn(capabilities);
|
||||||
assertThat(mPrioritizerController.isChecked()).isFalse();
|
assertThat(mPrioritizerController.isChecked()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ public class AssistantCapabilityPreferenceControllerTest {
|
|||||||
public void isChecked_prioritizerSettingIsOn_true() {
|
public void isChecked_prioritizerSettingIsOn_true() {
|
||||||
List<String> capabilities = new ArrayList<>();
|
List<String> capabilities = new ArrayList<>();
|
||||||
capabilities.add(Adjustment.KEY_IMPORTANCE);
|
capabilities.add(Adjustment.KEY_IMPORTANCE);
|
||||||
when(mBackend.getAssistantCapabilities(anyString())).thenReturn(capabilities);
|
when(mBackend.getAssistantAdjustments(anyString())).thenReturn(capabilities);
|
||||||
assertThat(mPrioritizerController.isChecked()).isTrue();
|
assertThat(mPrioritizerController.isChecked()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,17 +117,17 @@ public class AssistantCapabilityPreferenceControllerTest {
|
|||||||
public void isChecked_chipSettingIsOff_false() {
|
public void isChecked_chipSettingIsOff_false() {
|
||||||
List<String> capabilities = new ArrayList<>();
|
List<String> capabilities = new ArrayList<>();
|
||||||
capabilities.add(Adjustment.KEY_IMPORTANCE);
|
capabilities.add(Adjustment.KEY_IMPORTANCE);
|
||||||
when(mBackend.getAssistantCapabilities(anyString())).thenReturn(capabilities);
|
when(mBackend.getAssistantAdjustments(anyString())).thenReturn(capabilities);
|
||||||
assertThat(mChipController.isChecked()).isFalse();
|
assertThat(mChipController.isChecked()).isFalse();
|
||||||
|
|
||||||
capabilities = new ArrayList<>();
|
capabilities = new ArrayList<>();
|
||||||
capabilities.add(Adjustment.KEY_CONTEXTUAL_ACTIONS);
|
capabilities.add(Adjustment.KEY_CONTEXTUAL_ACTIONS);
|
||||||
when(mBackend.getAssistantCapabilities(anyString())).thenReturn(capabilities);
|
when(mBackend.getAssistantAdjustments(anyString())).thenReturn(capabilities);
|
||||||
assertThat(mChipController.isChecked()).isFalse();
|
assertThat(mChipController.isChecked()).isFalse();
|
||||||
|
|
||||||
capabilities = new ArrayList<>();
|
capabilities = new ArrayList<>();
|
||||||
capabilities.add(Adjustment.KEY_TEXT_REPLIES);
|
capabilities.add(Adjustment.KEY_TEXT_REPLIES);
|
||||||
when(mBackend.getAssistantCapabilities(anyString())).thenReturn(capabilities);
|
when(mBackend.getAssistantAdjustments(anyString())).thenReturn(capabilities);
|
||||||
assertThat(mChipController.isChecked()).isFalse();
|
assertThat(mChipController.isChecked()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,34 +136,34 @@ public class AssistantCapabilityPreferenceControllerTest {
|
|||||||
List<String> capabilities = new ArrayList<>();
|
List<String> capabilities = new ArrayList<>();
|
||||||
capabilities.add(Adjustment.KEY_TEXT_REPLIES);
|
capabilities.add(Adjustment.KEY_TEXT_REPLIES);
|
||||||
capabilities.add(Adjustment.KEY_CONTEXTUAL_ACTIONS);
|
capabilities.add(Adjustment.KEY_CONTEXTUAL_ACTIONS);
|
||||||
when(mBackend.getAssistantCapabilities(anyString())).thenReturn(capabilities);
|
when(mBackend.getAssistantAdjustments(anyString())).thenReturn(capabilities);
|
||||||
assertThat(mChipController.isChecked()).isTrue();
|
assertThat(mChipController.isChecked()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onPreferenceChange_prioritizerOn() {
|
public void onPreferenceChange_prioritizerOn() {
|
||||||
mPrioritizerController.onPreferenceChange(mPrioritizerPreference, true);
|
mPrioritizerController.onPreferenceChange(mPrioritizerPreference, true);
|
||||||
verify(mBackend).allowAssistantCapability(Adjustment.KEY_IMPORTANCE, true);
|
verify(mBackend).allowAssistantAdjustment(Adjustment.KEY_IMPORTANCE, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onPreferenceChange_prioritizerOff() {
|
public void onPreferenceChange_prioritizerOff() {
|
||||||
mPrioritizerController.onPreferenceChange(mPrioritizerPreference, false);
|
mPrioritizerController.onPreferenceChange(mPrioritizerPreference, false);
|
||||||
verify(mBackend).allowAssistantCapability(Adjustment.KEY_IMPORTANCE, false);
|
verify(mBackend).allowAssistantAdjustment(Adjustment.KEY_IMPORTANCE, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onPreferenceChange_chipsOn() {
|
public void onPreferenceChange_chipsOn() {
|
||||||
mChipController.onPreferenceChange(mChipPreference, true);
|
mChipController.onPreferenceChange(mChipPreference, true);
|
||||||
verify(mBackend).allowAssistantCapability(Adjustment.KEY_CONTEXTUAL_ACTIONS, true);
|
verify(mBackend).allowAssistantAdjustment(Adjustment.KEY_CONTEXTUAL_ACTIONS, true);
|
||||||
verify(mBackend).allowAssistantCapability(Adjustment.KEY_TEXT_REPLIES, true);
|
verify(mBackend).allowAssistantAdjustment(Adjustment.KEY_TEXT_REPLIES, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onPreferenceChange_chipsOff() {
|
public void onPreferenceChange_chipsOff() {
|
||||||
mChipController.onPreferenceChange(mChipPreference, false);
|
mChipController.onPreferenceChange(mChipPreference, false);
|
||||||
verify(mBackend).allowAssistantCapability(Adjustment.KEY_CONTEXTUAL_ACTIONS, false);
|
verify(mBackend).allowAssistantAdjustment(Adjustment.KEY_CONTEXTUAL_ACTIONS, false);
|
||||||
verify(mBackend).allowAssistantCapability(Adjustment.KEY_TEXT_REPLIES, false);
|
verify(mBackend).allowAssistantAdjustment(Adjustment.KEY_TEXT_REPLIES, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user