Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 81fc1b0b authored by Steve Elliott's avatar Steve Elliott Committed by Automerger Merge Worker
Browse files

Merge "Revert^2 "Add configuration for defaulting notification behavior"" into...

Merge "Revert^2 "Add configuration for defaulting notification behavior"" into tm-qpr-dev am: fece9486

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/20530303



Change-Id: I9cd33ea6d02cf1243034a399162dfffcd0fd8f65
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents a538195c fece9486
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -637,6 +637,9 @@
        <item>android.uid.system:1000</item>
        <item>android.uid.system:1000</item>
    </string-array>
    </string-array>


    <!-- The default value for RedactionInterstitial in SUW -->
    <bool name="default_allow_sensitive_lockscreen_content">true</bool>

    <!-- Whether to enable the app battery usage list page feature. -->
    <!-- Whether to enable the app battery usage list page feature. -->
    <bool name="config_app_battery_usage_list_enabled">false</bool>
    <bool name="config_app_battery_usage_list_enabled">false</bool>


+4 −1
Original line number Original line Diff line number Diff line
@@ -189,13 +189,16 @@ public class RedactionInterstitial extends SettingsActivity {
        }
        }


        private void loadFromSettings() {
        private void loadFromSettings() {
            final boolean showUnRedactedDefault = getContext().getResources().getBoolean(
                    R.bool.default_allow_sensitive_lockscreen_content);
            final boolean managedProfile = UserManager.get(getContext()).isManagedProfile(mUserId);
            final boolean managedProfile = UserManager.get(getContext()).isManagedProfile(mUserId);
            // Hiding all notifications is device-wide setting, managed profiles can only set
            // Hiding all notifications is device-wide setting, managed profiles can only set
            // whether their notifications are show in full or redacted.
            // whether their notifications are show in full or redacted.
            final boolean showNotifications = managedProfile || Settings.Secure.getIntForUser(
            final boolean showNotifications = managedProfile || Settings.Secure.getIntForUser(
                    getContentResolver(), LOCK_SCREEN_SHOW_NOTIFICATIONS, 0, mUserId) != 0;
                    getContentResolver(), LOCK_SCREEN_SHOW_NOTIFICATIONS, 0, mUserId) != 0;
            final boolean showUnredacted = Settings.Secure.getIntForUser(
            final boolean showUnredacted = Settings.Secure.getIntForUser(
                    getContentResolver(), LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1, mUserId) != 0;
                    getContentResolver(), LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
                    showUnRedactedDefault ? 1 : 0, mUserId) != 0;


            int checkedButtonId = R.id.hide_all;
            int checkedButtonId = R.id.hide_all;
            if (showNotifications) {
            if (showNotifications) {
+29 −0
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@ import android.widget.RadioButton;
import com.android.settings.R;
import com.android.settings.R;
import com.android.settings.RestrictedRadioButton;
import com.android.settings.RestrictedRadioButton;
import com.android.settings.notification.RedactionInterstitial.RedactionInterstitialFragment;
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.ShadowRestrictedLockUtilsInternal;
import com.android.settings.testutils.shadow.ShadowUtils;
import com.android.settings.testutils.shadow.ShadowUtils;


@@ -38,6 +39,7 @@ import org.robolectric.shadows.ShadowUserManager;
@Config(shadows = {
@Config(shadows = {
        ShadowUtils.class,
        ShadowUtils.class,
        ShadowRestrictedLockUtilsInternal.class,
        ShadowRestrictedLockUtilsInternal.class,
        SettingsShadowResources.class,
})
})
public class RedactionInterstitialTest {
public class RedactionInterstitialTest {
    private RedactionInterstitial mActivity;
    private RedactionInterstitial mActivity;
@@ -134,6 +136,28 @@ public class RedactionInterstitialTest {
        assertSelectedButton(R.id.redact_sensitive);
        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() {
    private void setupActivity() {
        mActivity = buildActivity(RedactionInterstitial.class, new Intent()).setup().get();
        mActivity = buildActivity(RedactionInterstitial.class, new Intent()).setup().get();
        mFragment = (RedactionInterstitialFragment)
        mFragment = (RedactionInterstitialFragment)
@@ -142,6 +166,11 @@ public class RedactionInterstitialTest {
        assertThat(mFragment).isNotNull();
        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) {
    private void setupSettings(int show, int showUnredacted) {
        final ContentResolver resolver = RuntimeEnvironment.application.getContentResolver();
        final ContentResolver resolver = RuntimeEnvironment.application.getContentResolver();
        Settings.Secure.putIntForUser(resolver,
        Settings.Secure.putIntForUser(resolver,