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

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

Merge "Rename Battery to BatteryState." into sc-dev

parents bcf4d577 c9b9464a
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -17136,11 +17136,11 @@ package android.graphics.text {
package android.hardware {
  public abstract class Battery {
    ctor public Battery();
  public abstract class BatteryState {
    ctor public BatteryState();
    method @FloatRange(from=-1.0F, to=1.0f) public abstract float getCapacity();
    method public abstract int getStatus();
    method public abstract boolean hasBattery();
    method public abstract boolean isPresent();
    field public static final int STATUS_CHARGING = 2; // 0x2
    field public static final int STATUS_DISCHARGING = 3; // 0x3
    field public static final int STATUS_FULL = 5; // 0x5
@@ -47130,7 +47130,7 @@ package android.view {
  public final class InputDevice implements android.os.Parcelable {
    method public int describeContents();
    method @NonNull public android.hardware.Battery getBattery();
    method @NonNull public android.hardware.BatteryState getBatteryState();
    method public int getControllerNumber();
    method public String getDescriptor();
    method public static android.view.InputDevice getDevice(int);
+4 −4
Original line number Diff line number Diff line
@@ -24,9 +24,9 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * The Battery class is a representation of a single battery on a device.
 * The BatteryState class is a representation of a single battery on a device.
 */
public abstract class Battery {
public abstract class BatteryState {
    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = { "STATUS_" }, value = {
@@ -55,7 +55,7 @@ public abstract class Battery {
     *
     * @return True if the hardware has a battery, else false.
     */
    public abstract boolean hasBattery();
    public abstract boolean isPresent();

    /**
     * Get the battery status.
@@ -66,7 +66,7 @@ public abstract class Battery {

    /**
     * Get remaining battery capacity as float percentage [0.0f, 1.0f] of total capacity
     * Returns -1 when battery capacity can't be read.
     * Returns NaN when battery capacity can't be read.
     *
     * @return the battery capacity.
     */
+5 −5
Original line number Diff line number Diff line
@@ -19,28 +19,28 @@ package android.hardware.input;
import static android.os.BatteryManager.BATTERY_STATUS_UNKNOWN;
import static android.os.IInputConstants.INVALID_BATTERY_CAPACITY;

import android.hardware.Battery;
import android.hardware.BatteryState;

/**
 * Battery implementation for input devices.
 *
 * @hide
 */
public final class InputDeviceBattery extends Battery {
    private static final float NULL_BATTERY_CAPACITY = -1.0f;
public final class InputDeviceBatteryState extends BatteryState {
    private static final float NULL_BATTERY_CAPACITY = Float.NaN;

    private final InputManager mInputManager;
    private final int mDeviceId;
    private final boolean mHasBattery;

    InputDeviceBattery(InputManager inputManager, int deviceId, boolean hasBattery) {
    InputDeviceBatteryState(InputManager inputManager, int deviceId, boolean hasBattery) {
        mInputManager = inputManager;
        mDeviceId = deviceId;
        mHasBattery = hasBattery;
    }

    @Override
    public boolean hasBattery() {
    public boolean isPresent() {
        return mHasBattery;
    }

+3 −3
Original line number Diff line number Diff line
@@ -1571,12 +1571,12 @@ public final class InputManager {
    }

    /**
     * Gets a battery object associated with an input device, assuming it has one.
     * Gets a battery state object associated with an input device, assuming it has one.
     * @return The battery, never null.
     * @hide
     */
    public InputDeviceBattery getInputDeviceBattery(int deviceId, boolean hasBattery) {
        return new InputDeviceBattery(this, deviceId, hasBattery);
    public InputDeviceBatteryState getInputDeviceBatteryState(int deviceId, boolean hasBattery) {
        return new InputDeviceBatteryState(this, deviceId, hasBattery);
    }

    /**
+5 −0
Original line number Diff line number Diff line
@@ -141,6 +141,11 @@ public final class Light implements Parcelable {
        return mId;
    }

    @Override
    public String toString() {
        return "[Name=" + mName + " Id=" + mId + " Type=" + mType + " Ordinal=" + mOrdinal + "]";
    }

    /**
     * Returns the id of the light.
     *
Loading