# Glass SDK API Reference

This page organizes the public glasses-side `glass3.open.sdk` APIs for integration, capability lookup, and troubleshooting. Start with [Quick Start](/en/terminal-sdk/getting-started/快速开始.md) to add the SDK dependency, then use the capability sections below to find the relevant interfaces.

## API Category Overview

| Category | What to look for |
| --- | --- |
| [Integration and initialization](#api-init) | SDK binding, client registration, initialization status |
| [GlassSdk service entry points](#glasssdk-service-entry-table) | Getting capability services through `GlassSdk` |
| [Common information interfaces](#common-info-interfaces) | User information, companion app information, glasses-side configuration changes |
| [Offline voice command interfaces](#offline-command-interfaces) | Offline command word configuration and compatibility methods |
| [Voice and AI](#voice-ai) | AI chat and ASR speech-to-text |
| [Media capabilities](#media-capabilities) | Audio/video preview, photo/video capture, media state listeners |
| [Messaging and file transfer](#messaging-file-transfer) | Message and file exchange between phone and glasses |
| [File system capabilities](#file-system-capabilities) | File upload, file status, upload callbacks |
| [Visual recognition](#visual-recognition-capabilities) | Face, license plate, person/vehicle recognition capabilities |
| [Connectivity and peripherals](#connectivity-peripherals) | Classic Bluetooth and Bluetooth ring capabilities |
| [Device and system capabilities](#device-system-capabilities) | Device state, app visibility, battery, and system events |


<a id="api-init"></a>

## 1 Integration and Initialization

```kotlin
fun initSdk() {
        // Return directly if the SDK has already been initialized
        if (GlassSdk.isReady()) {
            Log.d(TAG, "SDK has already been initialized")
            return
        }
        GlassSdk.bindSecurityService(Utils.getApp(), object : IServiceConnectionCallback {
            override fun onServiceConnected() {
                // The clientId on the glasses side must be the same as the clientId registered on the phone side,
                // so the phone side knows which glasses-side application should receive the data
                GlassSdk.registerClient("GlassSample", mClientMessageCallback)
            }

            override fun onServiceDisconnected() {
                Log.i(TAG, "onServiceDisconnected: ")
            }

            override fun onBindingDied() {
                Log.i(TAG, "onBindingDied: ")               
            }
        })
    }
```

## 2 GlassSdk Service Entry Points and Common Capabilities

`GlassSdk` is the unified entry point for the glasses-side SDK. In a typical integration, bind the system service and register the client first, then call `getGlassXxxService()` to obtain the capability service you need.

### 2.1 Common Entry Methods

| Method | Description |
| --- | --- |
| <a id="bindsecurityservice"></a>[`bindSecurityService(context, callback)`](#bindsecurityservice) | Bind the glasses-side system service. Register the client and obtain capability services after the binding succeeds. |
| <a id="registerclient"></a>[`registerClient(clientId, callback)`](#registerclient) | Register the glasses-side application. The `clientId` must match the phone-side client ID. |
| <a id="isready"></a>[`isReady()`](#isready) | Check whether the SDK service is bound. |
| <a id="release"></a>[`release()`](#release) | Release the SDK connection and internal resources, usually when the app exits or no longer uses the SDK. |


Use `getGlassXxxService()` to obtain capability services from `GlassSdk`. Service objects may be null, so check `GlassSdk.isReady()` first and handle nullable return values.

```kotlin
if (!GlassSdk.isReady()) {
    // Bind the service and register the client first
    return
}

val mediaService = GlassSdk.getGlassMediaService()
val messageService = GlassSdk.getGlassMessageService()
```

<a id="glasssdk-service-entry-table"></a>

### 2.2 Capability Service Entry Points

| Method | Returned service | Description |
| --- | --- | --- |
| <a id="getclassicbluetoothservice"></a>[`getClassicBluetoothService()`](#ibtservice) | <a id="ibtservice-entry"></a>[`IBTService`](#ibtservice) | Classic Bluetooth capability. |
| <a id="getp2pgoservice"></a>[`getP2PGoService()`](#iwifip2pgoservice) | <a id="iwifip2pgoservice"></a>[`IWifiP2PGoService`](#iwifip2pgoservice) | Wi-Fi P2P connectivity capability. |
| <a id="getglassmessageservice"></a>[`getGlassMessageService()`](#imessageserver) | <a id="imessageserver-entry"></a>[`IMessageServer`](#imessageserver) | Messaging capability. |
| <a id="getglasscommonservice"></a>[`getGlassCommonService()`](#icommoninfoserver) | <a id="icommoninfoserver-entry"></a>[`ICommonInfoServer`](#icommoninfoserver) | Common information capability. |
| <a id="getglassmediaservice"></a>[`getGlassMediaService()`](#imediaserver) | <a id="imediaserver-entry"></a>[`IMediaServer`](#imediaserver) | Media preview, photo capture, and video recording capabilities. |
| <a id="getglassofflinefeaturerecservice"></a>[`getGlassOfflineFeatureRecService()`](#iofflinefeaturerecservice) | <a id="iofflinefeaturerecservice-entry"></a>[`IOfflineFeatureRecService`](#iofflinefeaturerecservice) | Offline feature recognition capability. |
| <a id="getglassofflinerecservice"></a>[`getGlassOfflineRecService()`](#iofflinerecserver) | <a id="iofflinerecserver-entry"></a>[`IOfflineRecServer`](#iofflinerecserver) | Offline recognition capability. |
| <a id="getglassonlinerecservice"></a>[`getGlassOnlineRecService()`](#ionlinerecservice) | <a id="ionlinerecservice-entry"></a>[`IOnlineRecService`](#ionlinerecservice) | Online person/vehicle recognition capability. |
| <a id="getglasscollectservice"></a>[`getGlassCollectService()`](#icollectservice) | <a id="icollectservice"></a>[`ICollectService`](#icollectservice) | Image collection capability. |
| <a id="getglasstrackservice"></a>[`getGlassTrackService()`](#itrackservice) | <a id="itrackservice"></a>[`ITrackService`](#itrackservice) | Person/vehicle detection and tracking capability. |
| <a id="getglassdeviceservice"></a>[`getGlassDeviceService()`](#ideviceservice) | <a id="ideviceservice-entry"></a>[`IDeviceService`](#ideviceservice) | Device and system capability. |
| <a id="getglassbluetoothringservice"></a>[`getGlassBluetoothRingService()`](#ibluetoothringservice) | <a id="ibluetoothringservice-entry"></a>[`IBluetoothRingService`](#ibluetoothringservice) | Bluetooth ring capability. |
| <a id="getglassnotificationservice"></a>[`getGlassNotificationService()`](#inotificationservice) | <a id="inotificationservice"></a>[`INotificationService`](#inotificationservice) | Notification capability. |
| <a id="getglassaichatservice"></a>[`getGlassAiChatService()`](#iaichatservice) | <a id="iaichatservice-entry"></a>[`IAiChatService`](#iaichatservice) | AI chat capability. |
| <a id="getglassfilesystemservice"></a>[`getGlassFileSystemService()`](#ifilesystemservice) | <a id="ifilesystemservice-entry"></a>[`IFileSystemService`](#ifilesystemservice) | File system capability. |
| <a id="getglasstranslateservice"></a>[`getGlassTranslateService()`](#itranslateservice) | <a id="itranslateservice"></a>[`ITranslateService`](#itranslateservice) | Translation capability. |
| <a id="getglassttsservice"></a>[`getGlassTtsService()`](#ittsservice) | <a id="ittsservice"></a>[`ITtsService`](#ittsservice) | Online TTS capability. |
| <a id="getglassofflinettsservice"></a>[`getGlassOfflineTtsService()`](#iofflinettsservice) | <a id="iofflinettsservice"></a>[`IOfflineTtsService`](#iofflinettsservice) | Offline TTS capability. |
| <a id="getglassasrservice"></a>[`getGlassAsrService()`](#iasrservice) | <a id="iasrservice-entry"></a>[`IAsrService`](#iasrservice) | ASR speech-to-text capability. |
| <a id="getglassofflinecmdservice"></a>[`getGlassOfflineCmdService()`](#iofflinecmdservice) | <a id="iofflinecmdservice-entry"></a>[`IOfflineCmdService`](#iofflinecmdservice) | Offline voice command capability. |
| <a id="getglassidentificationservice"></a>[`getGlassIdentificationService()`](#iidentificationservice) | <a id="iidentificationservice"></a>[`IIdentificationService`](#iidentificationservice) | Identification capability. |


<a id="2-3-common-information-interfaces"></a>

<a id="common-info-interfaces"></a>

### 2.3 Common Information Interfaces

`ICommonInfoServer` is returned by `GlassSdk.getGlassCommonService()`. Use it to read user information, companion app information, and register common information callbacks. `ICommonInfoListener` is the corresponding listener for user information, companion app information, and glasses-side configuration changes.

<a id="icommoninfoserver"></a>

**ICommonInfoServer: Common Information Service**

```java
interface ICommonInfoServer {
    /**
     * Get user information
     * @return UserInfo
     */
    UserInfo getUserInfo();

    /**
     * Get companion app information
     * @return CompanionAppInfo
     */
    CompanionAppInfo getCompanionAppInfo();

    /**
     * Register listener
     * @param listener
     */
    void setCommonInfoListener(ICommonInfoListener listener);

    /**
     * Unregister listener
     * @param listener
     */
    void removeCommonInfoListener(ICommonInfoListener listener);

}

```

<a id="icommoninfolistener"></a>

**ICommonInfoListener: Common Information Callback**

```java
interface ICommonInfoListener {
    /**
     * Update user information
     * @param info
     */
   void onUserInfo(in UserInfo info);

    /**
     * Update companion app information
     * @param info
     */
   void onCompanionAppInfo(in CompanionAppInfo info);

   /**
    * Configuration information on the glasses side
    */
   void onConfig(in String config);
}

```

<a id="2-4-offline-voice-command-interfaces"></a>

<a id="offline-command-interfaces"></a>

### 2.4 Offline Voice Command Interfaces

`IOfflineCmdService` is returned by `GlassSdk.getGlassOfflineCmdService()`. Use it to initialize, add, remove, and clear offline voice command words.

#### Compatibility Methods

| Method | Description |
| --- | --- |
| `setOfflineCmdLanguage(language)` | Set the offline command language, such as `ZH_CN` or `EN_US`. |
| `setOfflineCmdWords(language, voiceActions)` | Override offline command words by language. |
| `clearOfflineCmdWords(language)` | Clear offline command words for a specified language. |

<a id="iofflinecmdservice"></a>

**IOfflineCmdService: Offline Voice Command Service**

```kotlin
interface IOfflineCmdService {
         /**
          * Initialize
          * */
         void init();

          /**
          * Restore the previously configured command words
          * */
         void restore();

          /**
          * Add command words
          *@Param VoiceAction Command word
          * */
         void add(in VoiceAction voiceAction);

          /**
           * Add command words
           *@Param voiceActions A group of command words
           * */
         void addAll(in List<VoiceAction> voiceActions);

          /**
           * Remove command words
           *@Param VoiceAction Command word
           * */
         void remove(in VoiceAction voiceAction);

           /**
            * Remove all command words
            * */
         void removeAll();

         /**
          * Release
           * */
         void release();

         /**
          * Get the current offline command language (ZH_CN / EN_US)
          */
         String getLanguage();

         /**
          * Switch the offline command language (ZH_CN / EN_US)
          */
         void setLanguage(String language);

         /**
          * Replace command words in batches by language (does not affect caches for other languages)
          */
         void setWords(String language, in List<VoiceAction> voiceActions);

         /**
          * Clear command words for a specified language
          */
         void clearWords(String language);

         /**
          * Start voice recording
          */
         void startRecord();

         /**
          * Stop voice recording
          */
         void stopRecord();

}
```

<a id="3-voice-and-ai"></a>

<a id="voice-ai"></a>

## 3 Voice and AI

<a id="iaichatservice"></a>

**IAiChatService: AI Chat Service**

```java
interface IAiChatService {

        /**
         * Start AI chat
         * @param isCameraOpen Whether the camera is currently enabled
         */
        void startAiChat(boolean isCameraOpen );

        /**
         * End AI chat
         */
        void endAiChat();

        /**
         * AI chat
         * @param question AI chat question
         * @param listener Callback for receiving the answer
         */
        void toAiChat(String question, AiChatListener listener);


         /**
         * AI chat with intent recognition
         * @param question AI chat question
         * @param intent Intent
         * @param intentJson Intent JSON
         * @param listener Callback for receiving the answer
         */
        void toAiChatWithIntent(String question, int intent, String intentJson, AiChatListener listener);


         /**
          * Inspection
          * @param question
          * @param listener
          */
        void toInspectChat(String question, AiChatListener listener);

         /**
          * Perform AI chat with a Base64 image
          * @param question Question text
          * @param filePath Base64-encoded image
          * @param listener AI chat listener
          */
        void toAiCode( String code,  AiChatListener listener);


        void removeAIChatListener();

}
```

<a id="aichatlistener"></a>

**AiChatListener**

```java
interface AiChatListener {



        /**
         * AI chat answer
         * @param answer Streaming answer
         * @param isFinish Answer termination flag
         */
   void onAiChatAnswer(String answer,boolean isFinish,String contentType,String sessionId);



       /**
        * Error callback for AI chat
        * @param code Error code
        * @param message Error message
       */
       void onError( int code , String message);


    void onAiTakePhoto(String filePath);

    void onContinuousModeUpdate( boolean continuousMode,  long timeout,  boolean keepSessionActive);


}
```



<a id="4-media-capabilities"></a>

<a id="media-capabilities"></a>

## 4 Media Capabilities

<a id="imediaserver"></a>

**IMediaServer**

```kotlin
// CameraSize already implements Parcelable in Java/Kotlin
parcelable CameraSize;

interface IMediaServer {
    /**
     * Start recording
     * @param callback Recording callback
     * @param recordConfig Recording parameter settings
     */
    void startRecord(VideoCallback callback, in RecordConfig recordConfig);

    /**
     * Stop recording
     */
    void stopRecord();

    /**
     * Take a photo, which triggers the [PhotoFileCallback] callback with the captured file
     */
    void  takePhoto(int photoResolution,String path);

    /**
     * Add photo file callback
     * @param expectedResolution (Resolution)
     * @param photoFileCallback
     */
    void addPhotoCallback(PhotoFileCallback photoFileCallback);

    /**
     * Remove camera frame NV21 data callback
      */
    void removePhotoCallback(PhotoFileCallback photoFileCallback);

    /**
     * @return Maximum camera zoom level
     */
    int getMaxZoomLevel();

    int getZoomLevel();

    /**
     * Zoom camera
     * @param level Zoom level
     */
    void zoomCamera(int level);

    /**
     * Start audio recording
     * @param callback Audio callback
     */
    void startAudioRecord(AudioCallback callback);

    /**
     * Stop audio recording
     * @param callback Audio callback
     */
    void stopAudioRecord(AudioCallback callback);

   /**
     * Register media service status listener
     * @param listener
     */
    void setMediaStateLister(IMediaStateLister listener);

    /**
      * Unregister media service status listener
      * @param listener
      */
    void removeMediaStateLister(IMediaStateLister listener);


      void removeAllPhotoCallback();

    /**
     * Start cross-process Surface sharing (renders only camera frames to the Surface, without NV21 data)
     * @param surface Surface created by the client to receive camera frames
     * @param callback Lifecycle callback
     */
    void startCameraShare(in Surface surface, ICameraSurfaceCallback callback);

    /**
     * Stop cross-process Surface sharing
     * @param callback Previously registered callback
     */
    void stopCameraShare(ICameraSurfaceCallback callback);

    /**
     * Start NV21 data export (share frame data through SharedMemory double buffering)
     * @param callback Callback interface that receives frame data through onNv21FrameAvailable
     * @param enableMix Whether to enable overlay mode (camera + screen overlay),
     *                  false: Export pure camera NV21 data
     *                  true:  Export NV21 data after overlaying camera with screen content
     */
    void startCameraNv21Export(ICameraShareCallback callback, boolean enableMix);

    /**
     * Stop NV21 data export
     * @param callback Previously registered callback
     */
    void stopCameraNv21Export(ICameraShareCallback callback);

    /**
     * Close camera
     * @param callback Callback interface: true indicates the camera was closed successfully, false indicates the camera was not closed
     */
    void closeCamera(ICameraCloseCallback callback);

    /**
     * Start NV21 export (configurable resolution, frame rate, and stabilization)
     * @param callback Callback interface that receives frame data through onNv21FrameAvailable
     * @param enableMix Whether to enable AR Mix mode (camera + screen overlay)
     * @param config Configuration items, consistent with CameraShareConfig
     */
    void startCameraNv21ExportWithConfig(ICameraShareCallback callback, boolean enableMix, in CameraShareConfig config);

    /**
     * Start cross-process Surface sharing (configurable version)
     * @param surface Surface created by the client to receive camera frames
     * @param callback Lifecycle callback
     * @param enableMix Whether to enable AR Mix mode (camera + screen overlay)
     * @param config Configuration items, consistent with CameraShareConfig
     */
    void startCameraShareWithConfig(in Surface surface, ICameraSurfaceCallback callback, boolean enableMix, in CameraShareConfig config);

    /**
     * Get the list of preview resolutions supported by the Camera API
     * @return Supported resolution list (note: because the camera has rotation, the width and height of the camera raw resolution returned here are swapped compared with the resolution to be set in CameraShareConfig)
     */
    List<CameraSize> getSupportedPreviewSizes();
}
```

<a id="imediastatelister"></a>

**IMediaStateLister**

```java
interface IMediaStateLister {

    void onCameraResolutionChange(int width, int height);

    void onCameraError(int code,String errorMsg);
}
```

<a id="icamerasharecallback"></a>

**ICameraShareCallback**

```java
interface ICameraShareCallback {

    /**
     * Camera opened, with resolution and NV21 double-buffered SharedMemory provided
     * @param width Camera width
     * @param height Camera height
     * @param nv21Buffer0 NV21 double buffer 0
     * @param nv21Buffer1 NV21 double buffer 1
     */
    void onCameraOpened(int width, int height, in SharedMemory nv21Buffer0, in SharedMemory nv21Buffer1);

    /**
     * A new NV21 frame has been written to the specified buffer
     * @param bufferIndex Buffer index (0 or 1)
     * @param width Frame width
     * @param height Frame height
     * @param timestamp Frame timestamp (milliseconds)
     */
    void onNv21FrameAvailable(int bufferIndex, int width, int height, long timestamp);

    /**
     * Camera closed
     */
    void onCameraClosed();

    /**
     * An error occurred
     * @param code Error code
     * @param msg Error message
     */
    void onError(int code, String msg);

    /**
     * Unique callback identifier
     */
    String getCallbackId();

    /**
     * A new NV21 frame has been written to the specified buffer (asynchronous version, better performance)
     * @param bufferIndex Buffer index (0 or 1)
     * @param width Frame width
     * @param height Frame height
     * @param timestamp Frame timestamp (milliseconds)
     */
    oneway void onNv21FrameAvailableAsync(int bufferIndex, int width, int height, long timestamp);

    void onNv21ExportResolutionChanged(int width, int height, in SharedMemory nv21Buffer0, in SharedMemory nv21Buffer1, int appliedPreviewFps);

    void onNv21ExportRuntimeParamsChanged(int appliedPreviewFps, boolean videoStabilizationEnabled);

    /**
     * Zoom level changed
     * @param zoomLevel Current zoom level (integer)
     */
    void onZoomLevelChanged(int zoomLevel);
}
```

<a id="icamerasurfacecallback"></a>

**ICameraSurfaceCallback**

```java
/**
 * Lightweight callback for cross-process Surface sharing (lifecycle only, no NV21 data)
 */
interface ICameraSurfaceCallback {

    /**
     * Camera opened
     * @param width Camera width
     * @param height Camera height
     */
    void onCameraOpened(int width, int height);

    /**
     * Camera closed
     */
    void onCameraClosed();

    /**
     * An error occurred
     * @param code Error code
     * @param msg Error message
     */
    void onError(int code, String msg);

    /**
     * Unique callback identifier
     */
    String getCallbackId();

    /**
     * Surface sharing configuration changed (resolution, frame rate, stabilization, etc.)
     * Triggered when configuration is updated through startCameraShareWithConfig to avoid restarting the camera
     * @param width New width
     * @param height New height
     * @param appliedPreviewFps Negotiated frame rate
     * @param videoStabilizationEnabled Whether stabilization is enabled
     */
    void onSurfaceShareConfigChanged(int width, int height, int appliedPreviewFps, boolean videoStabilizationEnabled);

    /**
     * Zoom level changed
     * @param zoomLevel Current zoom level (integer)
     */
    void onZoomLevelChanged(int zoomLevel);
}

```

<a id="photofilecallback"></a>

**PhotoFileCallback**

```java
interface PhotoFileCallback {
   void onTakePhoto(String path);

    /**
     * Unified unique callback identifier method (implemented by the base class)
     */
    String getCallbackId();

    void onTakePhotoV2(String path, int width, int height);
}

```

<a id="videocallback"></a>

**VideoCallback**

```java
interface VideoCallback {

    void onStart();

    void onError();

    void onFinish();

    void onNewFile(long startTime, long endTime, String path, boolean isLast);

    void onErrorWithDetail(int code, String errorMsg);
}
```



<a id="5-messaging-and-file-transfer"></a>

<a id="messaging-file-transfer"></a>

## 5 Messaging and File Transfer

<a id="imessageserver"></a>

**IMessageServer: Messaging Service**

```kotlin
interface IMessageServer {
    /**
     * Register message listener
     *  @param listener
     */
    void setMessageListener(IMessageListener listener);

    /**
     * Unregister message listener
     *  @param listener
     */
    void removeMessageListener(IMessageListener listener);

    /**
     * Send a text message through P2P (sent by default to the phone-side app corresponding to the first ClientId)
     * @param message
     */
    void sendTextMessageByP2P(String message);

    /**
     * Send a text message through P2P to the specified clientId app on the phone side
     * @param message
     * @param clientId
     */
    void sendTextMessageByP2PWithClient(String message, String clientId);

    /**
     * Send a text message through classic Bluetooth (sent by default to the phone-side app corresponding to the first ClientId)
     * @param message
     */
    void sendTextMessageByClassicBT(String message);

    /**
     * Send a text message through classic Bluetooth to the specified clientId app on the phone side
     * @param message
     * @param clientId
     */
    void sendTextMessageByClassicBTWithClient(String message, String clientId);

    /**
     * Start sending audio stream data (PCM)
     */
    void sendAudioStreamData();

    /**
     *  Stop sending audio stream data
     */
    void stopAudioStreamData();

    /**
     * Start sending H.264 video stream data
     */
    void sendVideoStreamData();

    /**
     * Stop sending H.264 video stream data
     */
    void stopVideoStreamData();

    /**
     * Send binary stream data
     * @param tag
     * @param data
     * @param clientId
     * @param callback
     */
    void sendStreamData(String tag,in byte[] data, String clientId, IResultCallback callback);

    /**
     * Get the P2P file sending manager
     * @return IGlassFileOperate
     */
    IGlassFileOperate getGlassFileOperater();

    /**
     * Get the Bluetooth file sending manager
     * @return IGlassFileOperate
     */
    IGlassFileOperate getGlassBtFileOperater();

    /**
      * Start sending H.264 video stream data
      * @param callback
      */
    void sendVideoStreamDataV2(IResultCallback callback);
}
```

<a id="imessagelistener"></a>

**IMessageListener**

```kotlin
interface IMessageListener {
    /**
     * Receive text messages
     * @param msg
     */
    void onTextMessage(String msg);

    /**
     * Receive audio data
     * @param buffer Audio data buffer
     */
    void onAudioStream(in byte[] buffer);

    /**
     * Receive binary data
     * @param device Bluetooth device that sent the data
     * @param tag Data tag
     * @param data Binary data
     */
    void onStreamDataReceived(String tag, in byte[] data);

}
```

<a id="iglassfileoperate"></a>

**IGlassFileOperate**

```java
interface IGlassFileOperate {
    /**
     * Send file
     * @param dir Custom file receiving directory, for example: "coustom" or "coustom/file/"
     * @param filePath (Note: the file must be placed in a public directory accessible from the SD card)
     * @param listener File sending listener
     * @param resultCallback Operation result callback
     */
    void  sendFile(String dir,String filePath, FileReceiveListener listener, IResultCallback resultCallback);

    /**
     * Stop sending file
     */
    void stopSendFile();

    /**
     * Whether a file is being sent
     * @return
     */
    boolean isSendingFile();

    /**
     * @Deprecated  message = "Deprecated in version V2.1.4; use setFileReceiveV2Listener", replaceWith = ReplaceWith("setFileReceiveV2Listener(listener)"),
     *  Set the local file receiving listener
     *  @param listener
     */
    void setFileReceiveListener(FileReceiveListener listener);

    /**
     *  @Deprecated  message = "Deprecated in version V2.1.4; use removeFileReceiveV2Listener", replaceWith = ReplaceWith("removeFileReceiveV2Listener(listener)"),
     * Remove the local file receiving listener
     *  @param listener
     */
    void removeFileReceiveListener(FileReceiveListener listener);

    /**
     *  Set the local file receiving listener
     *  @param listener
     */
    void setFileReceiveV2Listener(FileReceiveV2Listener listener);

    /**
     * Remove the local file receiving listener
     *  @param listener
     */
    void removeFileReceiveV2Listener(FileReceiveV2Listener listener);

    /**
     * Whether a file is being received
     */
    boolean isReceivingFile();

}

```

<a id="filereceivev2listener"></a>

**FileReceiveV2Listener**

```java
interface FileReceiveV2Listener {
    void onStart(String filePath);
    void onProgressChanged(String filePath, float progress);
    void onComplete(String filePath);
    void onFail();
    void onCancel(String filePath);
}
```

<a id="filereceivelistener"></a>

**FileReceiveListener**

```java
interface FileReceiveListener {
    void onStart();
    void onProgressChanged(float progress);
    void onComplete(String filePath);
    void onFail();
    void onCancel();
}
```



<a id="6-file-system-capabilities"></a>

<a id="file-system-capabilities"></a>

## 6 File System Capabilities

<a id="ifilesystemservice"></a>

**IFileSystemService**

```kotlin
interface IFileSystemService {
    /**
      * Send a task to upload a file to the cloud
      * @param filePath File path
      * @param fileTag File tag type; see FileTag variables
      * @param lastModifiedTime File creation time
      * @param FileUploadListener File upload listener
      */
     void  sendUploadFileTask(String filePath, String fileTag, long lastModifiedTime, FileUploadListener listener);


     /**
     * Clear file upload task
     */
     void clearUploadTask();
}
```

<a id="fileuploadlistener"></a>

**FileUploadListener**

```java
interface FileUploadListener {

       /**Upload queued**/
       void onQueue(String filepath);
   /**
       *File server upload started,
      * */
      void onStart(String fileMd5);


      void onProgressChanged(float progress) ;


      void onComplete(String fileId, String fileUrl, String fileMd5);

      /**
       *Status update
       * */
      void onFail(String filepath,String fileMd5);

      /**
       *Progress update
       * */
      void onCancel(String fileMd5);

}

```

<a id="uploadstatus"></a>

**UploadStatus**

```java
interface UploadStatus {


    const int UPLOAD_STATUS_ING = 0;

      /**
       * Chinese
       */
    const int UPLOAD_STATUS_SUCCESS = 1;


     const int UPLOAD_STATUS_FAILED = -1;
}
```



<a id="7-visual-recognition-capabilities"></a>

<a id="visual-recognition-capabilities"></a>

## 7 Visual Recognition Capabilities

```kotlin
    /**
     *  Get the online person/vehicle detection and recognition management service
     */
    @JvmStatic
    fun getGlassOnlineRecService(): IOnlineRecService? {
        return getService(ServerType.ONLINE_REC, IOnlineRecService::class.java)
    }

   GlassSdk.getGlassOnlineRecService()
```

<a id="ionlinerecservice"></a>

**IOnlineRecService**

```java
interface IOnlineRecService {
    /**
     * Start detection
     * @param mode Recognition mode (@AIRecgMode)
     */
    void startDetection(int mode);

    /**
     * Stop detection
     */
    void stopDetection();

    /**
     * Register listener
     * @param listener Detection listener
     */
    void setGlassOnlineRecListener(IGlassDetectionListener listener);

    /**
     * Remove listener
     * @param listener Detection listener
     */
    void removeGlassOnlineRecListener(IGlassDetectionListener listener);

    /**
     * Face recognition
     * @param param Face recognition parameters
     * @param callback Recognition result callback
     */
    void recognizeFace(in FaceRecognizeParam param, IResultCallback callback);

    /**
     * Get small face image
     * @param trackId
     * @param Bitmap
     */
    Bitmap getFaceSamllBitmap(long trackId);

    /**
     * Get small face image (rounded corners)
     * @param trackId
     * @param Bitmap
     */
    Bitmap getFaceRoundCornerSamllBitmap(long trackId);

    /**
     * Get small license plate image
     * @param plateNo
     * @param Bitmap
     */
    Bitmap getLprSamllBitmap(String plateNo);
}
```

<a id="iglassdetectionlistener"></a>

**IGlassDetectionListener**

```kotlin
interface IGlassDetectionListener {
    /**
     * Callback when detection mode changes
     * @param mode Detection mode
     */
    void onModeChange(int mode);

    /**
     * Face detection callback (can be used to update face tracking boxes)
     * @param faceModels Face model list
     */
    void onFaceTrack(in List<FaceModel> faceModels);

    /**
     * Filter the best face image (can be used for online face recognition interface calls)
     * @param processedFaceModels Processed face model list
     */
    void onProcessedFaceModels(in List<FaceModel> processedFaceModels);

    /**
     * License plate detection callback
     * @param lprModel License plate model
     */
    void onLPRTrack(in LPRModel lprModel);
}
```

<a id="iresultcallback"></a>

**IResultCallback**

```java
interface IResultCallback {

    void  onSuccess(in RecognizePersonInfo data);

    void onFailed(int code, String errormsg);
}
```

<a id="8-connectivity-classic-bluetooth"></a>

<a id="connectivity-peripherals"></a>

## 8 Connectivity: Classic Bluetooth

<a id="ibtservice"></a>

**IBTService: Classic Bluetooth Service**

```kotlin
interface IBTService {

    /**
     * Get connected Bluetooth devices
     */
    List<BluetoothDevice> getConnectDevices();

    /**
     * Allow the device to be discoverable
     */
    void makeDeviceDiscoverable();

    /**
     * Set classic Bluetooth event callback
     */
    void setClassicBTListener(IClassicBTListener listener);

    /**
     * Remove classic Bluetooth event callback
     */
    void removeBlueToothServerListener(IClassicBTListener listener);

    /**
     * Get classic Bluetooth connection status
     */
    boolean isConnect();
}
```

<a id="iclassicbtlistener"></a>

**IClassicBTListener**

```java
interface IClassicBTListener {
    /**
     * Callback when a classic Bluetooth device connects successfully
     * @param device Connected device information
     */
    void onClientConnected(in BluetoothDevice device);

    /**
     * Callback when a classic Bluetooth device connection is interrupted
     * @param device Interrupted device information
     */
    void onClientDisconnected(in BluetoothDevice device);

    /**
     * A connection was rejected
     * @param device Information about the device whose connection was rejected
     */
    void onConnectionRejected(in BluetoothDevice device);
}
```

## 9 Peripheral Capability: Bluetooth Ring

<a id="ibluetoothringservice"></a>

**IBluetoothRingService: Bluetooth Ring Service**

```kotlin
interface IBluetoothRingService {
     /**
        * Set Bluetooth ring connection status callback
        * @param listener Callback instance
        */
       void setBluetoothRingState(IBluetoothRingConnectListener listener);

       /**
        * Check whether the ring is connected
        * @return Connection status
        */
       boolean isRingConnect();

       /**
        * Get the connected ring device
        * @return Bluetooth device instance
        */
       BluetoothDeviceBean getRingConnectDevice();

       /**
        * Release resources
        */
       void release();


}
```

<a id="ibluetoothringconnectlistener"></a>

**IBluetoothRingConnectListener**

```java
interface IBluetoothRingConnectListener {

        /**
         * Ring connection status
         * @param BluetoothDeviceBean Bluetooth ring device information
         * @param connect Whether connected
         */
       void onConnect(in BluetoothDeviceBean bean, boolean connect);

}
```



## 10 Offline Recognition Capabilities

<a id="iofflinerecserver"></a>

**IOfflineRecServer: Offline Recognition Service**

```java
interface IOfflineRecServer {

    /**
     * Start recognition
     * @param sceneId Scene ID
     * @param mode Recognition mode(@AIRecgMode)
     * @param listener
     */
    void startRecognition(String sceneId, int mode,IGlassRecListener listener);

    /**
     * Stop recognition
     *  @param sceneId Scene ID
     *  @param listener
     */
    void stopRecognition(String sceneId,IGlassRecListener listener);

    /**
     * Check and update the person database
     *  @param sceneId Scene ID
     *  @param callback
     */
    void checkUpdateLibVersion(String sceneId, CheckUpdateCallback callback);

    /**
     * Check whether the person database for the scene exists
     * @param sceneId
     */
    boolean isExistLib(String sceneId);

    /**
     * Get person details
     * @param personnelId
     * @param callback Result callback
     */
    void getPersonnelInfo(String personnelId,ResultCallback callback);

    /**
     * Get small face image
     * @param frameId
     * @param Bitmap
     */
    Bitmap getFaceSamllBitmap(long frameId,long trackId);

    /**
     * Get small face image (rounded corners)
     * @param frameId
     * @param Bitmap
     */
    Bitmap getFaceRoundCornerSamllBitmap(long frameId,long trackId);

    /**
     * Report face recognition result
     * $param face: Face data
     */
    void submitRecognizedFaceInfo(in RecognizeFaceSubmitInfo info, in Bitmap face);
}
```

<a id="iofflinefeaturerecservice"></a>

**IOfflineFeatureRecService**

```kotlin
interface IOfflineFeatureRecService {
    /**
     * Add feature library
     * @param featureName Feature library name
     * @param featurePath Feature library file path
     */
    void addFaceFeatureFile(String featureName, String featurePath);

    /**
     * Remove feature library
     * @param featureName Feature library name
     */
    void removeFaceFeature(String featureName);

    /**
     * Start recognition
     * @param mode Recognition mode (@AIRecgMode)
     * @param listener Recognition result callback listener
     */
    void startRecognition(int mode, IGlassRecListener listener);

    /**
     * Stop recognition
     * @param listener Recognition result callback listener
     */
    void stopRecognition(IGlassRecListener listener);

    /**
     * Get small face image
     * @param frameId
     * @param Bitmap
     */
    Bitmap getFaceSamllBitmap(long frameId,long trackId);

    /**
     * Get small face image (rounded corners)
     * @param frameId
     * @param Bitmap
     */
    Bitmap getFaceRoundCornerSamllBitmap(long frameId,long trackId);

}
```

<a id="iglassreclistener"></a>

**IGlassRecListener**

```java
interface IGlassRecListener {
    /**
     * Unified unique callback identifier method (implemented by the base class)
     */
    String getCallbackId();
    /**
     * Callback when detection mode changes
     * @param mode Recognition mode; value comes from AIRecgMode
     */
    void onModeChange(int mode);

    /**
     * Face detection callback
     * @param faceModels Face model list
     */
    void onFaceTrack(in List<FaceModel> faceModels);

    /**
     * License plate detection callback
     * @param lprModel License plate model
     */
    void onLPRTrack(in LPRModel lprModel);

    /**
     * Face recognition result callback
     * @param result Face recognition result
     */
    void onFaceRecognize(in FaceRecgResult result);


    /**
     * Face recognition result callback
     * @param result Face recognition result
     */
    void onFaceRecognizeNotInLib(in FaceRecgResult result);

    /**
     * Engine initialization callback
     */
    void onEngineInit();

}
```



<a id="11-device-and-system-capabilities"></a>

<a id="device-system-capabilities"></a>

## 11 Device and System Capabilities

<a id="ideviceservice"></a>

**IDeviceService: Device and System Service**

```kotlin
interface IDeviceService {

    String getDeviceName();

    String getSerialNumber();


    String getSystemVersion();

    DeviceStatusInfo getDeviceStatusInfo();


    /**
     * Switch mic beam (~3 s; keep UI responsive)
     * @param state
    0: Near-field directional — wearer only; suppress ambience
    1: Far-field directional — attenuate wearer; ±60° azimuth/el cone; range depends on SNR (~55 dB source @ 3 m in quiet rooms)
    3: Omnidirectional — capture from all directions, including wearer
     */
    fun switchMicScene(state: Int)
    void switchMicScene(int scene);


    void setVolume(int value);

    void setBrighing(int value);


    void reboot();


    void sendCusEvent(int eventCode,String extra);



    void setDeviceEventListener(DeviceEventListener listener);


    void setBatteryUpdateListener(BatteryUpdateListener listener);

    /**
     * Set system time
     * @param timestamp Timestamp
     */
    void setSystemTime(long timestamp);

    /**
     * Query all installed package information
     * @return Key-value pairs with package names as keys
     */
    Map<String, AppPackageInfo> queryAllPackages();



      /**
       * Set capture light
       * @param timestamp Timestamp
        */
     void setCameraLedEnable(boolean enable);



      /**
       * Set network access mode: 0 phone access; 1 glasses access
       * @param timestamp Timestamp
        */
     void setNetworkType(int type);



     int getNetworkType();


    /**
     * Configure app visibility and the display order of third-party apps
     * Used to batch configure the show/hide status of built-in system apps and third-party apps.
     *
     * @param appConfig App configuration information, including:
     *                  - appList: List of built-in system apps to hide
     *                  - thirdApps: Third-party app list, which will be displayed at the front
     * @param callback Set result callback; success=true indicates success, false indicates failure
     *
     */
     void configureAppVisibility(in  GlassAppConfig appConfig, IAppVisibilityListener callback);

    /**
     * Set the time synchronization server address
     * Supports HTTP/HTTPS and NTP protocols, and automatically identifies the protocol type based on the URL
     *
     * @param serverUrl Time server address, supporting the following formats:
     *                  - HTTP/HTTPS protocol: https://time.example.com or http://time.example.com
     *                  - NTP protocol: ntp.example.com or 192.168.1.100
     *                  - null or empty string: Use the default NTP protocol and public NTP servers
     *
     * @note If the URL starts with http:// or https://, HTTP is used to obtain the time
     *       Otherwise, NTP is used (standard UDP protocol, port 123)
     */
    void setTimeServer(String serverUrl);

    /**
     * Get the currently configured time server address
     *
     * @return Currently configured time server address; returns null if not configured
     */
    String getTimeServer();
}

```

<a id="iappvisibilitylistener"></a>

**IAppVisibilityListener**

```java
/**
 * App visibility setting callback interface
 */
interface IAppVisibilityListener {
    /**
     * Callback for setting app visibility
     * @param success true indicates success, false indicates failure
     */
    void onResult(boolean success);
}

```

<a id="deviceeventlistener"></a>

**DeviceEventListener**

```java
interface DeviceEventListener {
    void onDeviceEvent(int eventCode,String extra);


    void onCusEvent(int eventCode,String extra);
}
```

<a id="batteryupdatelistener"></a>

**BatteryUpdateListener**

```java
interface BatteryUpdateListener {
    void onBatteryStatsuUpdate(int powrNumber,boolean charging);
}
```

## 12 ASR Speech-to-Text

<a id="iasrservice"></a>

**IAsrService: ASR Speech-to-Text Service**

```java
interface IAsrService {

       /**
          *Start ASR task
          * @param callback Callback function returned by ASR
          */
         void startSpeech( SpeechCallback callback);

         /**
          *End ASR task
          */
         void stopSpeech();

}
```

<a id="speechcallback"></a>

**SpeechCallback**

```java
interface SpeechCallback {
  /**
       * ASR recognition started
       */
      void onStart();
      /**
       * Intermediate ASR recognition result
       * @param content Recognized content
       */
      void onIntermediateVad(String content);

      /**
       * Final ASR recognition result
       * @param content Recognized content
       */
      void onAsrComplete(String content);

      /**
       * Exception callback
       * @param code Error code
       */
      void onError(int code);


      void onServiceConnectState(boolean connect);

      /**
       * Final ASR recognition result with intent recognition
       * @param content Recognized content
       * @param intent Intent enum
       * @param intentJson Intent JSON
       */
      void onAsrCompleteWithIntent(String content, int intent, String intentJson);
}
```
