public class PowerStateEvent extends Event
EventListeners
being
notified, and can use the getNewState
and getPrevState
methods to make queries for system power state information. The
isUrgent
method can be used to determine if the state change event
can be opposed. The value of a PowerStateEvent
is the new power
state.
A PowerStateEvent
can be initiated only when the operating system
is operational. The following describes when a PowerStateEvent
is
valid and the valid state transitions.
A PowerStateEvent
MUST be delivered before one of the following
state transitions take place (if technically possible):
A PowerStateEvent
MAY be delivered after one of the following
state transition has taken place:
No PowerStateEvent
can be delivered for the following state
transition :
If there is no state transition (like in the case of a call to
PowerManager.setPowerState
with an argument state similar to the currently valid one), there is no
event generated.
EventListener
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BATTERY_LEVEL
To be used as an event name for
Event . |
static java.lang.String |
POWER_ALERT
To be used as an event name for
Event . |
static int |
POWER_ALERT_BATTERY_CRITICAL
Valid value for
POWER_ALERT events. |
static int |
POWER_ALERT_BATTERY_LOW
Valid value for
POWER_ALERT events. |
static int |
POWER_ALERT_BATTERY_NORMAL
Valid value for
POWER_ALERT events. |
static int |
POWER_ALERT_CALL_TERMINATION
Valid value for
POWER_ALERT events. |
static int |
POWER_ALERT_EXTERNAL_POWER_SOURCE_CHANGE
Valid value for
POWER_ALERT events. |
static int |
POWER_ALERT_IR_TERMINATION
Valid value for
POWER_ALERT events. |
static int |
POWER_ALERT_NETWORK_TERMINATION
Valid value for
POWER_ALERT events. |
static java.lang.String |
POWER_STATE
Indicates the power state as an
int value. |
static int |
POWER_STATE_FULL_POWER
Valid value for
POWER_STATE events. |
static int |
POWER_STATE_OFF
Valid value for
POWER_STATE events. |
static int |
POWER_STATE_REGULATED_HIGH_POWER
Valid value for
POWER_STATE events. |
static int |
POWER_STATE_REGULATED_LOW_POWER
Valid value for
POWER_STATE events. |
static int |
POWER_STATE_SLEEP
Valid value for
POWER_STATE events. |
static int |
POWER_STATE_SUSPEND
Valid value for
POWER_STATE events. |
APPLICATION_RELAUNCH_PREFIX, AUDIO_MUTE, SYSTEM_STATE, SYSTEM_STATE_NORMAL, SYSTEM_STATE_SHUTDOWN, SYSTEM_STATE_STANDBY, SYSTEM_STATE_STARTUP, VOICE_CALL
Modifier | Constructor and Description |
---|---|
protected |
PowerStateEvent(int prevState,
int newState,
boolean urgent)
Constructs a
PowerStateEvent object. |
Modifier and Type | Method and Description |
---|---|
int |
getNewState()
Gets the new power state that the system is going to transit to.
|
int |
getPrevState()
Gets the previous power state, which is the state at the time when the
event object is created.
|
boolean |
isUrgent()
Event listeners use this method to determine if the power state change
event can be opposed.
|
public static final java.lang.String POWER_ALERT
Event
.
Indicates a power management event.
Valid values are
POWER_ALERT_BATTERY_CRITICAL
, POWER_ALERT_BATTERY_LOW
,
POWER_ALERT_BATTERY_NORMAL
, POWER_ALERT_CALL_TERMINATION
,
POWER_ALERT_IR_TERMINATION
, POWER_ALERT_NETWORK_TERMINATION
,
and POWER_ALERT_EXTERNAL_POWER_SOURCE_CHANGE
.public static final int POWER_ALERT_BATTERY_CRITICAL
POWER_ALERT
events.
A warning that the primary battery level is critically low. The application
should immediately clean up and be prepared to shut down if necessary when
it receives this warning. The device can be shutdown at any time without
further warning.public static final int POWER_ALERT_BATTERY_LOW
POWER_ALERT
events.
A warning that the primary battery level is getting low. The definition
of a low battery is implementation dependent, but is a general indication
that the application should begin conserving power.public static final int POWER_ALERT_BATTERY_NORMAL
POWER_ALERT
events.
An indication that the level of the primary battery has returned to normal
(is no longer low or critical), presumably due to being charged.public static final int POWER_ALERT_CALL_TERMINATION
POWER_ALERT
events.
A warning that the telephone connection is about to be terminated due to
insufficient power, so the application should close down the session in
an orderly fashion.public static final int POWER_ALERT_EXTERNAL_POWER_SOURCE_CHANGE
POWER_ALERT
events.
An indication that an external power source has been applied or removed.
The estimatedTimeRemaining
in this case will be either
Integer.MAX_VALUE
if a power source was applied, a positive
integer indicating an estimate of the time remaining if the power source
has been removed, or -1
if the power source has been removed
and no time estimate is available.public static final int POWER_ALERT_IR_TERMINATION
POWER_ALERT
events.
A warning that the infrared connection is about to be terminated due to
insufficient power, so the application should close down infrared sessions
in an orderly fashion.public static final int POWER_ALERT_NETWORK_TERMINATION
POWER_ALERT
events.
A warning that the network connection is about to be terminated due to
insufficient power, so the application should close down the network
sessions in an orderly fashion.public static final java.lang.String BATTERY_LEVEL
Event
.
Indicates the amount of charge remaining in the battery
as a percent represented by int
values of 0 to 100
inclusive.
Implementations SHOULD map the native battery levels to an
aggregate percentile of all batteries in the device.
Only changes in battery level detectable by the implementation must
be reported.
If this is an argument to EventManager.getCurrent
, the call SHOULD return the
same value as a call to
PowerManager.getBatteryLevel()
.public static final java.lang.String POWER_STATE
Indicates the power state as an int
value.
Valid values are
POWER_STATE_OFF
,
POWER_STATE_SUSPEND
,
POWER_STATE_SLEEP
,
POWER_STATE_REGULATED_LOW_POWER
,
POWER_STATE_REGULATED_HIGH_POWER
, or
POWER_STATE_FULL_POWER
.
Events for each power state are delivered when the
system enters the state. The current power state can
be queried with PowerManager.getPowerState
.
public static final int POWER_STATE_FULL_POWER
POWER_STATE
events.
System is always running at its maximum possible performance for now.
Power management is disabled.public static final int POWER_STATE_OFF
POWER_STATE
events.
System is shutdown and is turned off. No memory state is saved. System
needs to be rebooted to a operational state.public static final int POWER_STATE_REGULATED_LOW_POWER
POWER_STATE
events.
System is operational but power consumption is regulated by power
management software. Regulation status is low, so power intensive
operations should be postponed if possible.public static final int POWER_STATE_REGULATED_HIGH_POWER
POWER_STATE
events.
System is operational but power consumption is regulated by power
management software. Regulation status is high, so power intensive
operations should be performed now.public static final int POWER_STATE_SLEEP
POWER_STATE
events.
System is not operational, memory state is saved in low latency persistent
storage that may require power. Minimal power may be used but the system
appears to be off. System can resume to its previous operational state in
a relatively short period of time.public static final int POWER_STATE_SUSPEND
POWER_STATE
events.
System is not operational, memory state is saved in high latency persistent
storage that do not require power. Power to the main system including CPU
and memory are removed. System takes longer period of time to resume to
its previous operational state.protected PowerStateEvent(int prevState, int newState, boolean urgent)
PowerStateEvent
object. Those objects are
generated by the run time system only.prevState
- the state at the time when the event object is creatednewState
- the state that the system is going to transit tourgent
- If urgent
is true
, it indicates
that objections to the state change event from the event listeners
will be ignored. Meaning that the PowerManagerException
(with error code KEEP_CURRENT_STATE
) sent by the
event listeners (normal applications) will be ignored, and the
state transition will occur.
If urgent
is false
, objections to the
current state change event will be attended. Meaning that the
PowerMangerException
(with error code
KEEP_CURRENT_STATE
) sent by the event listeners
(normal applications) will be serviced. It is recommended that
the state change may be aborted or delayed when there are
objections to the state change; however, actions take to service
the exception is implementation dependent. Note:
The value of urgent should reflect the value of the
urgent
parameter used in the
PowerManager.setPowerState()
method.public int getNewState()
PowerStateEvent
object. The new state is the value of
the Event
object.public int getPrevState()
PowerStateEvent
object. The previous state is the info of
the Event
object.public boolean isUrgent()
If the return is true
, the event source will ignore the
PowerManagerException
(with error code
KEEP_CURRENT_STATE
) thrown by the event listeners. State
transition will occur. If the return is false
, the event
source will response to the PowerManagerException
(with error
code KEEP_CURRENT_STATE
) thrown by the event listeners. The
kind of response to the exception is system dependent.
true
or false
Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. Use of this specification is subject to license terms.