See: Description
Interface | Description |
---|---|
PowerManaged |
The
PowerManaged interface provides methods that a Peripheral class may implement to control how the
underlying peripheral hardware resource is managed by the power management facility of the device. |
PowerSavingHandler |
The
PowerSavingHandler interface defines methods for getting notified of power state change requests on a
specific Peripheral instance. |
Peripheral
implementing class may implement the
PowerManaged
interface if the underlying peripheral device supports some form
of power management and saving states that can be mapped to the states defined by this API.
The following sample code gives an examples of using the power saving/management API: class SignalLevelMonitor implements MonitoringListener, PowerSavingHandler { private ADCChannel channel = null; private boolean inRange = false; public void start(int channelID, int low, int high) throws IOException, PeripheralNotAvailableException, PeripheralNotFoundException { channel = (ADCChannel) PeripheralManager.open(channelID); channel.setSamplingInterval(1000); // every 1 seconds channel.startMonitoring(low, high, this); if (channel instanceof PowerManaged) { ((PowerManaged) channel).enablePowerSaving(LOW_POWER, this); // Only enable LOW_POWER saving mode (POWER_ON is implicit) } } public void thresholdReached(MonitoringEvent event) { inRange = (event.getType() == MonitoringEvent.BACK_TO_RANGE); } public long handlePowerStateChangeRequest(Peripheral peripheral, int currentState, int requestedState, long duration) { if (requestedState == PowerManaged.LOW_POWER) { return inRange ? duration : 0; // Only accept to change to LOW_POWER if signal is back in range } return duration; // Accept returning to POWER_ON } public void stop() throws IOException, PeripheralNotAvailableException { if (channel != null) { channel.stopMonitoring(); if (channel instanceof PowerManaged) { ((PowerManaged) channel).disablePowerSaving(); } channel.close(); } } }
com.oracle.deviceaccess.PeripheralManager.open
methods.
The "com.oracle.deviceaccess.power"
permission allows access to be granted to peripheral power management.Copyright (c) 1990, 2013, Oracle and/or its affiliates. All rights reserved.