add dfx recovery api in newest namesapce.

Signed-off-by: zhancaijin <zhancaijin1@huawei.com>
This commit is contained in:
zhancaijin 2022-10-24 16:29:28 +08:00
parent cb292266fb
commit 727be4be91
3 changed files with 56 additions and 19 deletions

11
api/@ohos.app.ability.Ability.d.ts vendored Executable file → Normal file
View File

@ -309,4 +309,15 @@ export default class Ability {
* @since 9 * @since 9
*/ */
onMemoryLevel(level: AbilityConstant.MemoryLevel): void; onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
/**
* Called back when an ability prepares to save.
* @param reason state type when save.
* @param wantParam Indicates the want parameter.
* @return 0 if ability agrees to save data successfully, otherwise errcode.
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @stagemodelonly
* @since 9
*/
onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: any}): AbilityConstant.OnSaveResult;
} }

View File

@ -58,6 +58,7 @@ declare namespace AbilityConstant {
START_ABILITY = 1, START_ABILITY = 1,
CALL = 2, CALL = 2,
CONTINUATION = 3, CONTINUATION = 3,
APP_RECOVERY = 4,
} }
/** /**
@ -113,6 +114,34 @@ declare namespace AbilityConstant {
WINDOW_MODE_SPLIT_SECONDARY = 101, WINDOW_MODE_SPLIT_SECONDARY = 101,
WINDOW_MODE_FLOATING = 102, WINDOW_MODE_FLOATING = 102,
} }
/**
* Type of onSave result.
* @enum { number }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @stagemodelonly
* @since 9
*/
export enum OnSaveResult {
ALL_AGREE = 0,
CONTINUATION_REJECT = 1,
CONTINUATION_MISMATCH = 2,
RECOVERY_AGREE = 3,
RECOVERY_REJECT = 4,
ALL_REJECT,
}
/**
* Type of save state.
* @enum { number }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @stagemodelonly
* @since 9
*/
export enum StateType {
CONTINUATION = 0,
APP_RECOVERY = 1,
}
} }
export default AbilityConstant export default AbilityConstant

View File

@ -15,17 +15,16 @@
/** /**
* This module provides the capability to app receovery. * This module provides the capability to app receovery.
* * @import appReceovery from '@ohos.app.ability.appRecovery'
* @since 9
* @syscap SystemCapability.Ability.AbilityRuntime.Core * @syscap SystemCapability.Ability.AbilityRuntime.Core
* @import appReceovery from '@ohos.application.appRecovery' * @since 9
*/ */
declare namespace appReceovery { declare namespace appReceovery {
/** /**
* The type of no restart mode. * The type of no restart mode.
* * @enum { number }
* @since 9
* @syscap SystemCapability.Ability.AbilityRuntime.Core * @syscap SystemCapability.Ability.AbilityRuntime.Core
* @since 9
*/ */
enum RestartFlag { enum RestartFlag {
/** /**
@ -56,9 +55,9 @@ declare namespace appReceovery {
/** /**
* The type of when to save. * The type of when to save.
* * @enum { number }
* @since 9
* @syscap SystemCapability.Ability.AbilityRuntime.Core * @syscap SystemCapability.Ability.AbilityRuntime.Core
* @since 9
*/ */
enum SaveOccasionFlag { enum SaveOccasionFlag {
/** /**
@ -74,9 +73,9 @@ declare namespace appReceovery {
/** /**
* The type of where to save. * The type of where to save.
* * @enum { number }
* @since 9
* @syscap SystemCapability.Ability.AbilityRuntime.Core * @syscap SystemCapability.Ability.AbilityRuntime.Core
* @since 9
*/ */
enum SaveModeFlag { enum SaveModeFlag {
/** /**
@ -92,31 +91,29 @@ declare namespace appReceovery {
/** /**
* Enable appRecovery and app supports save and restore * Enable appRecovery and app supports save and restore
*
* @since 9
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @param restart no restart mode * @param restart no restart mode
* @param saveOccasion The type of When to save * @param saveOccasion The type of When to save
* @param saveMode The type of where to save * @param saveMode The type of where to save
* @StageModelOnly * @syscap SystemCapability.Ability.AbilityRuntime.Core
* @stagemodelonly
* @since 9
*/ */
function enableAppRecovery(restart?: RestartFlag, saveOccasion?: SaveOccasionFlag, saveMode?: SaveModeFlag) : void; function enableAppRecovery(restart?: RestartFlag, saveOccasion?: SaveOccasionFlag, saveMode?: SaveModeFlag) : void;
/** /**
* Restart App when called * Restart App when called
*
* @since 9
* @syscap SystemCapability.Ability.AbilityRuntime.Core * @syscap SystemCapability.Ability.AbilityRuntime.Core
* @stagemodelonly
* @since 9
*/ */
function restartApp(): void; function restartApp(): void;
/** /**
* Save App state data when called * Save App state data when called
*
* @since 9
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @return true if save data successfully, otherwise false * @return true if save data successfully, otherwise false
* @StageModelOnly * @syscap SystemCapability.Ability.AbilityRuntime.Core
* @stagemodelonly
* @since 9
*/ */
function saveAppState(): boolean; function saveAppState(): boolean;
} }