AceAbility, AceDataAbility, AceServiceAbilitypublic interface IAbilityContinuation
Ability to implement migration in a distributed system.
You can use the migration capability provided by the Ability to migrate data between a local device and
a remote device in a distributed system. The ability or ability slice that implements this interface has the
migration capability. You can initiate a migration request by calling Ability#continueAbility() or
AbilitySlice#continueAbility() on the local device, and then implement the methods provided in this
interface to save or restore application data. The saved data is managed by the distributed data management
module. The remote device can obtain and restore the saved data when starting the ability. In this way, the ability
on the local device is migrated to the remote device.
SystemCapability.Aafwk#ABILITY| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
ERR_ABILITY_QUERY_FAILED |
Indicates that the HAP package of the application cannot be found.
|
static int |
ERR_CONTINUE_TIMEOUT |
Indicates that the migration times out.
|
static int |
ERR_DEVICE_OFFLINE |
Indicates that the device goes offline during the migration.
|
static int |
ERR_INSTALL_FREE_NOT_SUPPORTED |
Indicates that the ability to be migrated does not support the installation-free feature.
|
static int |
ERR_NETWORK_UNAVAILABLE |
Indicates that the network of the peer device is unavailable.
|
static int |
ERR_PARAMETER_INVALID |
Indicates that the parameter verification fails.
|
static int |
ERR_PERMISSION_DENIED |
Indicates that the permission verification fails.
|
static int |
ERR_REMOTE_DEVICE_INCOMPATIBLE |
Indicates that the OS version of the peer device is incompatible.
|
static int |
ERR_UNKNOWN |
Indicates that the migration fails.
|
static int |
SUCCESS |
Indicates that the migration is successful.
|
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
onCompleteContinuation(int result) |
Called back when a local ability migration is complete.
|
default void |
onFailedContinuation(int errorCode) |
Called when an error occurred during the migration process of a local ability.
|
default void |
onRemoteTerminated() |
Called to notify the local device when a running ability on the remote device is destroyed after a reversible
migration is performed for the ability from the local device to the remote device.
|
boolean |
onRestoreData(IntentParams restoreData) |
Restores the user data saved during the migration for an ability on the remote device immediately after the
ability is created on the remote device.
|
boolean |
onSaveData(IntentParams saveData) |
Saves the user data (carried in the
IntentParams object) of a local ability generated during runtime. |
boolean |
onStartContinuation() |
Asks a user whether to start the migration.
|
static final int ERR_ABILITY_QUERY_FAILED
This constant is an error code returned to the application via onFailedContinuation(int)
when an error occurred during the ability migration process.
static final int ERR_CONTINUE_TIMEOUT
This constant is an error code returned to the application via onFailedContinuation(int)
when an error occurred during the ability migration process.
static final int ERR_DEVICE_OFFLINE
This constant is an error code returned to the application via onFailedContinuation(int)
when an error occurred during the ability migration process.
static final int ERR_INSTALL_FREE_NOT_SUPPORTED
This constant is an error code returned to the application via onFailedContinuation(int)
when an error occurred during the ability migration process.
static final int ERR_NETWORK_UNAVAILABLE
This constant is an error code returned to the application via onFailedContinuation(int)
when an error occurred during the ability migration process.
static final int ERR_PARAMETER_INVALID
This constant is an error code returned to the application via onFailedContinuation(int)
when an error occurred during the ability migration process.
static final int ERR_PERMISSION_DENIED
This constant is an error code returned to the application via onFailedContinuation(int)
when an error occurred during the ability migration process.
static final int ERR_REMOTE_DEVICE_INCOMPATIBLE
This constant is an error code returned to the application via onFailedContinuation(int)
when an error occurred during the ability migration process.
static final int ERR_UNKNOWN
This constant is a result code returned to the application via onCompleteContinuation(int)
after the migration process is complete.
static final int SUCCESS
This constant is a result code returned to the application via onCompleteContinuation(int)
after the migration process is complete.
boolean onStartContinuation()
This method is called back when a local ability initiates a migration request.
If the Ability does not implement this method, this Ability cannot be migrated, and
false is returned. If the AbilitySlice does not implement this method, it does not affect
whether its host ability can be migrated, and true is returned by default.
true if the user allows the migration; returns false otherwise.boolean onSaveData(IntentParams saveData)
IntentParams object) of a local ability generated during runtime.
After the migration is triggered and the local ability is ready, this method is called when the Distributed
Scheduler Service requests data from the local ability.saveData - Indicates the user data to save.true if the data is successfully saved; returns false otherwise.boolean onRestoreData(IntentParams restoreData)
restoreData - Indicates the user data to restore.true if the data is successfully restored; returns false otherwise.void onCompleteContinuation(int result)
You can define the processing logic after the migration is complete. For example, you can display a prompt to notify the user of the successful migration and then exit the local ability.
result - Indicates the migration result code. The value 0 indicates that the migration is
successful, and -1 indicates that the migration fails.default void onRemoteTerminated()
Ability#continueAbilityReversibly() or
Ability#continueAbilityReversibly(String).default void onFailedContinuation(int errorCode)
You can define the processing logic upon a migration error. For example, you can display a prompt message indicating that the network of the peer device is unavailable.
errorCode - Indicates the migration error code, which is defined in this interface.