Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d389b64a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Get battery presence at setup, if possible."

parents 66322958 982384a0
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -815,6 +815,18 @@ public class InternalResourceService extends SystemService {
        synchronized (mLock) {
            registerListeners();
            mCurrentBatteryLevel = getCurrentBatteryLevel();
            // Get the current battery presence, if available. This would succeed if TARE is
            // toggled long after boot.
            final Intent batteryStatus = getContext().registerReceiver(null,
                    new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
            if (batteryStatus != null) {
                final boolean hasBattery =
                        batteryStatus.getBooleanExtra(BatteryManager.EXTRA_PRESENT, true);
                if (mHasBattery != hasBattery) {
                    mHasBattery = hasBattery;
                    mConfigObserver.updateEnabledStatus();
                }
            }
        }
    }