Loading src/com/android/settings/security/ContentProtectionPreferenceController.java +10 −2 Original line number Diff line number Diff line Loading @@ -15,12 +15,12 @@ */ package com.android.settings.security; import static android.view.contentprotection.flags.Flags.settingUiEnabled; import static com.android.internal.R.string.config_defaultContentProtectionService; import android.content.ComponentName; import android.content.Context; import android.provider.DeviceConfig; import android.view.contentcapture.ContentCaptureManager; import androidx.annotation.NonNull; import androidx.annotation.Nullable; Loading Loading @@ -56,4 +56,12 @@ public class ContentProtectionPreferenceController extends BasePreferenceControl } return ComponentName.unflattenFromString(flatComponentName); } @VisibleForTesting protected boolean settingUiEnabled() { return DeviceConfig.getBoolean( DeviceConfig.NAMESPACE_CONTENT_CAPTURE, ContentCaptureManager.DEVICE_CONFIG_PROPERTY_ENABLE_CONTENT_PROTECTION_RECEIVER, ContentCaptureManager.DEFAULT_ENABLE_CONTENT_PROTECTION_RECEIVER); } } tests/robotests/src/com/android/settings/security/ContentProtectionPreferenceControllerTest.java +9 −2 Original line number Diff line number Diff line Loading @@ -48,6 +48,8 @@ public class ContentProtectionPreferenceControllerTest { private ContentProtectionPreferenceController mController; private boolean mSettingUiEnabled; @Before public void setUp() { mController = new TestContentProtectionPreferenceController(); Loading @@ -55,7 +57,7 @@ public class ContentProtectionPreferenceControllerTest { @Test public void isAvailable_flagSettingUiDisabled_isFalse() { mSetFlagsRule.disableFlags(FLAG_SETTING_UI_ENABLED); mSettingUiEnabled = false; assertThat(mController.isAvailable()).isFalse(); } Loading Loading @@ -98,7 +100,7 @@ public class ContentProtectionPreferenceControllerTest { @Test public void isAvailable_flagSettingUiEnabled_componentNameValid_isTrue() { mSetFlagsRule.enableFlags(FLAG_SETTING_UI_ENABLED); mSettingUiEnabled = true; assertThat(mController.isAvailable()).isTrue(); } Loading @@ -114,5 +116,10 @@ public class ContentProtectionPreferenceControllerTest { protected String getContentProtectionServiceFlatComponentName() { return mConfigDefaultContentProtectionService; } @Override protected boolean settingUiEnabled() { return mSettingUiEnabled; } } } Loading
src/com/android/settings/security/ContentProtectionPreferenceController.java +10 −2 Original line number Diff line number Diff line Loading @@ -15,12 +15,12 @@ */ package com.android.settings.security; import static android.view.contentprotection.flags.Flags.settingUiEnabled; import static com.android.internal.R.string.config_defaultContentProtectionService; import android.content.ComponentName; import android.content.Context; import android.provider.DeviceConfig; import android.view.contentcapture.ContentCaptureManager; import androidx.annotation.NonNull; import androidx.annotation.Nullable; Loading Loading @@ -56,4 +56,12 @@ public class ContentProtectionPreferenceController extends BasePreferenceControl } return ComponentName.unflattenFromString(flatComponentName); } @VisibleForTesting protected boolean settingUiEnabled() { return DeviceConfig.getBoolean( DeviceConfig.NAMESPACE_CONTENT_CAPTURE, ContentCaptureManager.DEVICE_CONFIG_PROPERTY_ENABLE_CONTENT_PROTECTION_RECEIVER, ContentCaptureManager.DEFAULT_ENABLE_CONTENT_PROTECTION_RECEIVER); } }
tests/robotests/src/com/android/settings/security/ContentProtectionPreferenceControllerTest.java +9 −2 Original line number Diff line number Diff line Loading @@ -48,6 +48,8 @@ public class ContentProtectionPreferenceControllerTest { private ContentProtectionPreferenceController mController; private boolean mSettingUiEnabled; @Before public void setUp() { mController = new TestContentProtectionPreferenceController(); Loading @@ -55,7 +57,7 @@ public class ContentProtectionPreferenceControllerTest { @Test public void isAvailable_flagSettingUiDisabled_isFalse() { mSetFlagsRule.disableFlags(FLAG_SETTING_UI_ENABLED); mSettingUiEnabled = false; assertThat(mController.isAvailable()).isFalse(); } Loading Loading @@ -98,7 +100,7 @@ public class ContentProtectionPreferenceControllerTest { @Test public void isAvailable_flagSettingUiEnabled_componentNameValid_isTrue() { mSetFlagsRule.enableFlags(FLAG_SETTING_UI_ENABLED); mSettingUiEnabled = true; assertThat(mController.isAvailable()).isTrue(); } Loading @@ -114,5 +116,10 @@ public class ContentProtectionPreferenceControllerTest { protected String getContentProtectionServiceFlatComponentName() { return mConfigDefaultContentProtectionService; } @Override protected boolean settingUiEnabled() { return mSettingUiEnabled; } } }