Add configuration for defaulting notification behavior

Test: RedactionInterstitialTest
Test: go through SUW on a phone
Bug: 240472040
Change-Id: I7bcd9f1a128c757881693e0251d305d2e26e4fd8
This commit is contained in:
Steve Elliott
2022-11-11 14:08:09 -05:00
parent af96b1ea7a
commit a92688d642
3 changed files with 36 additions and 1 deletions

View File

@@ -21,6 +21,7 @@ import android.widget.RadioButton;
import com.android.settings.R;
import com.android.settings.RestrictedRadioButton;
import com.android.settings.notification.RedactionInterstitial.RedactionInterstitialFragment;
import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settings.testutils.shadow.ShadowRestrictedLockUtilsInternal;
import com.android.settings.testutils.shadow.ShadowUtils;
@@ -38,6 +39,7 @@ import org.robolectric.shadows.ShadowUserManager;
@Config(shadows = {
ShadowUtils.class,
ShadowRestrictedLockUtilsInternal.class,
SettingsShadowResources.class,
})
public class RedactionInterstitialTest {
private RedactionInterstitial mActivity;
@@ -134,6 +136,28 @@ public class RedactionInterstitialTest {
assertSelectedButton(R.id.redact_sensitive);
}
@Test
public void defaultShowSensitiveContent_configDeny() {
final ContentResolver resolver = RuntimeEnvironment.application.getContentResolver();
Settings.Secure.putIntForUser(resolver,
LOCK_SCREEN_SHOW_NOTIFICATIONS, 1, UserHandle.myUserId());
setupConfig(false);
setupActivity();
assertSelectedButton(R.id.redact_sensitive);
}
@Test
public void defaultShowSensitiveContent_configAllow() {
final ContentResolver resolver = RuntimeEnvironment.application.getContentResolver();
Settings.Secure.putIntForUser(resolver,
LOCK_SCREEN_SHOW_NOTIFICATIONS, 1, UserHandle.myUserId());
setupConfig(true);
setupActivity();
assertSelectedButton(R.id.show_all);
}
private void setupActivity() {
mActivity = buildActivity(RedactionInterstitial.class, new Intent()).setup().get();
mFragment = (RedactionInterstitialFragment)
@@ -142,6 +166,11 @@ public class RedactionInterstitialTest {
assertThat(mFragment).isNotNull();
}
private void setupConfig(boolean allowSensitiveContent) {
SettingsShadowResources.overrideResource(
R.bool.default_allow_sensitive_lockscreen_content, allowSensitiveContent);
}
private void setupSettings(int show, int showUnredacted) {
final ContentResolver resolver = RuntimeEnvironment.application.getContentResolver();
Settings.Secure.putIntForUser(resolver,