From f5af83bbade2d09dc7e60893d1611223c049dcae Mon Sep 17 00:00:00 2001 From: mgceshuang Date: Tue, 26 Jul 2022 11:02:12 +0800 Subject: [PATCH] AppReceovery Signed-off-by: mgceshuang --- api/@ohos.appRecovery.d.ts | 136 +++++++++++++++++++++ api/@ohos.application.Ability.d.ts | 43 +++++++ api/@ohos.application.AbilityConstant.d.ts | 30 ++++- 3 files changed, 208 insertions(+), 1 deletion(-) create mode 100644 api/@ohos.appRecovery.d.ts diff --git a/api/@ohos.appRecovery.d.ts b/api/@ohos.appRecovery.d.ts new file mode 100644 index 0000000000..6b4df30c49 --- /dev/null +++ b/api/@ohos.appRecovery.d.ts @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2022-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This module provides the capability to app receovery. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.Hiview.AppReceovery + * @import import sensor from '@ohos.appReceovery' + */ +declare namespace AppReceovery { + /** + * The type of no restart mode. + * @since 9 + * @syscap SystemCapability.HiviewDFX.Hiview.AppReceovery + */ + enum RestartFlags { + /** + * NONE: no restart restrictions + * @since 9 + */ + NONE = 0, + + /** + * CPP_CRASH_NO_RESTART: Do not restart if process terminates due to cpp exception + * @since 9 + */ + CPP_CRASH_NO_RESTART = 1, + + /** + * JS_CRASH_NO_RESTART: Do not restart if process terminates due to js/ts/ets exception + * @since 9 + */ + JS_CRASH_NO_RESTART = 2, + + /** + * APP_FREEZE_NO_RESTART: Do not restart if process terminates due to appliction not respondong + * @since 9 + */ + APP_FREEZE_NO_RESTART = 4, + + /** + * NO_RESTART: Do not restart + * @since 9 + */ + NO_RESTART = 0xFFFF, + } + + /** + * The type of when to save. + * @since 9 + * @syscap SystemCapability.HiviewDFX.Hiview.AppReceovery + */ + enum SaveFlags { + /** + * SAVE_DEFAULT is saving with an optimal configuration + * and developers don't need to care about specific mode.default saving lifecycle. + * @since 9 + */ + SAVE_DEFAULT = 0, + + /** + * SAVE_WHEN_ERROR is saving when an error occurs. + * @since 9 + */ + SAVE_WHEN_ERROR = 1, + + /** + * SAVE_WHEN_CREATE is saving on create. + * @since 9 + */ + SAVE_WHEN_CREATE = 2, + + /** + * SAVE_WHEN_CREATE is saving on background. + * @since 9 + */ + SAVE_WHEN_BACKGROUND = 4, + } + + /** + * The type of where to save. + * @since 9 + * @syscap SystemCapability.HiviewDFX.Hiview.AppReceovery + */ + enum SaveMode { + /** + * SAVE_DEFAULT is saving with an optimal configuration + * and developers don't need to care about specific mode. default saving to shared memory. + * @since 9 + */ + SAVE_DEFAULT = 0, + + /** + * SAVE_WITH_DB is saving to db. + * @since 9 + */ + SAVE_WITH_DB = 1, + + /** + * SAVE_WITH_FILE is saving to file. + * @since 9 + */ + SAVE_WITH_FILE = 2, + + /** + * SAVE_WITH_SHARED_MEMORY is saving to shared memory. + * @since 9 + */ + SAVE_WITH_SHARED_MEMORY = 4, + } + + /** + * enable appRecovery and app supports save and restore + * @since 9 + * @syscap SystemCapability.HiviewDFX.Hiview.AppReceovery + * @param restartFlags no restart mode + * @param saveFlags The type of When to save + * @param saveMode The type of where to save + */ + function enableAppRecovery(restartFlags: RestartFlags, saveFlags: SaveFlags, saveMode: SaveMode) : void; + } + +export default AppReceovery; \ No newline at end of file diff --git a/api/@ohos.application.Ability.d.ts b/api/@ohos.application.Ability.d.ts index 4642593dcd..436330f494 100755 --- a/api/@ohos.application.Ability.d.ts +++ b/api/@ohos.application.Ability.d.ts @@ -302,4 +302,47 @@ export default class Ability { * @StageModelOnly */ dump(params: Array): Array; + + /** + * Called back when an ability prepares to restore. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param reason state type when restore. + * @param wantParam Indicates the want parameter. + * @StageModelOnly + */ + onRestoreState(reason: AbilityConstant.StateType, wantParam : {[key: string]: any}): void; + + /** + * Called back when an ability prepares to save. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param reason state type when save. + * @param wantParam Indicates the want parameter. + * @return 0 if ability agrees to continue and saves data successfully, otherwise errcode. + * @StageModelOnly + */ + onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: any}): AbilityConstant.OnSaveResult; + + /** + * restore for manual storage. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param reason state type when restore. + * @StageModelOnly + */ + restoreState(reason: AbilityConstant.StateType): void; + + /** + * save data for manual storage. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param reason state type when save. + * @StageModelOnly + */ + saveState(reason: AbilityConstant.StateType): void; } diff --git a/api/@ohos.application.AbilityConstant.d.ts b/api/@ohos.application.AbilityConstant.d.ts index 518bac32dc..a217310d99 100644 --- a/api/@ohos.application.AbilityConstant.d.ts +++ b/api/@ohos.application.AbilityConstant.d.ts @@ -83,11 +83,39 @@ declare namespace AbilityConstant { * @syscap SystemCapability.Ability.AbilityRuntime.Core * @StageModelOnly */ - export enum OnContinueResult { + export enum OnContinueResult { AGREE = 0, REJECT = 1, MISMATCH = 2, } + + /** + * Type of onSave result. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + export enum OnSaveResult { + ALL_AGREE = 0, + MIGRATION_REJECT = 1, + MIGRATION_MISMATCH = 2, + RECOVERY_AGREE = 3, + RECOVERY_REJECT = 4, + ALL_REJECT, + } + + /** + * Type of state type. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + export enum StateType { + MIGRATION = 0, + RECOVERY = 1, + } } export default AbilityConstant -- Gitee