Skip to content
com.iristick.smartglass.core

Interface DisplayListener


public interface DisplayListener

Listener interface for receiving updates about the state of the display.

An instance must be provided to the Headset.openDisplay method to open the display.

The state updates include notifications about the display completing startup, about display disconnection or closure, and about unexpected errors.

See Also:
Headset.openDisplay(DisplayListener, Handler)

Field Summary

Modifier and Type Field and Description
static int CLOSE_REASON_BUSY
A code that can be reported by onDisplayClosed(int) indicating that the display is in use by a higher-priority API client.
static int CLOSE_REASON_DEVICE_ERROR
A code that can be reported by onDisplayClosed(int) indicating that the display has encountered a fatal error.
static int CLOSE_REASON_DISCONNECTED
A code that can be reported by onDisplayClosed(int) indicating that the display was closed because the headset was disconnected.
static int CLOSE_REASON_REQUESTED
A code that can be reported by onDisplayClosed(int) indicating that the display was closed by invoking Headset.closeDisplay().
static int CLOSE_REASON_SERVICE_ERROR
A code that can be reported by onDisplayClosed(int) indicating that the display service has encountered a fatal error.

Method Summary

Modifier and Type Method and Description
void onDisplayClosed(int reason)
Called when the display has been completely closed.
void onDisplayOpened(Display display)
Called when the display has finished opening.
void onDisplaySurfaceOpened(Surface surface, int width, int height, int density)
Called when the display has finished opening.

Field Detail

CLOSE_REASON_REQUESTED

static final int CLOSE_REASON_REQUESTED

A code that can be reported by onDisplayClosed(int) indicating that the display was closed by invoking Headset.closeDisplay().

See Also:
onDisplayClosed(int)

CLOSE_REASON_DISCONNECTED

static final int CLOSE_REASON_DISCONNECTED

A code that can be reported by onDisplayClosed(int) indicating that the display was closed because the headset was disconnected.

See Also:
onDisplayClosed(int)

CLOSE_REASON_BUSY

static final int CLOSE_REASON_BUSY

A code that can be reported by onDisplayClosed(int) indicating that the display is in use by a higher-priority API client.

This code can be produced when opening the display fails, or when the display gets automatically closed because a higher-priority API client requested the display.

See Also:
onDisplayClosed(int)

CLOSE_REASON_DEVICE_ERROR

static final int CLOSE_REASON_DEVICE_ERROR

A code that can be reported by onDisplayClosed(int) indicating that the display has encountered a fatal error.

The display needs to be re-opened to be used again.

See Also:
onDisplayClosed(int)

CLOSE_REASON_SERVICE_ERROR

static final int CLOSE_REASON_SERVICE_ERROR

A code that can be reported by onDisplayClosed(int) indicating that the display service has encountered a fatal error.

The headset may need to be unplugged and replugged, and the Iristick service forcefully stopped and restarted, to restore display function, or there may be a persistent hardware problem.

An attempt at recovery may be possible by unbinding from the service, and trying to acquire all resources again from scratch.

See Also:
onDisplayClosed(int)

Method Detail

onDisplayOpened

void onDisplayOpened(@NonNull
                     Display display)

Called when the display has finished opening.

At this point, the display is ready to use, and content can be pushed to it, e.g., through the Presentation class.

Parameters:
display - The display that has become opened.
See Also:
Headset.openDisplay(DisplayListener, Handler)

onDisplaySurfaceOpened

void onDisplaySurfaceOpened(@NonNull
                            Surface surface,
                            int width,
                            int height,
                            int density)

Called when the display has finished opening.

At this point, the display is ready to use, and content can be drawn on to it, e.g., by calling Surface.lockCanvas(Rect).

Parameters:
surface - Surface on which to draw to push content on the display.
width - Width of the display in pixels.
height - Height of the display in pixels.
density - Suggested display density in dots per inch.
See Also:
Headset.openDisplaySurface(DisplayListener, Handler)

onDisplayClosed

void onDisplayClosed(int reason)

Called when the display has been completely closed.

This can happen either because the display has been closed explicitly with Headset.closeDisplay(), or because a higher-priority process requests the display, or because the headset was disconnected or encountered a fatal error.

This callback may also be called instead of onDisplayOpened if an error occurred while opening the display.

No further callbacks of this interface will be invoked after this method is done.

Parameters:
reason - The reason for closing the display, one of the CLOSE_REASON_* values.
See Also:
CLOSE_REASON_REQUESTED, CLOSE_REASON_DISCONNECTED, CLOSE_REASON_BUSY, CLOSE_REASON_DEVICE_ERROR, CLOSE_REASON_SERVICE_ERROR