diff --git a/api/@ohos.application.AbilityLifecycleCallback.d.ts b/api/@ohos.application.AbilityLifecycleCallback.d.ts index 13ec3ef6bbb44a9788bafff2b82417468ad05822..77e747eb78d62338fe0fd3fe9a778b2edc55914d 100644 --- a/api/@ohos.application.AbilityLifecycleCallback.d.ts +++ b/api/@ohos.application.AbilityLifecycleCallback.d.ts @@ -24,7 +24,7 @@ import Ability from "./@ohos.application.Ability"; */ export default class AbilityLifecycleCallback { /** - * Called back when the ability is started for initialization. + * Called back when an ability is started for initialization. * * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore @@ -34,7 +34,7 @@ export default class AbilityLifecycleCallback { onAbilityCreate(ability: Ability): void; /** - * Called back when the ability window stage is created. + * Called back when an ability window stage is created. * * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore @@ -44,7 +44,7 @@ export default class AbilityLifecycleCallback { onAbilityWindowStageCreate(ability: Ability): void; /** - * Called back when the ability window stage is created. + * Called back when an ability window stage is destroyed. * * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore @@ -54,7 +54,7 @@ export default class AbilityLifecycleCallback { onAbilityWindowStageDestroy(ability: Ability): void; /** - * Called back when the ability window stage is created. + * Called back when an ability is destroyed. * * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore @@ -64,7 +64,7 @@ export default class AbilityLifecycleCallback { onAbilityDestroy(ability: Ability): void; /** - * Called back when the ability window stage is created. + * Called back when the state of an ability changes to foreground. * * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore @@ -74,7 +74,7 @@ export default class AbilityLifecycleCallback { onAbilityForeground(ability: Ability): void; /** - * Called back when the ability window stage is created. + * Called back when the state of an ability changes to background. * * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore @@ -84,7 +84,7 @@ export default class AbilityLifecycleCallback { onAbilityBackground(ability: Ability): void; /** - * Called back when the ability window stage is created. + * Called back when an ability prepares to continue. * * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore diff --git a/api/@ohos.application.EnvironmentCallback.d.ts b/api/@ohos.application.EnvironmentCallback.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..b19bd5792eff52fc21ea06e0d6501cf543ba9f7c --- /dev/null +++ b/api/@ohos.application.EnvironmentCallback.d.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 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. + */ + +import { Configuration } from './@ohos.application.Configuration'; + +/** + * The environment callback. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @permission N/A + */ +export default class EnvironmentCallback { + /** + * Called when the system configuration is updated. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param config: Indicates the updated configuration. + * @StageModelOnly + */ + onConfigurationUpdated(config: Configuration): void; +} diff --git a/api/application/ApplicationContext.d.ts b/api/application/ApplicationContext.d.ts index eb6b30bf9afdacda5a528d96c29cd4d52595eed5..2f605c61cf00e4bfa78422ab766a12527bcc5db8 100755 --- a/api/application/ApplicationContext.d.ts +++ b/api/application/ApplicationContext.d.ts @@ -16,6 +16,7 @@ import { AsyncCallback } from "../basic"; import Context from "./Context"; import AbilityLifecycleCallback from "../@ohos.application.AbilityLifecycleCallback"; +import EnvironmentCallback from "../@ohos.application.EnvironmentCallback"; /** * The context of an application. It allows access to application-specific resources. @@ -48,4 +49,27 @@ export default class ApplicationContext extends Context { */ unregisterAbilityLifecycleCallback(callbackId: number, callback: AsyncCallback): void; unregisterAbilityLifecycleCallback(callbackId: number): Promise; + + /** + * Register environment callback. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param callback The environment callback. + * @return Returns the number code of the callback. + * @StageModelOnly + */ + registerEnvironmentCallback(callback: EnvironmentCallback): number; + + /** + * Unregister environment callback. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param callbackId Indicates the number code of the callback. + * @return - + * @StageModelOnly + */ + unregisterEnvironmentCallback(callbackId: number, callback: AsyncCallback): void; + unregisterEnvironmentCallback(callbackId: number): Promise; }