fixup! StatusBarSettings: Hide battery category on battery-less devices

Change-Id: I17999dfb7e5f1039c044e249b7d68a917dff9443
diff --git a/src/org/lineageos/lineageparts/statusbar/StatusBarSettings.java b/src/org/lineageos/lineageparts/statusbar/StatusBarSettings.java
index ee9d549..bc4e362 100644
--- a/src/org/lineageos/lineageparts/statusbar/StatusBarSettings.java
+++ b/src/org/lineageos/lineageparts/statusbar/StatusBarSettings.java
@@ -5,7 +5,9 @@
  */
 package org.lineageos.lineageparts.statusbar;
 
+import android.content.Context;
 import android.content.Intent;
+import android.content.IntentFilter;
 import android.os.BatteryManager;
 import android.os.Bundle;
 import android.provider.Settings;
@@ -16,8 +18,6 @@
 import androidx.preference.Preference;
 import androidx.preference.PreferenceCategory;
 
-import com.android.settingslib.fuelgauge.BatteryUtils;
-
 import org.lineageos.lineageparts.R;
 import org.lineageos.lineageparts.SettingsPreferenceFragment;
 import org.lineageos.lineageparts.utils.DeviceUtils;
@@ -74,7 +74,7 @@
         statusBarBattery.setOnPreferenceChangeListener(this);
         enableStatusBarBatteryDependents(statusBarBattery.getIntValue(2));
 
-        Intent intent = BatteryUtils.getBatteryIntent(getContext());
+        Intent intent = getBatteryIntent(getContext());
         if (intent != null) {
             mBatteryPresent = intent.getBooleanExtra(BatteryManager.EXTRA_PRESENT, true);
         }
@@ -156,6 +156,12 @@
         mStatusBarBatteryShowPercent.setEnabled(batteryIconStyle != STATUS_BAR_BATTERY_STYLE_TEXT);
     }
 
+    /** Gets the latest sticky battery intent from the Android system. */
+    public static Intent getBatteryIntent(Context context) {
+        return context.registerReceiver(
+                /*receiver=*/ null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
+    }
+
     private void updateQuickPulldownSummary(int value) {
         String summary="";
         switch (value) {