Introduce boolean flags to show/hide battery/memory in App info.

This adds two flags:
config_show_app_info_settings_memory
config_show_app_info_settings_battery

Which when individually set to false, will hide them item from "App
info" which is accessed from clicking on an application in Apps &
notifications -> App info.

Bug: 62379413
Test: make RunSettingsRoboTests
ROBOTEST_FILTER=com.android.settings.applications

Change-Id: Ifb3b644901728dc7ea04d13198abddaa7b230538
This commit is contained in:
Ben Lin
2018-01-19 15:03:59 -08:00
parent 1297029728
commit 3bf23ff59e
6 changed files with 41 additions and 3 deletions

View File

@@ -57,6 +57,12 @@
<!-- 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 memory from app_info_settings is available or not. -->
<bool name="config_show_app_info_settings_memory">true</bool>
<!-- Whether battery from app_info_settings is available or not. -->
<bool name="config_show_app_info_settings_battery">true</bool>
<!-- Whether location mode is available or not. --> <!-- Whether location mode is available or not. -->
<bool name="config_location_mode_available">true</bool> <bool name="config_location_mode_available">true</bool>

View File

@@ -76,7 +76,9 @@ public class AppBatteryPreferenceController extends BasePreferenceController
@Override @Override
public int getAvailabilityStatus() { public int getAvailabilityStatus() {
return AVAILABLE; return mContext.getResources().getBoolean(R.bool.config_show_app_info_settings_battery)
? AVAILABLE
: DISABLED_UNSUPPORTED;
} }
@Override @Override

View File

@@ -104,6 +104,10 @@ public class AppMemoryPreferenceController extends BasePreferenceController
@Override @Override
public int getAvailabilityStatus() { public int getAvailabilityStatus() {
if (!mContext.getResources().getBoolean(R.bool.config_show_app_info_settings_memory)) {
return DISABLED_UNSUPPORTED;
}
return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(mContext) return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(mContext)
? AVAILABLE : DISABLED_DEPENDENT_SETTING; ? AVAILABLE : DISABLED_DEPENDENT_SETTING;
} }

View File

@@ -23,6 +23,8 @@
<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_app_info_settings_memory">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>
<bool name="config_show_alarm_volume">false</bool> <bool name="config_show_alarm_volume">false</bool>
<bool name="config_show_charging_sounds">false</bool> <bool name="config_show_charging_sounds">false</bool>

View File

@@ -109,8 +109,14 @@ public class AppBatteryPreferenceControllerTest {
} }
@Test @Test
public void getAvailabilityStatus_shouldAlwaysReturnAvailable() { public void testAppBattery_byDefault_shouldBeShown() {
assertThat(mController.getAvailabilityStatus()).isEqualTo(mController.AVAILABLE); assertThat(mController.isAvailable()).isTrue();
}
@Test
@Config(qualifiers = "mcc999")
public void testAppBattery_ifDisabled_shouldNotBeShown() {
assertThat(mController.isAvailable()).isFalse();
} }
@Test @Test

View File

@@ -83,6 +83,24 @@ public class AppMemoryPreferenceControllerTest {
assertThat(mController.getAvailabilityStatus()).isEqualTo(mController.AVAILABLE); assertThat(mController.getAvailabilityStatus()).isEqualTo(mController.AVAILABLE);
} }
@Test
@Config(qualifiers = "mcc999")
public void getAvailabilityStatus_devSettingsEnabled_butNotVisible_shouldReturnUnsupported() {
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
assertThat(mController.getAvailabilityStatus()).isEqualTo(mController.DISABLED_UNSUPPORTED);
}
@Test
@Config(qualifiers = "mcc999")
public void getAvailabilityStatus_devSettingsDisabled_butNotVisible_shouldReturnUnsupported() {
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
assertThat(mController.getAvailabilityStatus()).isEqualTo(mController.DISABLED_UNSUPPORTED);
}
@Test @Test
public void getAvailabilityStatus_developmentSettingsDisabled_shouldReturnDisabled() { public void getAvailabilityStatus_developmentSettingsDisabled_shouldReturnDisabled() {
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.putInt(mContext.getContentResolver(),