Merge "Introduce boolean flags to show/hide battery/memory in App info."
diff --git a/res/values/bools.xml b/res/values/bools.xml
index 617ab7b..0cf085f 100644
--- a/res/values/bools.xml
+++ b/res/values/bools.xml
@@ -57,6 +57,12 @@
     <!-- Whether toggle_airplane is available or not. -->
     <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. -->
     <bool name="config_location_mode_available">true</bool>
 
diff --git a/src/com/android/settings/applications/appinfo/AppBatteryPreferenceController.java b/src/com/android/settings/applications/appinfo/AppBatteryPreferenceController.java
index ffe2bf3..afcf760 100644
--- a/src/com/android/settings/applications/appinfo/AppBatteryPreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/AppBatteryPreferenceController.java
@@ -76,7 +76,9 @@
 
     @Override
     public int getAvailabilityStatus() {
-        return AVAILABLE;
+        return mContext.getResources().getBoolean(R.bool.config_show_app_info_settings_battery)
+                ? AVAILABLE
+                : DISABLED_UNSUPPORTED;
     }
 
     @Override
diff --git a/src/com/android/settings/applications/appinfo/AppMemoryPreferenceController.java b/src/com/android/settings/applications/appinfo/AppMemoryPreferenceController.java
index 7b497a9..265754c 100644
--- a/src/com/android/settings/applications/appinfo/AppMemoryPreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/AppMemoryPreferenceController.java
@@ -104,6 +104,10 @@
 
     @Override
     public int getAvailabilityStatus() {
+        if (!mContext.getResources().getBoolean(R.bool.config_show_app_info_settings_memory)) {
+            return DISABLED_UNSUPPORTED;
+        }
+
         return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(mContext)
                 ? AVAILABLE : DISABLED_DEPENDENT_SETTING;
     }
diff --git a/tests/robotests/res/values-mcc999/config.xml b/tests/robotests/res/values-mcc999/config.xml
index 137a089..f43e39c 100644
--- a/tests/robotests/res/values-mcc999/config.xml
+++ b/tests/robotests/res/values-mcc999/config.xml
@@ -23,6 +23,8 @@
     <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_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_alarm_volume">false</bool>
     <bool name="config_show_charging_sounds">false</bool>
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppBatteryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppBatteryPreferenceControllerTest.java
index 91833f5..970b2ec 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/AppBatteryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppBatteryPreferenceControllerTest.java
@@ -109,8 +109,14 @@
     }
 
     @Test
-    public void getAvailabilityStatus_shouldAlwaysReturnAvailable() {
-        assertThat(mController.getAvailabilityStatus()).isEqualTo(mController.AVAILABLE);
+    public void testAppBattery_byDefault_shouldBeShown() {
+        assertThat(mController.isAvailable()).isTrue();
+    }
+
+    @Test
+    @Config(qualifiers = "mcc999")
+    public void testAppBattery_ifDisabled_shouldNotBeShown() {
+        assertThat(mController.isAvailable()).isFalse();
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppMemoryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppMemoryPreferenceControllerTest.java
index 47844c5..fd136c1 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/AppMemoryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppMemoryPreferenceControllerTest.java
@@ -84,6 +84,24 @@
     }
 
     @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
     public void getAvailabilityStatus_developmentSettingsDisabled_shouldReturnDisabled() {
         Settings.Global.putInt(mContext.getContentResolver(),
                 Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);