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
This commit is contained in:
@@ -57,6 +57,9 @@
|
|||||||
<!-- Whether toggle_airplane is available or not. -->
|
<!-- Whether toggle_airplane is available or not. -->
|
||||||
<bool name="config_show_toggle_airplane">true</bool>
|
<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. -->
|
<!-- Whether memory from app_info_settings is available or not. -->
|
||||||
<bool name="config_show_app_info_settings_memory">false</bool>
|
<bool name="config_show_app_info_settings_memory">false</bool>
|
||||||
|
|
||||||
|
@@ -80,7 +80,9 @@ public class PrivateDnsPreferenceController extends BasePreferenceController
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return AVAILABLE;
|
return mContext.getResources().getBoolean(R.bool.config_show_private_dns_settings)
|
||||||
|
? AVAILABLE
|
||||||
|
: UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
<bool name="config_additional_system_update_setting_enable">true</bool>
|
<bool name="config_additional_system_update_setting_enable">true</bool>
|
||||||
<bool name="config_show_wifi_settings">false</bool>
|
<bool name="config_show_wifi_settings">false</bool>
|
||||||
<bool name="config_show_toggle_airplane">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_memory">true</bool>
|
||||||
<bool name="config_show_app_info_settings_battery">false</bool>
|
<bool name="config_show_app_info_settings_battery">false</bool>
|
||||||
<bool name="config_show_high_power_apps">false</bool>
|
<bool name="config_show_high_power_apps">false</bool>
|
||||||
|
@@ -24,6 +24,8 @@ import static android.provider.Settings.Global.PRIVATE_DNS_MODE;
|
|||||||
import static android.provider.Settings.Global.PRIVATE_DNS_SPECIFIER;
|
import static android.provider.Settings.Global.PRIVATE_DNS_SPECIFIER;
|
||||||
import static androidx.lifecycle.Lifecycle.Event.ON_START;
|
import static androidx.lifecycle.Lifecycle.Event.ON_START;
|
||||||
import static androidx.lifecycle.Lifecycle.Event.ON_STOP;
|
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 com.google.common.truth.Truth.assertThat;
|
||||||
import static org.mockito.ArgumentMatchers.nullable;
|
import static org.mockito.ArgumentMatchers.nullable;
|
||||||
import static org.mockito.Matchers.anyString;
|
import static org.mockito.Matchers.anyString;
|
||||||
@@ -57,6 +59,7 @@ import org.mockito.ArgumentCaptor;
|
|||||||
import org.mockito.Captor;
|
import org.mockito.Captor;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
import org.robolectric.shadow.api.Shadow;
|
import org.robolectric.shadow.api.Shadow;
|
||||||
import org.robolectric.shadows.ShadowContentResolver;
|
import org.robolectric.shadows.ShadowContentResolver;
|
||||||
@@ -143,6 +146,17 @@ public class PrivateDnsPreferenceControllerTest {
|
|||||||
nc.onLinkPropertiesChanged(mNetwork, lp);
|
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
|
@Test
|
||||||
public void goThroughLifecycle_shouldRegisterUnregisterSettingsObserver() {
|
public void goThroughLifecycle_shouldRegisterUnregisterSettingsObserver() {
|
||||||
mLifecycle.handleLifecycleEvent(ON_START);
|
mLifecycle.handleLifecycleEvent(ON_START);
|
||||||
|
Reference in New Issue
Block a user