public class RadioModule extends RadioTuner
RadioTuner.Callback
DIRECTION_DOWN, DIRECTION_UP, ERROR_CANCELLED, ERROR_CONFIG, ERROR_HARDWARE_FAILURE, ERROR_SCAN_TIMEOUT, ERROR_SERVER_DIED
Modifier and Type | Method and Description |
---|---|
int |
cancel()
Cancel a pending scan or tune operation.
|
void |
close()
Close the tuner interface.
|
protected void |
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
int |
getConfiguration(RadioManager.BandConfig[] config)
Get current configuration.
|
boolean |
getMute()
Get mute state.
|
int |
getProgramInformation(RadioManager.ProgramInfo[] info)
Get current station information.
|
boolean |
hasControl()
Indicates if this client actually controls the tuner.
|
boolean |
isAntennaConnected()
Get current antenna connection state for current configuration.
|
int |
scan(int direction,
boolean skipSubChannel)
Scan up or down to next valid station.
|
int |
setConfiguration(RadioManager.BandConfig config)
Set the active band configuration for this module.
|
int |
setMute(boolean mute)
Set mute state.
|
int |
step(int direction,
boolean skipSubChannel)
Step up or down by one channel spacing.
|
int |
tune(int channel,
int subChannel)
Tune to a specific frequency.
|
protected void finalize()
Object
finalize
method to dispose of
system resources or to perform other cleanup.
The general contract of finalize
is that it is invoked
if and when the JavaTM virtual
machine has determined that there is no longer any
means by which this object can be accessed by any thread that has
not yet died, except as a result of an action taken by the
finalization of some other object or class which is ready to be
finalized. The finalize
method may take any action, including
making this object available again to other threads; the usual purpose
of finalize
, however, is to perform cleanup actions before
the object is irrevocably discarded. For example, the finalize method
for an object that represents an input/output connection might perform
explicit I/O transactions to break the connection before the object is
permanently discarded.
The finalize
method of class Object
performs no
special action; it simply returns normally. Subclasses of
Object
may override this definition.
The Java programming language does not guarantee which thread will
invoke the finalize
method for any given object. It is
guaranteed, however, that the thread that invokes finalize will not
be holding any user-visible synchronization locks when finalize is
invoked. If an uncaught exception is thrown by the finalize method,
the exception is ignored and finalization of that object terminates.
After the finalize
method has been invoked for an object, no
further action is taken until the Java virtual machine has again
determined that there is no longer any means by which this object can
be accessed by any thread that has not yet died, including possible
actions by other objects or classes which are ready to be finalized,
at which point the object may be discarded.
The finalize
method is never invoked more than once by a Java
virtual machine for any given object.
Any exception thrown by the finalize
method causes
the finalization of this object to be halted, but is otherwise
ignored.
public void close()
RadioTuner
RadioTuner.Callback
callback will not be called
anymore and associated resources will be released.
Must be called when the tuner is not needed to make hardware resources available to others.close
in class RadioTuner
public int setConfiguration(RadioManager.BandConfig config)
RadioTuner
setConfiguration
in class RadioTuner
config
- The desired band configuration (FmBandConfig or AmBandConfig).RadioManager.STATUS_OK
in case of success, RadioManager.STATUS_ERROR
in case of unspecified error, RadioManager.STATUS_NO_INIT
if the native service cannot be reached, RadioManager.STATUS_BAD_VALUE
if parameters are invalid, RadioManager.STATUS_INVALID_OPERATION
if the call is out of sequence, RadioManager.STATUS_DEAD_OBJECT
if the binder transaction to the native
service fails, public int getConfiguration(RadioManager.BandConfig[] config)
RadioTuner
getConfiguration
in class RadioTuner
config
- a BandConfig array of lengh 1 where the configuration is returned.RadioManager.STATUS_OK
in case of success, RadioManager.STATUS_ERROR
in case of unspecified error, RadioManager.STATUS_NO_INIT
if the native service cannot be reached, RadioManager.STATUS_BAD_VALUE
if parameters are invalid, RadioManager.STATUS_INVALID_OPERATION
if the call is out of sequence, RadioManager.STATUS_DEAD_OBJECT
if the binder transaction to the native
service fails, public int setMute(boolean mute)
RadioTuner
setMute
in class RadioTuner
mute
- the requested mute state.RadioManager.STATUS_OK
in case of success, RadioManager.STATUS_ERROR
in case of unspecified error, RadioManager.STATUS_NO_INIT
if the native service cannot be reached, RadioManager.STATUS_INVALID_OPERATION
if the call is out of sequence, RadioManager.STATUS_DEAD_OBJECT
if the binder transaction to the native
service fails, public boolean getMute()
RadioTuner
getMute
in class RadioTuner
true
if the radio tuner audio source is muted or a problem occured
retrieving the mute state, false
otherwise.public int step(int direction, boolean skipSubChannel)
RadioTuner
RadioTuner.Callback
onProgramInfoChanged() will be called when step completes or
onError() when cancelled or timeout.step
in class RadioTuner
direction
- RadioTuner.DIRECTION_UP
or RadioTuner.DIRECTION_DOWN
.skipSubChannel
- indicates to skip sub channels when the configuration currently
selected supports sub channel (e.g HD Radio). N/A otherwise.RadioManager.STATUS_OK
in case of success, RadioManager.STATUS_ERROR
in case of unspecified error, RadioManager.STATUS_NO_INIT
if the native service cannot be reached, RadioManager.STATUS_BAD_VALUE
if parameters are invalid, RadioManager.STATUS_INVALID_OPERATION
if the call is out of sequence, RadioManager.STATUS_DEAD_OBJECT
if the binder transaction to the native
service fails, public int scan(int direction, boolean skipSubChannel)
RadioTuner
RadioTuner.Callback
onProgramInfoChanged() will be called when scan completes or
onError() when cancelled or timeout.scan
in class RadioTuner
direction
- RadioTuner.DIRECTION_UP
or RadioTuner.DIRECTION_DOWN
.skipSubChannel
- indicates to skip sub channels when the configuration currently
selected supports sub channel (e.g HD Radio). N/A otherwise.RadioManager.STATUS_OK
in case of success, RadioManager.STATUS_ERROR
in case of unspecified error, RadioManager.STATUS_NO_INIT
if the native service cannot be reached, RadioManager.STATUS_BAD_VALUE
if parameters are invalid, RadioManager.STATUS_INVALID_OPERATION
if the call is out of sequence, RadioManager.STATUS_DEAD_OBJECT
if the binder transaction to the native
service fails, public int tune(int channel, int subChannel)
RadioTuner
RadioTuner.Callback
onProgramInfoChanged() will be called when tune completes or
onError() when cancelled or timeout.tune
in class RadioTuner
channel
- the specific channel or frequency to tune to.subChannel
- the specific sub-channel to tune to. N/A if the selected configuration
does not support cub channels.RadioManager.STATUS_OK
in case of success, RadioManager.STATUS_ERROR
in case of unspecified error, RadioManager.STATUS_NO_INIT
if the native service cannot be reached, RadioManager.STATUS_BAD_VALUE
if parameters are invalid, RadioManager.STATUS_INVALID_OPERATION
if the call is out of sequence, RadioManager.STATUS_DEAD_OBJECT
if the binder transaction to the native
service fails, public int cancel()
RadioTuner
RadioTuner.Callback
onError() will be called with
RadioTuner.ERROR_CANCELLED
.cancel
in class RadioTuner
RadioManager.STATUS_OK
in case of success, RadioManager.STATUS_ERROR
in case of unspecified error, RadioManager.STATUS_NO_INIT
if the native service cannot be reached, RadioManager.STATUS_BAD_VALUE
if parameters are invalid, RadioManager.STATUS_INVALID_OPERATION
if the call is out of sequence, RadioManager.STATUS_DEAD_OBJECT
if the binder transaction to the native
service fails, public int getProgramInformation(RadioManager.ProgramInfo[] info)
RadioTuner
getProgramInformation
in class RadioTuner
info
- a ProgramInfo array of lengh 1 where the information is returned.RadioManager.STATUS_OK
in case of success, RadioManager.STATUS_ERROR
in case of unspecified error, RadioManager.STATUS_NO_INIT
if the native service cannot be reached, RadioManager.STATUS_BAD_VALUE
if parameters are invalid, RadioManager.STATUS_INVALID_OPERATION
if the call is out of sequence, RadioManager.STATUS_DEAD_OBJECT
if the binder transaction to the native
service fails, public boolean isAntennaConnected()
RadioTuner
isAntennaConnected
in class RadioTuner
true
if the antenna is connected, false
otherwise.public boolean hasControl()
RadioTuner
RadioManager#openTuner(int,
RadioManager.BandConfig, boolean, Callback, Handler)
returns a non null tuner interface.
Control is lost when another client opens an interface on the same tuner.
When this happens, RadioTuner.Callback.onControlChanged(boolean)
is received.
The client can either wait for control to be returned (which is indicated by the same
callback) or close and reopen the tuner interface.hasControl
in class RadioTuner
true
if this interface controls the tuner,
false
otherwise or if a problem occured retrieving the state.