Class Headset¶
- java.lang.Object
-
- com.iristick.smartglass.core.Headset
public abstract class Headset extends Object
This class provides access to all extended functionality available on one headset.
Nested Class Summary¶
Modifier and Type | Class and Description |
---|---|
static interface |
Headset.InteractionModeListener |
Field Summary¶
Modifier and Type | Field and Description |
---|---|
static int |
INTERACTION_MODE_HUD
The pocket unit is inside its pouch.
|
static int |
INTERACTION_MODE_PHONE
The pocket unit is outside its pouch.
|
static int |
TOUCHPAD_FLAG_INHIBIT_UI_OPTIMIZATION
Flag for
registerTouchEventCallback(TouchEvent.Callback, Handler, int) to
disable automatic UI optimizations when the user touches the touchpad. |
static int |
TOUCHPAD_FLAG_OVERRIDE_ALL
Flag for
registerTouchEventCallback(TouchEvent.Callback, Handler, int) to
disable any standard behavior of the touchpad. |
static int |
TOUCHPAD_FLAG_OVERRIDE_NAVIGATION
Flag for
registerTouchEventCallback(TouchEvent.Callback, Handler, int) to
disable the standard navigation system. |
static int |
VOICE_FLAG_INHIBIT_COMMAND_DISCOVERY
Flag for
configureVoiceCommands(int) to disable the interaction system
from automatically discovering voice commands. |
static int |
VOICE_FLAG_INHIBIT_DISPLAY_SUSPEND
Flag for
configureVoiceCommands(int) to disable the voice command for the
"Iristick suspend" action. |
static int |
VOICE_FLAG_INHIBIT_DISPLAY_WAKEUP
Flag for
configureVoiceCommands(int) to disable the voice command for the
"Iristick wake up" action. |
static int |
VOICE_FLAG_INHIBIT_GO_BACK
Flag for
configureVoiceCommands(int) to disable the voice command for
the "go back" action. |
static int |
VOICE_FLAG_INHIBIT_UI_OPTIMIZATION
Flag for
configureVoiceCommands(int) to
disable automatic UI optimizations when the user uses voice commands. |
static int |
VOICE_FLAG_INHIBIT_VISUAL_FEEDBACK
Flag for
configureVoiceCommands(int) to disable the visual feedback. |
Constructor Summary¶
Constructor and Description |
---|
Headset() |
Method Summary¶
Modifier and Type | Method and Description |
---|---|
abstract void |
closeDisplay()
Close the connection to the display.
|
abstract void |
configureVoiceCommands(int flags)
Configures the voice commands of the interaction system provided by the Iristick Services.
|
abstract String |
findCamera(int type)
Find a camera with a specific type tag.
|
abstract CameraCharacteristics |
getCameraCharacteristics(String cameraId)
Queries the capabilities of a camera.
|
abstract String[] |
getCameraIdList()
Returns the list of currently connected camera devices by identifier, including
cameras that may be in use by other camera API clients.
|
Sensor |
getDefaultSensor(int type)
Gets the default sensor for a given type.
|
abstract int |
getInteractionMode()
Get the current interaction mode with this headset.
|
abstract List<Sensor> |
getSensorList(int type)
Gets the list of available sensors of a certain type.
|
abstract String |
getSerialNumber()
Get the serial number of this headset.
|
abstract void |
openCamera(String cameraId,
CameraDevice.Listener listener,
Handler handler)
Opens a connection to a camera with the given ID.
|
abstract void |
openDisplay(DisplayListener listener,
Handler handler)
Open a connection to the display.
|
abstract void |
openDisplaySurface(DisplayListener listener,
Handler handler)
Open a connection to the display.
|
abstract void |
registerInteractionModeListener(Headset.InteractionModeListener listener,
Handler handler)
Register a listener for interaction mode changes.
|
boolean |
registerSensorListener(SensorEventListener listener,
Sensor sensor,
int rateUs,
Handler handler)
Registers a listener for a sensor.
|
void |
registerTouchEventCallback(TouchEvent.Callback callback,
Handler handler)
Registers a callback for touchpad events.
|
abstract void |
registerTouchEventCallback(TouchEvent.Callback callback,
Handler handler,
int flags)
Registers a callback for touchpad events.
|
abstract boolean |
registerVoiceCommands(String[] commands,
VoiceEvent.Callback callback,
Handler handler)
Deprecated.
Use
startVoice(VoiceGrammar) with a VoiceCommandDispatcher instead. |
abstract void |
setLaserPointer(boolean enable)
Set the headset's laser pointer.
|
abstract void |
setTorchMode(boolean enable)
Set the flash unit's torch mode.
|
abstract boolean |
startVoice(VoiceGrammar grammar)
Starts listening for voice commands for the given grammar.
|
abstract void |
stopVoice(VoiceGrammar grammar)
Stop listening for voice commands for the given grammar.
|
abstract void |
stopVoiceAll()
Stop listening for voice commands for every currently still active grammar.
|
abstract void |
unregisterInteractionModeListener(Headset.InteractionModeListener listener)
Unregister an interaction mode listener.
|
abstract void |
unregisterSensorListener(SensorEventListener listener)
Unregisters a listener for all sensors.
|
abstract void |
unregisterTouchEventCallback(TouchEvent.Callback callback)
Unregisters a callback for touchpad events.
|
abstract void |
unregisterVoiceCommands(VoiceEvent.Callback callback)
Deprecated.
Use
stopVoice(VoiceGrammar) with a VoiceCommandDispatcher instead. |
Methods inherited from class java.lang.Object¶
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail¶
INTERACTION_MODE_PHONE¶
public static final int INTERACTION_MODE_PHONE
The pocket unit is outside its pouch. Interaction is primary done on the phone screen.
INTERACTION_MODE_HUD¶
public static final int INTERACTION_MODE_HUD
The pocket unit is inside its pouch. The user does not see the phone screen, hence interaction only happens through the heads-up display.
TOUCHPAD_FLAG_OVERRIDE_NAVIGATION¶
public static final int TOUCHPAD_FLAG_OVERRIDE_NAVIGATION
Flag for registerTouchEventCallback(TouchEvent.Callback, Handler, int)
to
disable the standard navigation system. You will probably want to set this flag,
as the navigation system would otherwise interfere with your handling of the touch events.
Note that the swipe down gesture is still handled by the Iristick Services and will
trigger a "go back" action, as if the user pressed the "back" button in the navigation bar.
Use the TOUCHPAD_FLAG_OVERRIDE_ALL
flag if you do not want that.
Note
This flag does not automatically disable the voice commands of the
navigation system. See configureVoiceCommands(int)
for more information.
TOUCHPAD_FLAG_INHIBIT_UI_OPTIMIZATION¶
public static final int TOUCHPAD_FLAG_INHIBIT_UI_OPTIMIZATION
Flag for registerTouchEventCallback(TouchEvent.Callback, Handler, int)
to
disable automatic UI optimizations when the user touches the touchpad.
Note that the standard navigation system itself is still enabled. Use the
TOUCHPAD_FLAG_OVERRIDE_NAVIGATION
if you do not want that.
Note
This does not influence the voice-based behavior of the UI
optimizations. See configureVoiceCommands(int)
for more information.
TOUCHPAD_FLAG_OVERRIDE_ALL¶
public static final int TOUCHPAD_FLAG_OVERRIDE_ALL
Flag for registerTouchEventCallback(TouchEvent.Callback, Handler, int)
to
disable any standard behavior of the touchpad. This effectively pauses the standard
navigation system, including the swipe down gesture. Use this flag if you want full
control over the touchpad in your app.
Implies TOUCHPAD_FLAG_OVERRIDE_NAVIGATION
and TOUCHPAD_FLAG_INHIBIT_UI_OPTIMIZATION
.
Note
This flag does not automatically disable the voice commands of the
navigation system. See configureVoiceCommands(int)
for more information.
VOICE_FLAG_INHIBIT_COMMAND_DISCOVERY¶
public static final int VOICE_FLAG_INHIBIT_COMMAND_DISCOVERY
Flag for configureVoiceCommands(int)
to disable the interaction system
from automatically discovering voice commands.
The interaction system can discover voice commands depending on your currently visible views. This includes commands for buttons, checkboxes and other interactive views.
Note that the voice command for the "go back" action is still handled by the Iristick
Services. Use the VOICE_FLAG_INHIBIT_GO_BACK
flag if you want this action disabled
as well.
Note
This does not influence the touchpad-based behavior of the
interaction system. See registerTouchEventCallback(TouchEvent.Callback, Handler, int)
for more information.
VOICE_FLAG_INHIBIT_GO_BACK¶
public static final int VOICE_FLAG_INHIBIT_GO_BACK
Flag for configureVoiceCommands(int)
to disable the voice command for
the "go back" action.
Note
This does not influence the touchpad-based behavior of the
interaction system.
See registerTouchEventCallback(TouchEvent.Callback, Handler, int)
for more
information.
VOICE_FLAG_INHIBIT_VISUAL_FEEDBACK¶
public static final int VOICE_FLAG_INHIBIT_VISUAL_FEEDBACK
Flag for configureVoiceCommands(int)
to disable the visual feedback.
VOICE_FLAG_INHIBIT_UI_OPTIMIZATION¶
public static final int VOICE_FLAG_INHIBIT_UI_OPTIMIZATION
Flag for configureVoiceCommands(int)
to
disable automatic UI optimizations when the user uses voice commands.
Note that the standard navigation system itself is still enabled. Use the
VOICE_FLAG_INHIBIT_COMMAND_DISCOVERY
if you do not want that.
Note
This does not influence the touchpad-based behavior of the UI
optimizations.
See registerTouchEventCallback(TouchEvent.Callback, Handler, int)
for more
information.
VOICE_FLAG_INHIBIT_DISPLAY_SUSPEND¶
public static final int VOICE_FLAG_INHIBIT_DISPLAY_SUSPEND
Flag for configureVoiceCommands(int)
to disable the voice command for the
"Iristick suspend" action. This action will turn off the display and put the phone in sleep
mode, as if the user had pressed the power button.
If set, the user will no longer be able to turn off the display through a voice command.
Note
You will likely want to set this together with
VOICE_FLAG_INHIBIT_DISPLAY_WAKEUP
.
VOICE_FLAG_INHIBIT_DISPLAY_WAKEUP¶
public static final int VOICE_FLAG_INHIBIT_DISPLAY_WAKEUP
Flag for configureVoiceCommands(int)
to disable the voice command for the
"Iristick wake up" action. This action will take the phone out of sleep mode, re-enable
the display and unlock the screen lock.
If set, the user will no longer be able to turn on the display through a voice command. The user can still unlock their phone with the touchpad.
Note
Voice commands can not unlock secure screen locks (e.g. PIN number or password). These screen locks must be unlocked with the touchpad of the Iristick smart glasses or with the phone.
Note
You will likely want to set this together with
VOICE_FLAG_INHIBIT_DISPLAY_SUSPEND
.
Constructor Detail¶
Headset¶
public Headset()
Method Detail¶
getSerialNumber¶
@CheckResult @NonNull public abstract String getSerialNumber()
- Returns:
- The serial number.
- Since:
- 1.1
getInteractionMode¶
@CheckResult public abstract int getInteractionMode()
Get the current interaction mode with this headset.
- Returns:
- The current interaction mode.
registerInteractionModeListener¶
public abstract void registerInteractionModeListener(@NonNull Headset.InteractionModeListener listener, @Nullable Handler handler)
Register a listener for interaction mode changes.
- Parameters:
listener
- The listener which is invoked when interaction mode changes.handler
- The handler on which the listener should be invoked, ornull
to use the current thread'slooper
.
unregisterInteractionModeListener¶
public abstract void unregisterInteractionModeListener(@NonNull Headset.InteractionModeListener listener)
Unregister an interaction mode listener.
- Parameters:
listener
- The listener to unregister.
openDisplay¶
public abstract void openDisplay(@NonNull DisplayListener listener, @Nullable Handler handler)
Open a connection to the display.
Once the display is successfully opened, DisplayListener.onDisplayOpened(Display)
will be invoked with the newly opened Display
. Standard UI may then be shown by
extending the Presentation
class.
If you do not need to show standard UI elements, but instead want to draw directly to
the display, consider calling openDisplaySurface()
instead.
If opening the display fails for any reason, then the listener's
onDisplayClosed
method will be called instead of
onDisplayOpened
.
Note
This method must not be called again until onDisplayClosed()
or closeDisplay()
has been called.
It is also mutually exclusive with openDisplaySurface()
.
Note
While the display is opened, the interaction system provided by the Iristick Services is disabled. Likewise, automatically discovered voice commands are disabled as well. Interactions that trigger the "go back" action are not disabled.
- Parameters:
listener
- The listener which is invoked once the display is opened.handler
- The handler on which the listener should be invoked, ornull
to use the current thread'slooper
.- Since:
- Android API level 19
- See Also:
openDisplaySurface(DisplayListener, Handler)
openDisplaySurface¶
public abstract void openDisplaySurface(@NonNull DisplayListener listener, @Nullable Handler handler)
Open a connection to the display.
Unlike openDisplay()
, this method provides a
Surface
to draw content on the screen, instead of a Display
object.
Once the display is successfully opened,
DisplayListener.onDisplaySurfaceOpened(Surface, int, int, int)
will be invoked with the newly opened Surface
. A canvas for drawing on the display
may be obtained with lockCanvas()
.
If opening the display fails for any reason, then the listener's
onDisplayClosed
method will be called instead of
onDisplayOpened
.
Note
This method must not be called again until onDisplayClosed()
or closeDisplay()
has been called.
It is also mutually exclusive with openDisplay()
.
Note
While the display is opened, the interaction system provided by the Iristick Services is disabled. Likewise, automatically discovered voice commands are disabled as well. Interactions that trigger the "go back" action are not disabled.
- Parameters:
listener
- The listener which is invoked once the display is opened.handler
- The handler on which the listener should be invoked, ornull
to use the current thread'slooper
.- See Also:
openDisplay(DisplayListener, Handler)
closeDisplay¶
public abstract void closeDisplay()
Close the connection to the display.
Once the display has fully shut down, the DisplayListener.onDisplayClosed(int)
callback
will be called. The display may however be re-opened right after a call to
closeDisplay()
without having to wait for the onDisplayClosed()
callback.
Calling this method multiple times, or when the display is already closed, does not have any effect.
getCameraIdList¶
@CheckResult @NonNull public abstract String[] getCameraIdList()
Returns the list of currently connected camera devices by identifier, including cameras that may be in use by other camera API clients.
Attention
The returned identifiers are not part of the stable API.
They may vary across versions of the Iristick Services, device models or even Headset
objects. You should always discover the camera identifiers of a connected headset using this
method or findCamera(int)
.
- Returns:
- The list of currently connected cameras.
- See Also:
findCamera(int)
findCamera¶
@CheckResult @Nullable public abstract String findCamera(int type)
If multiple cameras are available with the type
tag, one of them will be returned.
Attention
The returned identifier is not part of the stable API.
It may vary across versions of the Iristick Services, device models or even Headset
objects. You should always discover the camera identifiers of a connected headset using this
method or getCameraIdList()
.
- Parameters:
type
- The desired camera type (one of theTYPE_*
constants inCameraCharacteristics
).- Returns:
- The id of the camera or
null
if no camera of the desired type is available on this headset. - Since:
- 1.2
- See Also:
CameraCharacteristics.TYPES
getCameraCharacteristics¶
@CheckResult @NonNull public abstract CameraCharacteristics getCameraCharacteristics(@NonNull String cameraId)
Queries the capabilities of a camera. These capabilities are immutable for a given camera.
- Parameters:
cameraId
- The id of the camera to query.- Returns:
- The properties of the given camera.
- Throws:
IllegalArgumentException
- ifcameraId
does not match any known camera.- See Also:
getCameraIdList()
openCamera¶
public abstract void openCamera(@NonNull String cameraId, @NonNull CameraDevice.Listener listener, @Nullable Handler handler)
Opens a connection to a camera with the given ID.
Use findCamera(int)
or getCameraIdList()
to find available camera devices.
Note that even if an id is listed, open may fail if the headset
is disconnected between the calls to findCamera
/getCameraIdList
and
openCamera
.
Once the camera is successfully opened, CameraDevice.Listener#onOpened(CameraDevice)
will
be invoked with the newly opened CameraDevice
. The camera can then be set up
for operation by calling createCaptureSession
.
If the headset becomes disconnected during initialization
after this function call returns,
onDisconnected
will be called with a
CameraDevice
object in the disconnected state (and
onOpened
will be skipped).
If opening the camera fails for any other reason, then the camera listener's
onError
method will be called instead of onOpened
.
Requires the CAMERA
permission.
Attention
Camera identifiers are not part of the stable API.
They may vary across versions of the Iristick Services, device models or even Headset
objects. You should always discover the camera identifiers of a connected headset using
#findCamera
or #getCameraIdList
.
- Parameters:
cameraId
- The unique identifier of the camera device to open.listener
- The listener which is invoked once the camera is opened.handler
- The handler on which the listener should be invoked, ornull
to use the current thread'slooper
.- Throws:
NullPointerException
- ifcameraId
orlistener
isnull
.IllegalArgumentException
- ifcameraId
does not match any available camera.SecurityException
- if the application does not have permission to access the camera.- See Also:
findCamera(int)
,getCameraIdList()
setTorchMode¶
public abstract void setTorchMode(boolean enable)
Note that the application does not have the exclusive ownership of the flash unit.
Other applications are free to call setTorchMode
to turn the torch mode on or off.
If the latest application that turned on the torch mode exits, the torch mode will be
turned off.
- Parameters:
enable
- The desired state of the torch mode. Set totrue
to turn on the torch mode. Set tofalse
to turn off the torch mode.
setLaserPointer¶
public abstract void setLaserPointer(boolean enable)
Note that the application does not have the exclusive ownership of the laser unit.
Other applications are free to call setLaserPointer
to turn the laser mode on or off.
If the latest application that turned on the laser pointer exits, the laser pointer will be
turned off.
- Parameters:
enable
- The desired state of the laser pointer. Set totrue
to turn on the laser pointer. Set tofalse
to turn off the laser pointer.
getDefaultSensor¶
@CheckResult @Nullable public Sensor getDefaultSensor(int type)
Gets the default sensor for a given type.
- Parameters:
type
- Type of sensor requested (seeTYPE_*
constants inSensor
).- Returns:
- The default sensor matching the requested type if one exists, or
null
otherwise.
getSensorList¶
@CheckResult @NonNull public abstract List<Sensor> getSensorList(int type)
Gets the list of available sensors of a certain type.
Make multiple calls to get sensors of different types or use Sensor.TYPE_ALL
to get all sensors.
- Parameters:
type
- Type of sensors requested (seeTYPE_*
constants inSensor
).- Returns:
- A list of sensors matching the requested type.
registerSensorListener¶
public boolean registerSensorListener(@NonNull SensorEventListener listener, @NonNull Sensor sensor, int rateUs, @Nullable Handler handler)
Registers a listener for a sensor. Events are delivered in continuous mode as soon as they are available.
Calling this method is equivalent to calling
sensor.registerListener(listener, rateUs, handler)
- Parameters:
listener
- The listener.sensor
- The target sensor.rateUs
- The rate sensor events are delivered at. This is only a hint to the system. Events may be received faster or slower than the specified rate. Usually, events are received faster. The rate is specified in microseconds.handler
- The handler on which the listener should be invoked, ornull
to use the current thread'slooper
.- Returns:
true
if the sensor has been successfully enabled.- See Also:
Sensor.registerListener(SensorEventListener, int, Handler)
unregisterSensorListener¶
public abstract void unregisterSensorListener(@NonNull SensorEventListener listener)
Unregisters a listener for all sensors.
- Parameters:
listener
- The listener to unregister.
registerTouchEventCallback¶
public abstract void registerTouchEventCallback(@NonNull TouchEvent.Callback callback, @Nullable Handler handler, int flags)
Registers a callback for touchpad events.
- Parameters:
callback
- The callback to register.handler
- The handler on which the listener should be invoked, ornull
to use the current thread'slooper
.flags
- Combination of flag values to modify the standard touchpad behavior.- See Also:
TOUCHPAD_FLAG_OVERRIDE_NAVIGATION
,TOUCHPAD_FLAG_OVERRIDE_ALL
registerTouchEventCallback¶
public void registerTouchEventCallback(@NonNull TouchEvent.Callback callback, @Nullable Handler handler)
Registers a callback for touchpad events.
The navigation system provided by the Iristick Services will be paused while the
callback is registered, except for the swipe down gesture which will trigger a "back" action.
Use registerTouchEventCallback(TouchEvent.Callback, Handler, int)
to customize this
behavior.
- Parameters:
callback
- The callback to register.handler
- The handler on which the listener should be invoked, ornull
to use the current thread'slooper
.
unregisterTouchEventCallback¶
public abstract void unregisterTouchEventCallback(@NonNull TouchEvent.Callback callback)
Unregisters a callback for touchpad events.
- Parameters:
callback
- The callback to unregister.
configureVoiceCommands¶
public abstract void configureVoiceCommands(int flags)
Configures the voice commands of the interaction system provided by the Iristick Services.
- Parameters:
flags
- Combination of flag values to modify the standard voice interaction behavior.- See Also:
VOICE_FLAG_INHIBIT_COMMAND_DISCOVERY
,VOICE_FLAG_INHIBIT_GO_BACK
,VOICE_FLAG_INHIBIT_VISUAL_FEEDBACK
registerVoiceCommands¶
@Deprecated public abstract boolean registerVoiceCommands(@NonNull String[] commands, @NonNull VoiceEvent.Callback callback, @Nullable Handler handler)
startVoice(VoiceGrammar)
with a VoiceCommandDispatcher
instead.Registers a callback for voice commands.
The commands are assumed to be in the current locale if supported by the voice recognition engine or English otherwise. Special characters, such as punctuation, are ignored. One command may consist of multiple words, separated by spaces.
When multiple callback are registered for the same voice command(s), they are all notified when the user utters that voice command.
When the same callback is registered again with a different set of commands, the new commands overwrite the previous commands.
To preserve resources, it is recommended to register as few callbacks as possible and to group commands together if they do not need to be disabled separately.
- Parameters:
commands
- A list of commands for the voice recognition service to recognize.callback
- The callback to register.handler
- The handler on which the listener should be invoked, ornull
to use the current thread'slooper
.- Returns:
true
if the callback registration was successful,false
otherwise.- Throws:
NullPointerException
- ifcommands
orcallback
isnull
.IllegalArgumentException
- ifcommands
is empty or contains no valid commands.OutOfMemoryError
- if the callback could not be registered due to exhausted resources.
unregisterVoiceCommands¶
@Deprecated public abstract void unregisterVoiceCommands(@NonNull VoiceEvent.Callback callback)
stopVoice(VoiceGrammar)
with a VoiceCommandDispatcher
instead.Unregisters a callback for voice commands.
- Parameters:
callback
- The callback to unregister.
startVoice¶
public abstract boolean startVoice(@NonNull VoiceGrammar grammar)
This operation is a no-op if the grammar is already in use for voice recognition by this headset.
- Parameters:
grammar
- The grammar for the voice recognition engine to recognize.- Returns:
true
if the callback registration was successful,false
otherwise.- Throws:
NullPointerException
- ifgrammar
isnull
.IllegalStateException
- if the grammar is invalid.IllegalStateException
- if the grammar is alreadyreleased
.- See Also:
stopVoice(VoiceGrammar)
,stopVoiceAll()
stopVoice¶
public abstract void stopVoice(@NonNull VoiceGrammar grammar)
- Parameters:
grammar
- The grammar to stop listening for.- See Also:
startVoice(VoiceGrammar)
,stopVoiceAll()
stopVoiceAll¶
public abstract void stopVoiceAll()
- See Also:
startVoice(VoiceGrammar)
,stopVoice(VoiceGrammar)