Make battery cycle count configurable and disable it by default

Most devices don't report valid cycle count.

Change-Id: I32478dac8ff409cd90506495eca42b9df987919b
diff --git a/res/values/lineage_config.xml b/res/values/lineage_config.xml
index f349475..7a47d3a 100644
--- a/res/values/lineage_config.xml
+++ b/res/values/lineage_config.xml
@@ -21,4 +21,7 @@
 
     <!-- Show battery information -->
     <bool name="config_show_battery_info" translatable="false">true</bool>
+
+    <!-- Show battery cycle count -->
+    <bool name="config_show_battery_cycle_count" translatable="false">false</bool>
 </resources>
diff --git a/src/com/android/settings/deviceinfo/batteryinfo/BatteryCycleCountPreferenceController.java b/src/com/android/settings/deviceinfo/batteryinfo/BatteryCycleCountPreferenceController.java
index c1c7635..f7dff9d 100644
--- a/src/com/android/settings/deviceinfo/batteryinfo/BatteryCycleCountPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/batteryinfo/BatteryCycleCountPreferenceController.java
@@ -36,7 +36,8 @@
 
     @Override
     public int getAvailabilityStatus() {
-        return AVAILABLE;
+        return mContext.getResources().getBoolean(R.bool.config_show_battery_cycle_count)
+                ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
     }
 
     @Override
diff --git a/src/com/android/settings/deviceinfo/batteryinfo/BatteryInfoFragment.java b/src/com/android/settings/deviceinfo/batteryinfo/BatteryInfoFragment.java
index c017022..882901d 100644
--- a/src/com/android/settings/deviceinfo/batteryinfo/BatteryInfoFragment.java
+++ b/src/com/android/settings/deviceinfo/batteryinfo/BatteryInfoFragment.java
@@ -18,18 +18,23 @@
 
 import android.app.settings.SettingsEnums;
 import android.content.Context;
+import android.os.Bundle;
 
 import com.android.settings.R;
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settingslib.search.SearchIndexable;
+import com.android.settingslib.widget.FooterPreference;
 
 /** A fragment that shows battery hardware information. */
 @SearchIndexable
 public class BatteryInfoFragment extends DashboardFragment {
 
     public static final String TAG = "BatteryInfo";
+    private static final String KEY_BATTERY_INFO_FOOTER = "battery_info_footer";
+
+    private FooterPreference mFooterPreference;
 
     @Override
     public int getMetricsCategory() {
@@ -42,6 +47,19 @@
     }
 
     @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        mFooterPreference = findPreference(KEY_BATTERY_INFO_FOOTER);
+    }
+
+    @Override
+    public void onActivityCreated(Bundle savedInstanceState) {
+        super.onActivityCreated(savedInstanceState);
+        mFooterPreference.setVisible(
+                getContext().getResources().getBoolean(R.bool.config_show_battery_cycle_count));
+    }
+
+    @Override
     protected String getLogTag() {
         return TAG;
     }