目录

ServiceCollaboration

Overview

Provides NDK APIs for device interconnectivity of Service Collaboration Kit.

System capability: SystemCapability.Collaboration.Service

Since: 5.0.0(12)

Summary

[h2]Files

Name Description
service_collaboration_api.h Defines the device interconnectivity APIs and relevant types.

[h2]Structs

Name Description
struct ServiceCollaboration_CollaborationDeviceInfo Device information object obtained through device interconnectivity, including basic device information and capability types.
struct ServiceCollaboration_CollaborationDeviceInfoSets Peer device information object set obtained through HMS_ServiceCollaboration_GetCollaborationDeviceInfos.
struct ServiceCollaboration_SelectInfo Selected device information when HMS_ServiceCollaboration_StartCollaboration is used to trigger device interconnectivity.
struct ServiceCollaborationCallback

Callback method passed to HMS_ServiceCollaboration_StartCollaboration or

HMS_ServiceCollaboration_StartCollaborationV2, which is used to transfer the status information of device interconnectivity.

struct ServiceCollaboration_SelectInfoV2 Selected device information when HMS_ServiceCollaboration_StartCollaborationV2 is used to trigger device interconnectivity. Devices with the image and video upload capabilities can be selected.

[h2]Macros

Name Description
COLLABORATIONDEVICEINFO_DEVICENETWORKID_MAXLENGTH 65 Maximum length of the device network ID.
COLLABORATIONDEVICEINFO_DEVICENAME_MAXLENGTH 128 Maximum length of the device name.
SERVICE_COLLABORATION_URI_MAXLENGTH 4096 Maximum length of the URI of the sandbox directory.

[h2]Types

Name Description
typedef enum ServiceCollaborationFilterType ServiceCollaborationFilterType Device interconnectivity capability types.
typedef enum ServiceCollaborationDataType ServiceCollaborationDataType Types of the data returned.
typedef enum ServiceCollaborationEventCode ServiceCollaborationEventCode Enumeration of error codes.
typedef enum CollaborationDeviceFilterType CollaborationDeviceFilterType Device types of the callee in device interconnectivity.
typedef struct ServiceCollaboration_CollaborationDeviceInfo ServiceCollaboration_CollaborationDeviceInfo Device information object.
typedef struct ServiceCollaboration_CollaborationDeviceInfoSets ServiceCollaboration_CollaborationDeviceInfoSets Set of device information objects.
typedef struct ServiceCollaboration_SelectInfo ServiceCollaboration_SelectInfo Information about the selected device.
typedef struct ServiceCollaborationCallback ServiceCollaborationCallback

Callback method passed to HMS_ServiceCollaboration_StartCollaboration or

HMS_ServiceCollaboration_StartCollaborationV2, which is used to transfer the status information of device interconnectivity.

typedef struct ServiceCollaboration_SelectInfoV2 ServiceCollaboration_SelectInfoV2 Selected device information when HMS_ServiceCollaboration_StartCollaborationV2 is used to trigger device interconnectivity. Devices with the image and video upload capabilities can be selected.

[h2]Enums

Name Description

ServiceCollaborationFilterType {

TAKE_PHOTO = 1,

SCAN_DOCUMENT = 2,

IMAGE_PICKER = 3,

VIDEO_PICKER = 5,

IMAGE_VIDEO_PICKER = 6

}

Device interconnectivity capability types.

ServiceCollaborationDataType{

IMAGE = 1,

VIDEO = 2

}

Types of the data returned.

ServiceCollaborationEventCode{

LAST_DATA_BACK = 1001202000,

PEER_CANCEL = 1001202001,

NETWORK_ERROR = 1001202002,

PEER_WIFI_NOT_OPEN = 1001202004,

LOCAL_WIFI_NOT_OPEN = 1001202005,

DATA_BACK_START = 1001202006,

MIDDLE_DATA_BACK = 1001202007,

TIMEOUT_AUTO_CANCEL = 1001202008,

DATA_READ_FAILED = 1001202009,

LINK_SHUTDOWN = 1001202011,

REMOTE_HOTSPOT_CONFLICT = 1001202013,

REMOTE_DISTRIBUTED_SERVICES_CONFLICT = 1001202014,

SEND_VIDEO_SUCCESS = 1001202015,

MULTI_VIDEO_SENDING_BACK = 1001202016,

STORE_VIDEO_FAIL = 1001202017

}

Enumeration of error codes.

CollaborationDeviceFilterType {

PHONE = 1,

TABLET = 2,

PC_2IN1 = 3

}

Device types of the callee in device interconnectivity.

[h2]Functions

Name Description

ServiceCollaboration_CollaborationDeviceInfoSets* HMS_ServiceCollaboration_GetCollaborationDeviceInfos(

uint32_t fileterNum, ServiceCollaborationFilterType serviceFileterTypes[])

Obtains the list of devices that support related capabilities.

uint32_t HMS_ServiceCollaboration_StartCollaboration(

const ServiceCollaboration_SelectInfo* selectService, ServiceCollaborationCallback* callback)

Starts the capability of sending images across devices.
int32_t HMS_ServiceCollaboration_StopCollaboration(uint32_t collaborationId) Disables the device interconnectivity capability.

uint32_t HMS_ServiceCollaboration_StartCollaborationV2(

const ServiceCollaboration_SelectInfoV2* selectService, ServiceCollaborationCallback* callback)

Starts the capability of sending images and videos across devices.

ServiceCollaboration_CollaborationDeviceInfoSets*

HMS_ServiceCollaboration_GetCollaborationDeviceInfosV2 (

uint32_t deviceFilterNum, CollaborationDeviceFilterType

deviceFilterTypes[], uint32_t serviceFilterNum,

ServiceCollaborationFilterType serviceFilterTypes[])

Obtains the list of specified devices that support related capabilities.

Macro Description

[h2]COLLABORATIONDEVICEINFO_DEVICENETWORKID_MAXLENGTH

#define COLLABORATIONDEVICEINFO_DEVICENETWORKID_MAXLENGTH   65

Description

Maximum length of the device network ID.

Since: 5.0.0(12)

[h2]COLLABORATIONDEVICEINFO_DEVICENAME_MAXLENGTH

#define COLLABORATIONDEVICEINFO_DEVICENAME_MAXLENGTH   128

Description

Maximum length of the device name.

Since: 5.0.0(12)

[h2]SERVICE_COLLABORATION_URI_MAXLENGTH

#define SERVICE_COLLABORATION_URI_MAXLENGTH   4096

Description

Maximum length of the URI of the app sandbox directory.

Since: 6.1.0(23)

Type Definition Description

[h2]ServiceCollaboration_CollaborationDeviceInfo

typedef struct ServiceCollaboration_CollaborationDeviceInfo ServiceCollaboration_CollaborationDeviceInfo

Description

Device information object.

Since: 5.0.0(12)

[h2]ServiceCollaboration_CollaborationDeviceInfoSets

typedef struct ServiceCollaboration_CollaborationDeviceInfoSets ServiceCollaboration_CollaborationDeviceInfoSets

Description

Set of device information objects.

Since: 5.0.0(12)

[h2]ServiceCollaboration_SelectInfo

typedef struct ServiceCollaboration_SelectInfo ServiceCollaboration_SelectInfo

Description

Information about the selected device.

Since: 5.0.0(12)

[h2]ServiceCollaborationCallback

typedef struct ServiceCollaborationCallback ServiceCollaborationCallback

Description

Callback method passed to HMS_ServiceCollaboration_StartCollaboration or HMS_ServiceCollaboration_StartCollaborationV2 to pass the status information of device interconnectivity.

Since: 5.0.0(12)

[h2]ServiceCollaborationFilterType

typedef enum ServiceCollaborationFilterType ServiceCollaborationFilterType

Description

Device interconnectivity capability types.

Since: 5.0.0(12)

[h2]ServiceCollaborationDataType

typedef enum ServiceCollaborationDataType ServiceCollaborationDataType

Description

Types of the data returned.

Since: 5.0.0(12)

[h2]ServiceCollaborationEventCode

typedef enum ServiceCollaborationEventCode ServiceCollaborationEventCode

Description

Enumeration of error codes.

Since: 5.0.0(12)

[h2]ServiceCollaboration_SelectInfoV2

typedef struct ServiceCollaboration_SelectInfoV2 ServiceCollaboration_SelectInfoV2

Description

Selected device information when HMS_ServiceCollaboration_StartCollaborationV2 is used to trigger device interconnectivity. Devices with the image and video upload capabilities can be selected.

Since: 6.1.0(23)

Enum Description

[h2]ServiceCollaborationFilterType

enum ServiceCollaborationFilterType

Description

Device interconnectivity capability types.

Since: 5.0.0(12)

Enumerated Value Description
TAKE_PHOTO = 1 Takes a photo.
SCAN_DOCUMENT = 2 Performs scanning.
IMAGE_PICKER = 3 Selects an image from Gallery.
VIDEO_PICKER = 5

Selects a video from Gallery.

Since: 6.1.0(23)

IMAGE_VIDEO_PICKER = 6

Selects an image or video from Gallery.

Since: 6.1.0(23)

[h2]CollaborationDeviceFilterType

enum CollaborationDeviceFilterType

Description

Device types of the callee in device interconnectivity.

Since: 6.1.0(23)

Enumerated Value Description
PHONE Phone
TABLET Tablet
PC_2IN1 PC/2-in-1 device

[h2]ServiceCollaborationDataType

enum ServiceCollaborationDataType

Description

Types of the data returned.

Since: 5.0.0(12)

Enumerated Value Description
IMAGE = 1 Image
VIDEO = 2

Video

Since: 6.1.0(23)

[h2]ServiceCollaborationEventCode

enum ServiceCollaborationEventCode

Description

Enumeration of error codes.

Since: 5.0.0(12)

Enumerated Value Description
LAST_DATA_BACK = 1001202000 The last data packet has been received.
PEER_CANCEL = 1001202001 Canceled on the remote device.
NETWORK_ERROR = 1001202002 Network error.
PEER_WIFI_NOT_OPEN = 1001202004 The WLAN is not enabled on the remote device.
LOCAL_WIFI_NOT_OPEN = 1001202005 The WLAN is not enabled on the local device.
DATA_BACK_START = 1001202006 Data returning started.
MIDDLE_DATA_BACK = 1001202007 Intermediate data received.
TIMEOUT_AUTO_CANCEL = 1001202008 Data receiving canceled due to timeout.
DATA_READ_FAILED = 1001202009 Failed to read data.
LINK_SHUTDOWN = 1001202011 The link is disconnected.
REMOTE_HOTSPOT_CONFLICT = 1001202013

A link conflict occurred because the hotspot is enabled on the remote device.

Since: 5.1.0(18)

REMOTE_DISTRIBUTED_SERVICES_CONFLICT = 1001202014

A link conflict occurred because the remote device was interconnecting with another device.

Since: 5.1.0(18)

SEND_VIDEO_SUCCESS = 1001202015

The video backhaul is successful.

Since: 6.1.0(23)

MULTI_VIDEO_SENDING_BACK = 1001202016

Start multiple video backhauls.

Since: 6.1.0(23)

STORE_VIDEO_FAIL = 1001202017

Failed to backhaul the video due to memory shortage.

Since: 6.1.0(23)

Function Description

[h2]HMS_ServiceCollaboration_GetCollaborationDeviceInfos

ServiceCollaboration_CollaborationDeviceInfoSets* HMS_ServiceCollaboration_GetCollaborationDeviceInfos(
    uint32_t fileterNum, ServiceCollaborationFilterType serviceFileterTypes[]);

Description

Obtains the list of devices that support related capabilities.

Since: 5.0.0(12)

Parameters:

Name Description
uint32_t fileterNum Total number of service capability types.
ServiceCollaborationFilterType serviceFileterTypes[] Array of required service capability types.

Returns:

ServiceCollaboration_CollaborationDeviceInfoSets, which is a set of device information objects.

[h2]HMS_ServiceCollaboration_GetCollaborationDeviceInfosV2

ServiceCollaboration_CollaborationDeviceInfoSets* HMS_ServiceCollaboration_GetCollaborationDeviceInfosV2(
    uint32_t deviceFilterNum, CollaborationDeviceFilterType deviceFilterTypes[], uint32_t serviceFilterNum, ServiceCollaborationFilterType serviceFilterTypes[]);

Description

Obtains the list of specified devices that support related capabilities.

Since: 6.1.0(23)

Parameters:

Name Description
uint32_t deviceFilterNum Total number of device types.
CollaborationDeviceFilterType deviceFilterTypes[] Array of device types of the called party.
uint32_t serviceFilterNum Total number of service capability types.
ServiceCollaborationFilterType serviceFilterTypes[] Total number of service capability types.

Returns:

ServiceCollaboration_CollaborationDeviceInfoSets, which is a set of device information objects.

[h2]HMS_ServiceCollaboration_StartCollaboration

uint32_t HMS_ServiceCollaboration_StartCollaboration(
    const ServiceCollaboration_SelectInfo* selectService, ServiceCollaborationCallback* callback);

Description

Starts the capability of sending images across devices.

Since: 5.0.0(12)

Parameters:

Name Description
const ServiceCollaboration_SelectInfo* selectService Information about the selected device.
ServiceCollaborationCallback* callback Callback method, which is used to transfer the status information of device interconnectivity.

Returns:

collaborationId of the uint32_t type, which is the unique ID of a device interconnectivity session.

[h2]HMS_ServiceCollaboration_StopCollaboration

int32_t HMS_ServiceCollaboration_StopCollaboration(uint32_t collaborationId);

Description

Disables the device interconnectivity capability.

Since: 5.0.0(12)

Parameters:

Name Description
uint32_t collaborationId

Unique ID of a device interconnectivity session, which can be obtained from the return value of HMS_ServiceCollaboration_StartCollaboration or

HMS_ServiceCollaboration_StartCollaborationV2.

Returns:

Stop is returned. The value 0 indicates success.

[h2]HMS_ServiceCollaboration_StartCollaborationV2

uint32_t HMS_ServiceCollaboration_StartCollaborationV2(
    const ServiceCollaboration_SelectInfoV2* selectService, ServiceCollaborationCallback* callback);

Description

Starts the capability of sending images and videos across devices.

Since: 6.1.0(23)

Parameters:

Name Description
const ServiceCollaboration_SelectInfoV2* selectService Information about the selected device.
ServiceCollaborationCallback* callback Callback method, which is used to transfer the status information of device interconnectivity.

Returns:

collaborationId of the uint32_t type, which is the unique ID of a device interconnectivity session.