Use DeviceConfig flag instead of aconfig flag

Bug: 308610589
Test: Units
Flag: EXEMPT
Change-Id: I3ff34b4048d8c0f0101f74fbab0498f91c7c2409
This commit is contained in:
Nino Jagar
2023-11-03 17:51:16 +00:00
parent b1852541a0
commit bf97254dd7
2 changed files with 19 additions and 4 deletions

View File

@@ -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;
@@ -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);
}
}

View File

@@ -48,6 +48,8 @@ public class ContentProtectionPreferenceControllerTest {
private ContentProtectionPreferenceController mController;
private boolean mSettingUiEnabled;
@Before
public void setUp() {
mController = new TestContentProtectionPreferenceController();
@@ -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();
}
@@ -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();
}
@@ -114,5 +116,10 @@ public class ContentProtectionPreferenceControllerTest {
protected String getContentProtectionServiceFlatComponentName() {
return mConfigDefaultContentProtectionService;
}
@Override
protected boolean settingUiEnabled() {
return mSettingUiEnabled;
}
}
}