public static interface PowerManaged.Group
Group
interface provides methods for registering for power state changes of devices belonging
to the same power management group. Devices currently open by an application belong to the same power management group when their power managements
are logically or physically dependent. For example, different GPIO pins may be controlled by the same GPIO controller
and their power managements are physically dependent: when a power state change is requested on one pin it results in
applications that have open any of the other pins to be notified of that power state change request, including
the requesting application. Registering for power state change request notifications on a power management group
rather than on individual devices belonging to that group allows for being notified only once for each
of the devices opened by the application belonging to that group. If an
application has registered for both notifications on an individual device belonging to a group and for notifications
on that same group notifications will happen on all registered handlers. Notification on the group happens last.
Note that devices belonging to the same group may not necessarily be of the same type.
When all the Device
instances open by an application and belonging to the same power management group
have been closed the Group
instance corresponding to that group enters an irreversible closed
state:
power state changes are no longer notified on that Group
.
A compliant implementation MUST guarantee the thread-safety of Group
instances.Modifier and Type | Method and Description |
---|---|
boolean |
contains(PowerManaged device)
Check whether the provided
Device is part of this group. |
void |
setPowerSavingHandler(PowerSavingHandler handler)
Registers a
PowerSavingHandler instance to get asynchronously notified when the power management
facility is about to change the power state of this group, hence allowing the application to veto the power
state change. |
void setPowerSavingHandler(PowerSavingHandler handler) throws java.io.IOException, ClosedDeviceException
PowerSavingHandler
instance to get asynchronously notified when the power management
facility is about to change the power state of this group, hence allowing the application to veto the power
state change.
If handler
is null
then the previously registered PowerSavingHandler
is unregistered.handler
- the PowerSavingHandler
instance to be notified when a power state change is requested
for this group.java.lang.IllegalStateException
- if handler
is not null
and a PowerSavingHandler
is
already registered.java.lang.SecurityException
- if the caller does not have the required permission.ClosedDeviceException
- if this Group
is closed; that is all the devices belonging to this Group
have been closed.java.io.IOException
- if some other I/O error occurs.boolean contains(PowerManaged device) throws java.io.IOException, ClosedDeviceException
Device
is part of this group. To be part of a group
the Device
must be open. As soon as a Device
is closed it is removed
from the group.device
- the device to be checked.true
if the provided Device
is part of this group; false
otherwise.java.lang.NullPointerException
- if device
is null
.java.lang.SecurityException
- if the caller does not have the required permission.ClosedDeviceException
- if this Group
is closed; that is all the devices belonging to this Group
have been closed.java.io.IOException
- if some other I/O error occurs.Copyright © 2012, 2014, Oracle and/or its affiliates. All rights reserved.
Legal Notices