| register(callback: AsyncCallback\<number>): void | Registers the continuation management service and obtains a token. This API does not involve any filter parameters and uses an asynchronous callback to return the result.|
| register(options: ContinuationExtraParams, callback: AsyncCallback\<number>): void | Registers the continuation management service and obtains a token. This API uses an asynchronous callback to return the result.|
| register(options?: ContinuationExtraParams): Promise\<number> | Registers the continuation management service and obtains a token. This API uses a promise to return the result.|
| on(type: "deviceConnect", token: number, callback: Callback\<Array\<ContinuationResult>>): void | Subscribes to device connection events. This API uses an asynchronous callback to return the result.|
| on(type: "deviceDisconnect", token: number, callback: Callback\<Array\<string>>): void | Subscribes to device disconnection events. This API uses an asynchronous callback to return the result.|
| startDeviceManager(token: number, callback: AsyncCallback\<void>): void | Starts the device selection module to show the list of available devices. This API does not involve any filter parameters and uses an asynchronous callback to return the result.|
| startDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback\<void>): void | Starts the device selection module to show the list of available devices. This API uses an asynchronous callback to return the result.|
| startDeviceManager(token: number, options?: ContinuationExtraParams): Promise\<void> | Starts the device selection module to show the list of available devices. This API uses a promise to return the result.|
| updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback\<void>): void | Instructs the device selection module to update the device connection state. This API uses an asynchronous callback to return the result.|
| updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState): Promise\<void> | Instructs the device selection module to update the device connection state. This API uses a promise to return the result.|
| unregister(token: number, callback: AsyncCallback\<void>): void | Deregisters the continuation management service. This API uses an asynchronous callback to return the result.|
| unregister(token: number): Promise\<void> | Deregisters the continuation management service. This API uses a promise to return the result.|
| registerContinuation(callback: AsyncCallback\<number>): void | Registers the continuation management service and obtains a token. This API does not involve any filter parameters and uses an asynchronous callback to return the result.|
| registerContinuation(options: ContinuationExtraParams, callback: AsyncCallback\<number>): void | Registers the continuation management service and obtains a token. This API uses an asynchronous callback to return the result.|
| registerContinuation(options?: ContinuationExtraParams): Promise\<number> | Registers the continuation management service and obtains a token. This API uses a promise to return the result.|
| on(type: "deviceSelected", token: number, callback: Callback\<Array\<ContinuationResult>>): void | Subscribes to device connection events. This API uses an asynchronous callback to return the result.|
| on(type: "deviceUnselected", token: number, callback: Callback\<Array\<ContinuationResult>>): void | Subscribes to device disconnection events. This API uses an asynchronous callback to return the result.|
| startContinuationDeviceManager(token: number, callback: AsyncCallback\<void>): void | Starts the device selection module to show the list of available devices. This API does not involve any filter parameters and uses an asynchronous callback to return the result.|
| startContinuationDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback\<void>): void | Starts the device selection module to show the list of available devices. This API uses an asynchronous callback to return the result.|
| startContinuationDeviceManager(token: number, options?: ContinuationExtraParams): Promise\<void> | Starts the device selection module to show the list of available devices. This API uses a promise to return the result.|
| updateContinuationState(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback\<void>): void | Instructs the device selection module to update the device connection state. This API uses an asynchronous callback to return the result.|
| updateContinuationState(token: number, deviceId: string, status: DeviceConnectState): Promise\<void> | Instructs the device selection module to update the device connection state. This API uses a promise to return the result.|
| unregisterContinuation(token: number, callback: AsyncCallback\<void>): void | Deregisters the continuation management service. This API uses an asynchronous callback to return the result.|
| unregisterContinuation(token: number): Promise\<void> | Deregisters the continuation management service. This API uses a promise to return the result.|
## How to Develop
1. Import the **continuationManager** module.
...
...
@@ -36,7 +36,7 @@ As the entry of the ability continuation capability, **continuationManager** is
import continuationManager from '@ohos.continuation.continuationManager';
```
2. Apply for permissions required for cross-device continuation or collaboration operations.
2. Apply for the **DISTRIBUTED_DATASYNC** permission.
The permission application operation varies according to the ability model in use. In the FA mode, add the required permission in the `config.json` file, as follows:
...
...
@@ -57,6 +57,7 @@ As the entry of the ability continuation capability, **continuationManager** is
```ts
import abilityAccessCtrl from "@ohos.abilityAccessCtrl";
import bundle from '@ohos.bundle';
import featureAbility from '@ohos.ability.featureAbility';
async function requestPermission() {
let permissions: Array<string> = [
...
...
@@ -124,7 +125,8 @@ As the entry of the ability continuation capability, **continuationManager** is
// If the permission is not granted, call requestPermissionsFromUser to apply for the permission.
@@ -140,13 +142,16 @@ As the entry of the ability continuation capability, **continuationManager** is
```ts
let token: number = -1; // Used to save the token returned after the registration. The token will be used when listening for device connection/disconnection events, starting the device selection module, and updating the device connection state.
4. Listen for the device connection/disconnection state.
...
...
@@ -156,28 +161,31 @@ As the entry of the ability continuation capability, **continuationManager** is
```ts
let remoteDeviceId: string = ""; // Used to save the information about the remote device selected by the user, which will be used for cross-device continuation or collaboration.
// The token parameter is the token obtained during the registration.
The preceding multi-device collaboration operation is performed across devices in the stage model. For details about this operation in the FA model, see [Page Ability Development](https://gitee.com/openharmony/docs/blob/master/en/application-dev/ability/fa-pageability.md).
...
...
@@ -189,35 +197,43 @@ As the entry of the ability continuation capability, **continuationManager** is
let deviceConnectStatus: continuationManager.DeviceConnectState = continuationManager.DeviceConnectState.CONNECTED;
// The token parameter is the token obtained during the registration, and the remoteDeviceId parameter is the remoteDeviceId obtained.
let unselectedDeviceId: string = deviceIds[0]; // Assign the deviceId of the first deselected remote device to the unselectedDeviceId variable.
let deviceConnectStatus: continuationManager.DeviceConnectState = continuationManager.DeviceConnectState.DISCONNECTING; // Device disconnected.
// Update the device connection state.
let unselectedDeviceId: string = continuationResults[0].id; // Assign the deviceId of the first deselected remote device to the unselectedDeviceId variable.
let deviceConnectStatus: continuationManager.DeviceConnectState = continuationManager.DeviceConnectState.DISCONNECTING; // Device disconnected.
// The token parameter is the token obtained during the registration, and the unselectedDeviceId parameter is the unselectedDeviceId obtained.
6. If you do not need to perform cross-device migration or collaboration operations, you can deregister the continuation management service, by passing the token obtained during the registration.
...
...
@@ -244,10 +264,14 @@ As the entry of the ability continuation capability, **continuationManager** is
The sample code is as follows:
```ts
// The token parameter is the token obtained during the registration.
The **distributedMissionManager** module implements system mission management across devices. You can use the APIs provided by this module to register or deregister a mission status listener, and start or stop synchronizing the remote mission list.
The **distributedMissionManager** module implements system mission management across devices. You can use the APIs provided by this module to register or deregister a mission status listener, start or stop synchronizing a remote mission list, and continue a mission on a remote device.
> **NOTE**
>
...
...
@@ -48,16 +48,23 @@ Registers a mission status listener. This API uses an asynchronous callback to r
console.log('NotifyNetDisconnect state '+JSON.stringify(state));
| onContinueDone | function | Yes | No | Callback used to notify the user that the mission continuation is complete and return the continuation result. |
This error code is reported when the system ability is abnormal.
**Possible Causes**
The possible causes are as follows:
1. The DMS service is not started.
2. The **binder** object of DMS is not obtained.
3. Other services on which ability continuation depends are not started or the **binder** object is not obtained.
**Solution**
Try again later or restart the device.
## 16600002 The specified token or callback is not registered.
**Description**
This error code is reported if the token or callback used in an API of **continuationManager** is not registered when the API is called.
**Error Message**
The specified token or callback is not registered.
**Possible Causes**
The specified token or callback is not registered.
**Solution**
Register the token or callback before calling the API.
## 16600003 The number of token registration times has reached the upper limit.
**Description**
This error code is reported when the number of times that the **continuationManager.registerContinuation** API is called has reached the upper limit.
**Error Message**
The number of token registration times has reached the upper limit.
**Possible Causes**
The number of token registration times has reached the upper limit.
**Solution**
Use a registered token. Do not register the token too frequently.
## 16600004 The specified callback has been registered.
**Description**
This error code is reported when the **continuationManager.on** API is called with a callback the same as a previous one.
**Error Message**
The specified callback has been registered.
**Possible Causes**
The same callback is used for repeated registration.
**Solution**
Use a different callback for registration.
## 16300501 The system ability works abnormally.
**Description**
This error code is reported when the system ability is abnormal.
**Error Message**
The system ability works abnormally.
**Possible Causes**
The possible causes are as follows:
1. The DMS service is not started.
2. The **binder** object of DMS is not obtained.
3. Other services on which ability continuation depends are not started or the **binder** object is not obtained.
**Solution**
Try again later or restart the device.
## 16300502 Failed to get the missionInfo of the specified missionId.
**Description**
This error code is reported when calling the **distributedMissionManager.continueMission** API fails.
**Error Message**
Failed to get the missionInfo of the specified missionId.
**Possible Causes**
The possible causes are as follows:
1. The mission ID is incorrect.
2. The mission information corresponding to the mission ID does not exist.
**Solution**
Verify the mission ID.
## 16300503 The application is not installed on the remote end and installation-free is not supported.
**Description**
This error code is reported if the application is not installed on the remote end and the installation-free feature is not supported when the **distributedMissionManager.continueMission** API is called.
**Error Message**
The application is not installed on the remote end and installation-free is not supported.
**Possible Causes**
The application to continue is not installed on the remote end, and the installation-free feature is not supported.
**Solution**
1. Check whether the application has been installed on the remote end.
2. Check whether the remote end supports installation-free.
## 16300504 The application is not installed on the remote end and installation-free is supported. Try again with the freeInstall flag.
**Description**
This error code is reported if the application is not installed on the remote end and installation-free is supported when the **distributedMissionManager.continueMission** API is called.
**Error Message**
The application is not installed on the remote end and installation-free is supported. Try again with the freeInstall flag.
**Possible Causes**
The application to continue is not installed on the remote end, and installation-free is supported. However, the **freeInstall** flag is not carried.
**Solution**
Try again with the **freeInstall** flag.
## 16300505 The operation device must be the device where the application to be continued is currently located or the target device.
**Description**
This error code is reported if the operation device is not the device where the application to be continued is currently located (source device) or the target device when the **distributedMissionManager.continueMission** API is called.
**Error Message**
The operation device must be the device where the application to be continued is currently located or the target device.
**Possible Causes**
The operation device is not the source or target device.
**Solution**
Use the source or target device for the operation.
## 16300506 The local continuation task is already in progress.
**Description**
This error code is reported if the local continuation task is in progress when the **distributedMissionManager.continueMission** API is called.
**Error Message**
The local continuation task is already in progress.
**Possible Causes**
The continuation task has been initiated and is not complete yet.
**Solution**
Wait until the continuation task is complete.
## 3 Failed to flatten the object.
**Description**
This error code is reported if the system parameter **DMS_PROXY_INTERFACE_TOKEN** fails flattening when an API of **continuationManager** is called.
**Error Message**
Failed to flatten the object.
**Possible Causes**
The system parameter **DMS_PROXY_INTERFACE_TOKEN** fails to be written in serialization.
**Solution**
Make sure the system functions properly. Restart the system when needed.
## 7 The object is null.
**Error Message**
The object is null.
**Description**
This error code is reported if DMS and other objects are empty or reading in serialization fails when an API of **continuationManager** is called.
**Possible Causes**
The possible causes are as follows:
1. Reading the input parameters in serialization fails.
2. The DMS service is not started or the **binder** object is not obtained.
3. Other services on which DMS depends are not started or the **binder** object is not obtained.
**Solution**
1. Check whether the input parameters are valid.
2. Check whether the DMS service is started normally. Restart the service or device when needed.
3. Check whether other services on which DMS depends are started normally. Restart the services or device when needed.
## 29360207 The number of registrations has reached the upper limit.
**Description**
This error code is reported when the number of times that the **continuationManager.register** API is called exceeds the upper limit.
**Error Message**
The number of registrations has reached the upper limit.
**Possible Causes**
The number of device registration times has reached the upper limit.
**Solution**
Restart the service and avoid frequent registration.
## 29360208 The token is not registered.
**Description**
This error code is reported when an API of **continuationManager** is called with an unregistered token.
**Error Message**
The token is not registered.
**Possible Causes**
The token is not registered.
**Solution**
Register a token and use it in the API.
## 29360209 The callback has been registered.
**Description**
This error code is reported when the **continuationManager.on** API is called with a callback the same as a previous one.
**Error Message**
The callback has been registered.
**Possible Causes**
The specified callback has been registered.
**Solution**
Do not use the same callback for repeated registration.
## 29360210 The callback is not registered.
**Description**
This error code is reported when the **off**, **updateConnectStatus**, or **startDeviceManager** API of **continuationManager** is called with a callback that has been not registered by calling **on**.
**Error Message**
The callback is not registered.
**Possible Causes**
The specified callback is not registered.
**Solution**
Register a callback and use it in the API.
## 29360211 Failed to connect to the ability.
**Description**
This error code is reported if connection to the specified ability fails when the **startDeviceManager** API of **continuationManager** is called.
**Error Message**
Failed to connect to the ability.
**Possible Causes**
The specified token is invalid or the target ability is not working properly.
**Solution**
Check whether the token is valid and whether the corresponding ability is normal. Restart the service or device when needed.
## 29360214 The type of callback is not supported.
**Description**
This error code is reported when the **callback** parameter in the **on** or **off** API of **continuationManager** is set to an incorrect type.
**Error Message**
The type of callback is not supported.
**Possible Causes**
The callback type is not supported.
**Solution**
Pass a supported type for the **callback** parameter.
## 29360215 Invalid connection state.
**Description**
This error code is reported when the **status** parameter in the **updateConnectStatus** API of **continuationManager** is invalid.
**Error Message**
Invalid connection state.
**Possible Causes**
The **status** parameter is invalid.
**Solution**
Use a valid value for the **status** parameter.
## 29360216 Invalid continuation mode.
**Error Message**
Invalid continuation mode.
**Description**
This error code is reported when the **ContinuationExtraParams.continuationMode** parameter in the **register** or **startDeviceManager** API of **continuationManager** is invalid.
**Possible Causes**
The **ContinuationExtraParams.continuationMode** parameter is invalid.
**Solution**
Use a valid value for the **ContinuationExtraParams.continuationMode** parameter.
The API is supported, but certain features in the API, such as the algorithm, are not supported.
**Procedure**
**Solution**
Modify the parameters and use the features supported.
...
...
@@ -23,7 +23,7 @@ Failed to obtain `${messageInfo}`. It is not set in ParamSet.
The key parameter is not set.
**Procedure**
**Solution**
1. Determine the missing parameter from the error message.
2. Set the parameter.
...
...
@@ -38,7 +38,7 @@ Invalid `${messageInfo}`.
An invalid parameter is found.
**Procedure**
**Solution**
1. Determine the invalid parameter from the error message.
2. Correct the invalid parameter.
...
...
@@ -55,7 +55,7 @@ Failed to write the file.
The file operation failed.
**Procedure**
**Solution**
1. Check whether the disk space is used up and whether the file system is abnormal.
2. Clear the disk space.
...
...
@@ -72,7 +72,7 @@ Failed to obtain messages from IPC.
IPC failed.
**Procedure**
**Solution**
Locate and rectify the IPC failure.
...
...
@@ -89,7 +89,7 @@ The algorithm library operation fails. The possible causes include the following
1. The encryption and decryption on the algorithm library failed due to incorrect ciphertext data.
2. Incorrect key parameters exist.
**Procedure**
**Solution**
1. Check and correct the ciphertext data.
2. Check and correct the key parameters.
...
...
@@ -107,7 +107,7 @@ The possible causes include the following:
1. The key is configured with the user access control attribute and becomes invalid after the password is cleared.
2. The key is configured with the user access control attribute and becomes invalid after a new biometric feature is enrolled.
**Procedure**
**Solution**
1. Locate the cause of the authentication failure based on the log.
2. If the authentication fails due to the access control attribute configured, the key cannot be used any more.
...
...
@@ -122,7 +122,7 @@ The authentication token verification failed.
The authentication token verification failed due to an incorrect challenge value.
**Procedure**
**Solution**
1. Check whether the challenge for userIAM authentication is correctly assembled.
2. If the challenge value is incorrect, modify the assembly mode, use the bytes generated by HUKS to assembly challenge value, and pass it to userIAM for authentication.
...
...
@@ -137,7 +137,7 @@ The Authentication token timed out.
The authentication failed because the authentication token timed out.
**Procedure**
**Solution**
The difference between the current time and the authentication token generation time must be less than the timeout interval. Otherwise, the access will be rejected.
...
...
@@ -151,7 +151,7 @@ The number of key operation sessions has reached the limit.
The number of concurrent key operation sessions has reached the maximum (15).
**Procedure**
**Solution**
1. Check whether there are multiple key session operations (**init** operations) for the same application. If yes, modify the code to avoid concurrent invoking.
2. If the key operation sessions are set up for different applications, wait until the sessions are released.
...
...
@@ -166,7 +166,7 @@ The entity does not exist.
The key corresponding to the key alias does not exist.
**Procedure**
**Solution**
1. Check whether the key alias is misspelled.
2. Check whether the key corresponding to the key alias is successfully generated.
@@ -14,7 +14,7 @@ This error code is reported if the HDI service is abnormal when the **on**, **on
The HDI service is abnormal.
**Procedure**
**Solution**
1. Retry the operation at a specified interval (for example, 1s) or at an exponential increase interval.
2. If the operation fails for three consecutive times, stop the retry. You can also attempt to obtain the sensor list to check for device availability.
@@ -15,7 +15,7 @@ This error code is reported if the HDI service is abnormal or the device is occu
1. The HDI service is abnormal.
2. The device is occupied.
**Procedure**
**Solution**
1. Retry the operation at a specified interval or at an exponential increase interval. If the operation fails for three consecutive times, stop the retry. You can also obtain the vibrator list to check for device availability.