SmartEyeglass SDK public class

SmartEyeglassControlUtils

extends BroadcastReceiver
  1. java.lang.Object
  2. BroadcastReceiver
  3. com.sony.smarteyeglass.extension.util.SmartEyeglassControlUtils

Class Overview

This class provides the methods that you use to handle most SmartEyeglass-specific functionality. The API provides these features:

Use of these methods requires the "com.sony.smarteyeglass.permission.SMARTEYEGLASS" permission in the app's Android manifest. Camera and voice-to-text intents require additional specific permissions as noted.

Camera control

The Camera API provides access to two camera functions:

  • Picture : Take and store a still image
  • JPG Stream : Get JPEG stream data for image recognition

Your camera control app starts and stops camera operation in one of these modes. In JPEG stream mode, image capture begins automatically and continues until camera function is terminated. To capture a still image, you call requestCameraCapture() after starting the camera.

Audio control

SmartEyeglass hardware includes a microphone on the controller that can be used for voice input that is automatically translated to text. To initiate the asynchronous voice input operation, call enableVoiceTextInput(). Provide a handler for the result that is passed back upon completion of the operation. See onVoiceTextInput.

The SmartEyeglass is also a Bluetooth headset, and you can use the microphone and speaker for host-phone audio functions, including sound recording and playback, and telephony. In general, these functions use the standard Android BT HFP API. This class provides a method to query the current telephony status, requestTelephonyFunctionStatus().

Built-in UI utilites

Utilities that help you create a UI for your app include built-in animation effects for layer transitions, and predefined configurable dialogs.

The dialog methods make it easy to define and display a dialog with a message and optional choice buttons. Provide a handler for the result that is passed back to your app when the user dismisses the dialog, or it times out. See onDialogClosed.

Configuration options

You can enable and disable various configuration options for the SmartEyeglass, including:

  • Power modes (low/high power consumption and standby)
  • Safe display mode
  • Screen depth
  • Sound effects for button-press feedback


User input event handling

Users can tap or swipe(left/right) on the touch pad, or press the Back key on the controller. You can override the handlers for these events that are part of the Smart Extension APIs in the Sony Add-on SDK package .

Permissions

Your app's Android manifest must declare this permissions to use SmartEyeglass features:

com.sony.smarteyeglass.permission.SMARTEYEGLASS

In addition, to use the camera and voice-to-text input features, you must request additional permissions:

  • com.sony.smarteyeglass.permission.CAMERA
  • com.sony.smarteyeglass.permission.VOICE_TEXT_INPUT

For example, to use the camera functions, include this element in the Android manifest:

<uses-permission android:name="com.sony.smarteyeglass.permission.CAMERA"/>

Summary

Nested Classes
class SmartEyeglassControlUtils.PointInWorldCoordinate Defines a point in the real-world coordinate system.
Constants
float VERTICAL_RANGE_MAX
float VERTICAL_RANGE_MIN
Public Constructors
SmartEyeglassControlUtils(java.lang.String hostAppPackageName, SmartEyeglassEventListener eventListener)

Creates an instance of this class.

Public Methods
final void activate(Context context)

Associates this instance with a service context.

final void deactivate()

Unregisters this instance from the associated service context.

void onReceive(Context context, Intent intent)
void setRequiredApiVersion(int version)

Set the minimum version of the SmartEyeglass API the app requires.

void showImage(int resourceId)

Displays an image resource on the SmartEyeglass screen.

void showImageWithCallback(int resourceId, int transactionNumber)

Draws an image on the SmartEyeglass display.

void showBitmap(Bitmap bitmap)

Displays a bitmap on the SmartEyeglass screen.

void showBitmap(Bitmap bitmap, int x, int y)

Updates a part of the SmartEyeglass screen with a given bitmap.

void showBitmapWithCallback(Bitmap bitmap, int transactionNumber)

Draws an bitmap on the SmartEyeglass display.

void showBitmapWithCallback(Bitmap bitmap, int x, int y, int transactionNumber)

Draws an bitmap on a specific region of the SmartEyeglass display.

void startCamera(java.lang.String filePath)

Initiates camera operation on the SmartEyeglass device, providing a file specification for saving captured image data.

void startCamera()

Initiates camera operation on the SmartEyeglass device.

void stopCamera()

Terminates camera operation on the SmartEyeglass device.

void setCameraMode(int jpegQuality, int resolution, int recordingMode)

Configures camera settings for the next camera operation.

void requestCameraCapture()

Captures a still image when the camera module is running.

void moveLowerLayer(Bitmap bitmap)

Transitions the screen display to the given bitmap using a built-in animation effect that looks like moving down to a lower layer.

void moveUpperLayer(Bitmap bitmap)

Transitions the screen display to the given bitmap using a built-in animation effect that looks like moving up to a higher layer.

void moveLowerLayer(int layoutId, Bundle[] layoutData)

Transitions the screen display to the given layout using a built-in animation effect that looks like moving down to a lower layer.

void moveUpperLayer(int layoutId, Bundle[] layoutData)

Transitions the screen display to the given layout using a built-in animation effect that looks like moving up to a higher layer.

void sendTextViewLayoutId(int textViewId)

Enables vertical stroll support for specified TextView in the current layout.

void showDialogMessage(java.lang.String text, int mode)

Displays a simple dialog.

void showDialogMessage(java.lang.String title, java.lang.String message, java.lang.String[] buttons)

Displays a customized dialog with up to three custom buttons.

void enableVoiceTextInput()

Enables the voice-to-text input feature.

void disableVoiceTextInput()

Disables voice-to-text input feature and removes the microphone icon from the screen.

void enableSafeDisplayMode()

Enables the safe-display mode, which limits the display to the lower half of the screen in order to minimize interference with the user's field of view.

void disableSafeDisplayMode()

Disables the safe-display mode, restoring full screen display.

void setPowerMode(int powerMode)

Sets the power mode.

void requestEnterStandbyMode()

Initiates Standby mode to conserve power.

void disableSoundEffect()

Disables the sound effect that provides feedback when the user presses a button on the controller.

void enableSoundEffect()

Enables the sound effect that provides feedback when the user presses a button on the controller.

void setScreenDepth(int depth)

Controls screen depth, which is the apparent distance of the display plane from the user's eyes.

void requestBatteryStatus()

Requests notification of the battery status.

void requestTelephonyFunctionStatus()

Requests notification of the telephony function status.

void setRenderMode(int renderingMode)

Turns AR rendering mode on or off.

void changeARCylindricalVerticalRange(float range)

Limits the vertical range of cylindrical coordinate system.

void registerARObject(RenderObject object)

Registers an image to be rendered by the AR engine.

void moveARObject(RenderObject object)

Executes the change of position of a registered AR object.

void sendARObjectResponse(RenderObject object, int result)

Sends object data in response to a request from the AR engine for update of a static object display.

void sendARAnimationObject(int objectId, Bitmap bitmap)

Sends image data in response to a request from the AR engine for update of an animation display.

void sendARAnimationObjectWithCallback(int objectId, Bitmap bitmap, int transactionNumber)

Sends the image data of each frame of the animation object.

void changeARObjectOrder(RenderObject object)

Executes the change of rendering order of a registered AR object.

void enableARAnimationRequest()

Request to enable AR animation feature.

void disableARAnimationRequest()

Request to disables AR animation feature.

void deleteARObject(RenderObject object)

Deletes an AR object.

static PointF convertCoordinateSystemFromWorldToCylindrical(SmartEyeglassControlUtils.PointInWorldCoordinate viewingLocation, SmartEyeglassControlUtils.PointInWorldCoordinate targetLocation)

Converts the position of an object in the real world to the cylindrical coordinate system for a given user viewpoint.

Protected Methods
void sendToHostApp(Intent intent)

Sends an intent to HostApp, adding package names.

Constants

public static final float VERTICAL_RANGE_MAX

Constant Value: 60.0 (0x0000003c)

public static final float VERTICAL_RANGE_MIN

Constant Value: 0.0 (0x00000000)

Public Constructors

public SmartEyeglassControlUtils(java.lang.String hostAppPackageName, SmartEyeglassEventListener eventListener)

Creates an instance of this class.

Parameters
hostAppPackageName Package name of host application.
eventListener Optional. The associated event listener, or NULL if not needed.

Public Methods

public final void activate(Context context)

Associates this instance with a service context.

Parameters
context The extension service context.

public final void deactivate()

Unregisters this instance from the associated service context. You must call this method before destroying the associated context object (for example, in the onDestroy() method of the Activity ). Failure to deactivate causes the Android framework to log an error.

public void onReceive(Context context, Intent intent)

Parameters
context
intent

public void setRequiredApiVersion(int version)

Set the minimum version of the SmartEyeglass API the app requires. Call this during initialization of the app so that HostApp can ensure compatibility.

This allows the framework to warn the user if they need to install an update, and exit gracefully from your app.

By default, the required API version is set to the highest level available in the SDK. For the best user experience, you should explicitly set it to the highest API level the app actually requires.

Parameters
version The minimum required API version

public void showImage(int resourceId)

Displays an image resource on the SmartEyeglass screen. Display can take some time for a large image.

If an image is larger than the screen size, it is not displayed on the screen.
For screen size refer to EXTRA_IMAGE_HEIGHT, EXTRA_IMAGE_WIDTH

Parameters
resourceId The image resource ID.

public void showImageWithCallback(int resourceId, int transactionNumber)

Draws an image on the SmartEyeglass display. Returns the result in onResultShowImage when the operation is completed.

If an image is larger than the screen size, it is not displayed on the screen.
For screen size refer to EXTRA_IMAGE_HEIGHT, EXTRA_IMAGE_WIDTH

Parameters
resourceId The image resource ID.
transactionNumber The transaction number.(allowed 0 or more)

public void showBitmap(Bitmap bitmap)

Displays a bitmap on the SmartEyeglass screen. Display can take some time for a large image.

If an image is larger than the screen size, it is not displayed on the screen.
For screen size refer to EXTRA_IMAGE_HEIGHT, EXTRA_IMAGE_WIDTH

Parameters
bitmap The bitmap object.

public void showBitmap(Bitmap bitmap, int x, int y)

Updates a part of the SmartEyeglass screen with a given bitmap. Provide the screen position at which to place the upper-left corner of the bitmap. Coordinates are in pixels from the screen origin, the upper left corner.

If an image is larger than the screen size, it is not displayed on the screen.
For screen size refer to EXTRA_IMAGE_HEIGHT, EXTRA_IMAGE_WIDTH

Parameters
bitmap The bitmap to show.
x The x position at which to draw.
y The y position at which to draw.

public void showBitmapWithCallback(Bitmap bitmap, int transactionNumber)

Draws an bitmap on the SmartEyeglass display. Returns the result in onResultShowBitmap when the operation is completed.

If an image is larger than the screen size, it is not displayed on the screen.
For screen size refer to EXTRA_IMAGE_HEIGHT, EXTRA_IMAGE_WIDTH

Parameters
bitmap The bitmap to show.
transactionNumber The transaction number. (allowed 0 or more)

public void showBitmapWithCallback(Bitmap bitmap, int x, int y, int transactionNumber)

Draws an bitmap on a specific region of the SmartEyeglass display. Returns the result in onResultShowBitmap when the operation is completed.

If an image is larger than the screen size, it is not displayed on the screen.
For screen size refer to EXTRA_IMAGE_HEIGHT, EXTRA_IMAGE_WIDTH

Parameters
bitmap The bitmap to show.
x The x position.
y The y position.
transactionNumber The transaction number. (allowed 0 or more)

public void startCamera(java.lang.String filePath)

Initiates camera operation on the SmartEyeglass device, providing a file specification for saving captured image data.

Parameters
filePath Path of a file to which to save captured image data.
Throws
ControlCameraException  

public void startCamera()

Initiates camera operation on the SmartEyeglass device. When the recording mode is CAMERA_MODE_STILL, CAMERA_MODE_JPG_STREAM_LOW_RATE, CAMERA_MODE_JPG_STREAM_HIGH_RATE, the extension receives onCameraReceived callback methods when the capture process finishes.

Throws
ControlCameraException  

public void stopCamera()

Terminates camera operation on the SmartEyeglass device.

public void setCameraMode(int jpegQuality, int resolution, int recordingMode)

Configures camera settings for the next camera operation.

Parameters
jpegQuality The desired JPEG quality (compression). One of:
resolution The desired picture resolution. One of:
recordingMode The camera mode. One of:

public void requestCameraCapture()

Captures a still image when the camera module is running.

public void moveLowerLayer(Bitmap bitmap)

Transitions the screen display to the given bitmap using a built-in animation effect that looks like moving down to a lower layer. Display can take some time for a large image. If an image larger than the screen size,it is not displayed on the screen.
For screen size refer to EXTRA_IMAGE_HEIGHT, EXTRA_IMAGE_WIDTH

Parameters
bitmap The new bitmap to show.

public void moveUpperLayer(Bitmap bitmap)

Transitions the screen display to the given bitmap using a built-in animation effect that looks like moving up to a higher layer. Display can take some time for a large image. If an image larger than the screen size,it is not displayed on the screen.
For screen size refer to EXTRA_IMAGE_HEIGHT, EXTRA_IMAGE_WIDTH

Parameters
bitmap The new bitmap to show.

public void moveLowerLayer(int layoutId, Bundle[] layoutData)

Transitions the screen display to the given layout using a built-in animation effect that looks like moving down to a lower layer. Display can take some time for a large image.

Parameters
layoutId The resource ID for the new layout to show.
layoutData The layout data bundle.

public void moveUpperLayer(int layoutId, Bundle[] layoutData)

Transitions the screen display to the given layout using a built-in animation effect that looks like moving up to a higher layer. Display can take some time for a large image.

Parameters
layoutId The resource ID for the new layout to show.
layoutData The layout data bundle.

public void sendTextViewLayoutId(int textViewId)

Enables vertical stroll support for specified TextView in the current layout.

Parameters
textViewId The resource ID of the TextView.

public void showDialogMessage(java.lang.String text, int mode)

Displays a simple dialog.

Parameters
text The message text.
mode The dialog mode, one of:

public void showDialogMessage(java.lang.String title, java.lang.String message, java.lang.String[] buttons)

Displays a customized dialog with up to three custom buttons. The user closes the dialog by selecting one of the buttons.

Parameters
title The dialog title.
message The message text.
buttons An array of one to three button labels. A 0-based index pointing into this array is returned to the onDialogClosed handler to indicate which button was selected.

public void enableVoiceTextInput()

Enables the voice-to-text input feature. After that user can input text by pushing the Talk button. When feature is active it shows a microphone icon on the screen.

The system interrupts screen while voice-to-text input is in use. During the operation, the app has no control and cannot receive input events from the device keys or touch sensor.

The result of the operation is returned the onVoiceTextInput handler for your app.

public void disableVoiceTextInput()

Disables voice-to-text input feature and removes the microphone icon from the screen.

public void enableSafeDisplayMode()

Enables the safe-display mode, which limits the display to the lower half of the screen in order to minimize interference with the user's field of view.

public void disableSafeDisplayMode()

Disables the safe-display mode, restoring full screen display.

public void setPowerMode(int powerMode)

Sets the power mode. In normal mode (the default), the SmartEyeglass connects via Bluetooth. In high power mode, the connection can use Wi-Fi as well, which uses more power but allows faster data transfer.

Parameters
powerMode The PowerMode value, one of

public void requestEnterStandbyMode()

Initiates Standby mode to conserve power. Standby mode terminates automatically when the user presses any button or touches the touch sensor.

public void disableSoundEffect()

Disables the sound effect that provides feedback when the user presses a button on the controller. The sound effect is on by default.

public void enableSoundEffect()

Enables the sound effect that provides feedback when the user presses a button on the controller. The sound effect is on by default. Use this call to re-enable the effect after you have turned it off.

public void setScreenDepth(int depth)

Controls screen depth, which is the apparent distance of the display plane from the user's eyes.

Parameters
depth An integer in the range -4 to 6.
  • 0 (the default) is about 5 meters
  • 6 is nearest
  • -4 is furthest, about 10 meters or more

public void requestBatteryStatus()

Requests notification of the battery status. See onBatteryStatus

public void requestTelephonyFunctionStatus()

Requests notification of the telephony function status. See onTelephonyFunctionStatus

public void setRenderMode(int renderingMode)

Turns AR rendering mode on or off.

Parameters
renderingMode The rendering mode. One of:

public void changeARCylindricalVerticalRange(float range)

Limits the vertical range of cylindrical coordinate system. Objects positioned outside of limit will stick to the edge of range. Resulting field of view will be -range..range degrees.

Parameters
range The new range value, must be between 0 and 60 degrees.

public void registerARObject(RenderObject object)

Registers an image to be rendered by the AR engine. Registration is asynchronous. The result of registration is sent to the onARRegistrationResult handler for your app.

Parameters
object The configured render object, an instance of CylindricalRenderObject or GlassesRenderObject.

public void moveARObject(RenderObject object)

Executes the change of position of a registered AR object. Before calling this method, update the position value in RenderObject.

Parameters
object The registered AR object.

public void sendARObjectResponse(RenderObject object, int result)

Sends object data in response to a request from the AR engine for update of a static object display. Call this in your handler for onARObjectRequest. Image of more than 57822 pixels can not be sent.

Parameters
object The object identified in the request event.
result The result passed in the request event.

public void sendARAnimationObject(int objectId, Bitmap bitmap)

Sends image data in response to a request from the AR engine for update of an animation display. Call this in your handler for onARObjectRequest. Image of more than 57822 pixels can not be sent.

Parameters
objectId The object identified in the request event.
bitmap The bitmap for the next animation frame.

public void sendARAnimationObjectWithCallback(int objectId, Bitmap bitmap, int transactionNumber)

Sends the image data of each frame of the animation object. A processing result will be notified if display processing is completed. Response method onResultSendAnimationObject(int, int) Image of more than 57822 pixels can not be sent.

Parameters
objectId The object ID.
bitmap The bitmap image.
transactionNumber The transaction number. (allowed 0 or more)

public void changeARObjectOrder(RenderObject object)

Executes the change of rendering order of a registered AR object. Before calling this method, update the rendering order value in the object using setOrder or setOrder.

Parameters
object The registered object.

public void enableARAnimationRequest()

Request to enable AR animation feature. For operation result: onAREnableAnimationResponse

public void disableARAnimationRequest()

Request to disables AR animation feature. For operation result: onARDisableAnimationResponse

public void deleteARObject(RenderObject object)

Deletes an AR object.

Parameters
object The registered object.

public static PointF convertCoordinateSystemFromWorldToCylindrical(SmartEyeglassControlUtils.PointInWorldCoordinate viewingLocation, SmartEyeglassControlUtils.PointInWorldCoordinate targetLocation)

Converts the position of an object in the real world to the cylindrical coordinate system for a given user viewpoint.

Parameters
viewingLocation A user viewpoint in the real-world coordinate system.
targetLocation The position of an object in the real-world coordinate system.
Returns

A position in the cylindrical coordinate system.

Protected Methods

protected void sendToHostApp(Intent intent)

Sends an intent to HostApp, adding package names.

Parameters
intent The intent to send.