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

Commit 82b18b92 authored by Steve's avatar Steve Committed by Gerrit Code Review
Browse files

Add support for external dock batterys

Allows the external battery status to be read via framework.

Change-Id: I1340071cecab8f1733e58e4f3ba0d304f861f311
parent c557ddb3
Loading
Loading
Loading
Loading
+33 −0
Original line number Original line Diff line number Diff line
@@ -27,6 +27,12 @@ public class BatteryManager {
     */
     */
    public static final String EXTRA_STATUS = "status";
    public static final String EXTRA_STATUS = "status";


    /**
     * Integer containing the current status constant for the dock battery.
     * @hide
     */
    public static final String EXTRA_DOCK_STATUS = "dock_status";
    
    /**
    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * integer containing the current health constant.
     * integer containing the current health constant.
@@ -46,6 +52,18 @@ public class BatteryManager {
     */
     */
    public static final String EXTRA_LEVEL = "level";
    public static final String EXTRA_LEVEL = "level";


    /**
     * Integer field containing the current dock battery level.
     * @hide
     */
    public static final String EXTRA_DOCK_LEVEL = "dock_level";

    /**
     * Boolean field containing the current dock battery AC status.
     * @hide
     */
    public static final String EXTRA_DOCK_AC_ONLINE = "dock_ac_online";
    
    /**
    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * integer containing the maximum battery level.
     * integer containing the maximum battery level.
@@ -109,6 +127,21 @@ public class BatteryManager {
    public static final int BATTERY_HEALTH_UNSPECIFIED_FAILURE = 6;
    public static final int BATTERY_HEALTH_UNSPECIFIED_FAILURE = 6;
    public static final int BATTERY_HEALTH_COLD = 7;
    public static final int BATTERY_HEALTH_COLD = 7;


    /** @hide */
    public static final int DOCK_STATE_UNKNOWN = 0;

    /** @hide */
    public static final int DOCK_STATE_UNDOCKED = 1;

    /** @hide */
    public static final int DOCK_STATE_CHARGING = 2;

    /** @hide */
    public static final int DOCK_STATE_DOCKED = 3;

    /** @hide */
    public static final int DOCK_STATE_DISCHARGING = 4;

    // values of the "plugged" field in the ACTION_BATTERY_CHANGED intent.
    // values of the "plugged" field in the ACTION_BATTERY_CHANGED intent.
    // These must be powers of 2.
    // These must be powers of 2.
    /** Power source is an AC charger. */
    /** Power source is an AC charger. */
+3 −0
Original line number Original line Diff line number Diff line
@@ -915,4 +915,7 @@
    <!-- Device has a h/w rotation lock switch -->
    <!-- Device has a h/w rotation lock switch -->
    <bool name="config_hasRotationLockSwitch">false</bool>
    <bool name="config_hasRotationLockSwitch">false</bool>


    <!-- Asus dock compatibility disabled by default -->
    <bool name="config_hasDockBattery">false</bool>

</resources>
</resources>
+1 −0
Original line number Original line Diff line number Diff line
@@ -3677,6 +3677,7 @@
  <java-symbol type="integer" name="config_backKillTimeout" />
  <java-symbol type="integer" name="config_backKillTimeout" />
  <java-symbol type="bool" name="config_screenOffAnimation" />
  <java-symbol type="bool" name="config_screenOffAnimation" />
  <java-symbol type="bool" name="config_hasRotationLockSwitch" />
  <java-symbol type="bool" name="config_hasRotationLockSwitch" />
  <java-symbol type="bool" name="config_hasDockBattery" />


  <!-- Notification and battery light -->
  <!-- Notification and battery light -->
  <java-symbol type="bool" name="config_intrusiveBatteryLed" />
  <java-symbol type="bool" name="config_intrusiveBatteryLed" />
+15 −0
Original line number Original line Diff line number Diff line
@@ -107,6 +107,10 @@ class BatteryService extends Binder {
    private boolean mBatteryLevelCritical;
    private boolean mBatteryLevelCritical;
    private int mInvalidCharger;
    private int mInvalidCharger;


    private int mDockBatteryStatus;
    private int mDockBatteryLevel;
    private String mDockBatteryPresent;

    private int mLastBatteryStatus;
    private int mLastBatteryStatus;
    private int mLastBatteryHealth;
    private int mLastBatteryHealth;
    private boolean mLastBatteryPresent;
    private boolean mLastBatteryPresent;
@@ -119,6 +123,8 @@ class BatteryService extends Binder {
    private int mLowBatteryWarningLevel;
    private int mLowBatteryWarningLevel;
    private int mLowBatteryCloseWarningLevel;
    private int mLowBatteryCloseWarningLevel;


    private boolean mHasDockBattery;

    private int mPlugType;
    private int mPlugType;
    private int mLastPlugType = -1; // Extra state so we can detect first run
    private int mLastPlugType = -1; // Extra state so we can detect first run


@@ -153,6 +159,9 @@ class BatteryService extends Binder {
        mLowBatteryCloseWarningLevel = mContext.getResources().getInteger(
        mLowBatteryCloseWarningLevel = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_lowBatteryCloseWarningLevel);
                com.android.internal.R.integer.config_lowBatteryCloseWarningLevel);


        mHasDockBattery = mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_hasDockBattery);

        mPowerSupplyObserver.startObserving("SUBSYSTEM=power_supply");
        mPowerSupplyObserver.startObserving("SUBSYSTEM=power_supply");


        // watch for invalid charger messages if the invalid_charger switch exists
        // watch for invalid charger messages if the invalid_charger switch exists
@@ -409,6 +418,12 @@ class BatteryService extends Binder {
        intent.putExtra(BatteryManager.EXTRA_TECHNOLOGY, mBatteryTechnology);
        intent.putExtra(BatteryManager.EXTRA_TECHNOLOGY, mBatteryTechnology);
        intent.putExtra(BatteryManager.EXTRA_INVALID_CHARGER, mInvalidCharger);
        intent.putExtra(BatteryManager.EXTRA_INVALID_CHARGER, mInvalidCharger);


        if (mHasDockBattery){
            intent.putExtra(BatteryManager.EXTRA_DOCK_STATUS, mDockBatteryStatus);
            intent.putExtra(BatteryManager.EXTRA_DOCK_LEVEL, mDockBatteryLevel);
            intent.putExtra(BatteryManager.EXTRA_DOCK_AC_ONLINE, false);
        }

        if (false) {
        if (false) {
            Slog.d(TAG, "level:" + mBatteryLevel +
            Slog.d(TAG, "level:" + mBatteryLevel +
                    " scale:" + BATTERY_SCALE + " status:" + mBatteryStatus +
                    " scale:" + BATTERY_SCALE + " status:" + mBatteryStatus +
+4 −0
Original line number Original line Diff line number Diff line
@@ -48,6 +48,10 @@ ifeq ($(WITH_MALLOC_LEAK_CHECK),true)
    LOCAL_CFLAGS += -DMALLOC_LEAK_CHECK
    LOCAL_CFLAGS += -DMALLOC_LEAK_CHECK
endif
endif


ifeq ($(TARGET_HAS_DOCK_BATTERY),true)
    LOCAL_CFLAGS += -DHAS_DOCK_BATTERY
endif

LOCAL_MODULE:= libandroid_servers
LOCAL_MODULE:= libandroid_servers


include $(BUILD_SHARED_LIBRARY)
include $(BUILD_SHARED_LIBRARY)
Loading