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

Commit bc4b5844 authored by Ben Lin's avatar Ben Lin
Browse files

Add a boolean flag to show or hide Private DNS in Network & internet.

The following boolean flag is added:
config_show_private_dns_settings

When set to false, Private DNS will not be shown in Network & internet.

Bug: 111398942
Test: make RunSettingsRoboTests
ROBOTEST_FILTER=PrivateDnsPreferenceControllerTest
Change-Id: I62911930680355b7fc109b295d8526bdb7eac0b3
parent c879386e
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -57,6 +57,9 @@
    <!-- Whether toggle_airplane is available or not. -->
    <bool name="config_show_toggle_airplane">true</bool>

    <!-- Whether private_dns_settings is available or not. -->
    <bool name="config_show_private_dns_settings">true</bool>

    <!-- Whether memory from app_info_settings is available or not. -->
    <bool name="config_show_app_info_settings_memory">false</bool>

+3 −1
Original line number Diff line number Diff line
@@ -80,7 +80,9 @@ public class PrivateDnsPreferenceController extends BasePreferenceController

    @Override
    public int getAvailabilityStatus() {
        return AVAILABLE;
        return mContext.getResources().getBoolean(R.bool.config_show_private_dns_settings)
                ? AVAILABLE
                : UNSUPPORTED_ON_DEVICE;
    }

    @Override
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
    <bool name="config_additional_system_update_setting_enable">true</bool>
    <bool name="config_show_wifi_settings">false</bool>
    <bool name="config_show_toggle_airplane">false</bool>
    <bool name="config_show_private_dns_settings">false</bool>
    <bool name="config_show_app_info_settings_memory">true</bool>
    <bool name="config_show_app_info_settings_battery">false</bool>
    <bool name="config_show_high_power_apps">false</bool>
+14 −0
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import static android.provider.Settings.Global.PRIVATE_DNS_MODE;
import static android.provider.Settings.Global.PRIVATE_DNS_SPECIFIER;
import static androidx.lifecycle.Lifecycle.Event.ON_START;
import static androidx.lifecycle.Lifecycle.Event.ON_STOP;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.anyString;
@@ -57,6 +59,7 @@ import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadow.api.Shadow;
import org.robolectric.shadows.ShadowContentResolver;
@@ -143,6 +146,17 @@ public class PrivateDnsPreferenceControllerTest {
        nc.onLinkPropertiesChanged(mNetwork, lp);
    }

    @Test
    public void getAvailibilityStatus_availableByDefault() {
        assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
    }

    @Test
    @Config(qualifiers = "mcc999")
    public void getAvailabilityStatus_unsupportedWhenSet() {
        assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
    }

    @Test
    public void goThroughLifecycle_shouldRegisterUnregisterSettingsObserver() {
        mLifecycle.handleLifecycleEvent(ON_START);