Interface PowerSource
- All Known Implementing Classes:
AbstractPowerSource
,AixPowerSource
,FreeBsdPowerSource
,LinuxPowerSource
,MacPowerSource
,OpenBsdPowerSource
,SolarisPowerSource
,WindowsPowerSource
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
Units of Battery Capacity -
Method Summary
Modifier and TypeMethodDescriptiondouble
Amperage of the battery, in milliAmperes (mA).The battery chemistry (e.g., Lithium Ion).int
The current (remaining) capacity of the battery.int
The cycle count of the battery, if known.int
The design (original) capacity of the battery.Name of the power source at the device level.The battery's date of manufacture.The name of the battery's manufacturer.int
The maximum capacity of the battery.getName()
Name of the power source at the Operating System level.double
Power Usage Rate of the battery, in milliWatts (mW).double
Estimated remaining capacity as a fraction of max capacity.The battery's serial number.double
The battery's temperature, in degrees Celsius.double
Estimated time remaining on the power source, in seconds, as reported by the operating system.double
Estimated time remaining on the power source, in seconds, as reported by the battery.double
Voltage of the battery, in Volts.boolean
Reports whether the battery is charging.boolean
Reports whether the battery is discharging.boolean
Reports whether the device is plugged in to an external power source.boolean
Updates statistics on this battery.
-
Method Details
-
getName
String getName()Name of the power source at the Operating System level.- Returns:
- The power source name, as reported by the operating system.
-
getDeviceName
String getDeviceName()Name of the power source at the device level.- Returns:
- The power source name, as reported by the device itself.
-
getRemainingCapacityPercent
double getRemainingCapacityPercent()Estimated remaining capacity as a fraction of max capacity.This is an estimated/smoothed value which should correspond to the Operating System's "percent power" display, and may not directly correspond to the ratio of
getCurrentCapacity()
togetMaxCapacity()
.- Returns:
- A value between 0.0 (fully drained) and 1.0 (fully charged)
-
getTimeRemainingEstimated
double getTimeRemainingEstimated()Estimated time remaining on the power source, in seconds, as reported by the operating system.This is an estimated/smoothed value which should correspond to the Operating System's "battery time remaining" display, and will react slowly to changes in power consumption.
- Returns:
- If positive, seconds remaining. If negative, -1.0 (calculating) or -2.0 (unlimited)
-
getTimeRemainingInstant
double getTimeRemainingInstant()Estimated time remaining on the power source, in seconds, as reported by the battery. If the battery is charging, this value may represent time remaining to fully charge the battery.Note that this value is not very accurate on some battery systems. The value may vary widely depending on present power usage, which could be affected by disk activity and other factors. This value will often be a higher value than
getTimeRemainingEstimated()
.- Returns:
- Seconds remaining to fully discharge or fully charge the battery.
-
getPowerUsageRate
double getPowerUsageRate()Power Usage Rate of the battery, in milliWatts (mW).- Returns:
- If positive, the charge rate. If negative, the discharge rate.
-
getVoltage
double getVoltage()Voltage of the battery, in Volts.- Returns:
- the battery voltage, or -1 if unknown.
-
getAmperage
double getAmperage()Amperage of the battery, in milliAmperes (mA).- Returns:
- the battery amperage. If positive, charging the battery. If negative, discharging the battery.
-
isPowerOnLine
boolean isPowerOnLine()Reports whether the device is plugged in to an external power source.- Returns:
true
if plugged in,false
otherwise.
-
isCharging
boolean isCharging()Reports whether the battery is charging.- Returns:
true
if the battery is charging,false
otherwise.
-
isDischarging
boolean isDischarging()Reports whether the battery is discharging.- Returns:
true
if the battery is discharging,false
otherwise.
-
getCapacityUnits
PowerSource.CapacityUnits getCapacityUnits()- Returns:
- The units of battery capacity.
-
getCurrentCapacity
int getCurrentCapacity()The current (remaining) capacity of the battery.- Returns:
- The current capacity. Units are defined by
getCapacityUnits()
.
-
getMaxCapacity
int getMaxCapacity()The maximum capacity of the battery. When compared to design capacity, permits a measure of battery state of health. It is possible for max capacity to exceed design capacity.- Returns:
- The maximum capacity. Units are defined by
getCapacityUnits()
.
-
getDesignCapacity
int getDesignCapacity()The design (original) capacity of the battery. When compared to maximum capacity, permits a measure of battery state of health. It is possible for max capacity to exceed design capacity.- Returns:
- The design capacity. Units are defined by
getCapacityUnits()
.
-
getCycleCount
int getCycleCount()The cycle count of the battery, if known.- Returns:
- The cycle count of the battery, or -1 if unknown.
-
getChemistry
String getChemistry()The battery chemistry (e.g., Lithium Ion).- Returns:
- the battery chemistry.
-
getManufactureDate
LocalDate getManufactureDate()The battery's date of manufacture.Some battery manufacturers encode the manufacture date in the serial number. Parsing this value is operating system and battery manufacturer dependent, and is left to the user.
- Returns:
- the manufacture date, if available. May be
null
.
-
getManufacturer
String getManufacturer()The name of the battery's manufacturer.- Returns:
- the manufacturer name.
-
getSerialNumber
String getSerialNumber()The battery's serial number.Some battery manufacturers encode the manufacture date in the serial number. Parsing this value is operating system and battery manufacturer dependent, and is left to the user.
- Returns:
- the serial number.
-
getTemperature
double getTemperature()The battery's temperature, in degrees Celsius.- Returns:
- the battery's temperature, or 0 if uknown.
-
updateAttributes
boolean updateAttributes()Updates statistics on this battery.- Returns:
true
if the update was successful. Iffalse
the battery statistics are unchanged.
-