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

Commit b5dff8f9 authored by Nino Jagar's avatar Nino Jagar Committed by Android (Google) Code Review
Browse files

Merge "Use DeviceConfig flag instead of aconfig flag" into main

parents a8cfc6d9 bf97254d
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -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);
    }
}
+9 −2
Original line number Diff line number Diff line
@@ -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;
        }
    }
}