Add boolean flags to show/hide top-most settings.
Bug: None Test: RunSettingsRoboTests Change-Id: Ib576f5979feda0fa7f573915acffc5065d40095c
This commit is contained in:
@@ -168,6 +168,15 @@
|
||||
<!-- Whether device_model should be shown or not. -->
|
||||
<bool name="config_show_device_model">true</bool>
|
||||
|
||||
<!-- Whether top_level_battery should be shown or not. -->
|
||||
<bool name="config_show_top_level_battery">true</bool>
|
||||
|
||||
<!-- Whether top_level_connected_devices should be shown or not. -->
|
||||
<bool name="config_show_top_level_connected_devices">true</bool>
|
||||
|
||||
<!-- Whether top_level_display should be shown or not. -->
|
||||
<bool name="config_show_top_level_display">true</bool>
|
||||
|
||||
<!-- Whether wifi_ip_address should be shown or not. -->
|
||||
<bool name="config_show_wifi_ip_address">true</bool>
|
||||
|
||||
|
@@ -19,6 +19,7 @@ package com.android.settings.connecteddevice;
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.R;
|
||||
|
||||
public class TopLevelConnectedDevicesPreferenceController extends BasePreferenceController {
|
||||
|
||||
@@ -29,7 +30,9 @@ public class TopLevelConnectedDevicesPreferenceController extends BasePreference
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE_UNSEARCHABLE;
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_top_level_connected_devices)
|
||||
? AVAILABLE_UNSEARCHABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -29,7 +29,9 @@ public class TopLevelDisplayPreferenceController extends BasePreferenceControlle
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_top_level_display)
|
||||
? AVAILABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -48,7 +48,9 @@ public class TopLevelBatteryPreferenceController extends BasePreferenceControlle
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE_UNSEARCHABLE;
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_top_level_battery)
|
||||
? AVAILABLE_UNSEARCHABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -58,6 +58,9 @@
|
||||
<bool name="config_show_system_update_settings">false</bool>
|
||||
<bool name="config_wifi_support_connected_mac_randomization">false</bool>
|
||||
<bool name="config_show_device_model">false</bool>
|
||||
<bool name="config_show_top_level_battery">false</bool>
|
||||
<bool name="config_show_top_level_connected_devices">false</bool>
|
||||
<bool name="config_show_top_level_display">false</bool>
|
||||
<bool name="config_show_wifi_ip_address">false</bool>
|
||||
<bool name="config_show_wifi_mac_address">false</bool>
|
||||
<bool name="config_disable_uninstall_update">true</bool>
|
||||
|
@@ -16,6 +16,9 @@
|
||||
|
||||
package com.android.settings.connecteddevice;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -43,6 +46,17 @@ public class TopLevelConnectedDevicesPreferenceControllerTest {
|
||||
mController = new TopLevelConnectedDevicesPreferenceController(mContext, "test_key");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailibilityStatus_availableByDefault() {
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(qualifiers = "mcc999")
|
||||
public void getAvailabilityStatus_unsupportedWhenSet() {
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowAdvancedConnectedDeviceController.class)
|
||||
public void getSummary_shouldCallAdvancedConnectedDeviceController() {
|
||||
|
@@ -17,12 +17,14 @@
|
||||
package com.android.settings.display;
|
||||
|
||||
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.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -40,11 +42,13 @@ import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class TopLevelDisplayPreferenceControllerTest {
|
||||
@Mock
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private PackageManager mPackageManager;
|
||||
@@ -54,6 +58,7 @@ public class TopLevelDisplayPreferenceControllerTest {
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
when(mContext.getPackageManager()).thenReturn(mPackageManager);
|
||||
when(mContext.getString(R.string.config_wallpaper_picker_package)).thenReturn("pkg");
|
||||
when(mContext.getString(R.string.config_wallpaper_picker_class)).thenReturn("cls");
|
||||
@@ -62,10 +67,16 @@ public class TopLevelDisplayPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailability_alwaysAvailable() {
|
||||
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 getSummary_hasWallpaper_shouldReturnWallpaperSummary() {
|
||||
final List<ResolveInfo> resolveInfos = new ArrayList<>();
|
||||
|
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.settings.fuelgauge;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
import static com.android.settings.fuelgauge.TopLevelBatteryPreferenceController.getDashboardLabel;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
@@ -25,17 +27,30 @@ import android.content.Context;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class TopLevelBatteryPreferenceControllerTest {
|
||||
|
||||
private Context mContext;
|
||||
private TopLevelBatteryPreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mController = new TopLevelBatteryPreferenceController(mContext, "test_key");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailibilityStatus_availableByDefault() {
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(qualifiers = "mcc999")
|
||||
public void getAvailabilityStatus_unsupportedWhenSet() {
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user