1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"), 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import ExtensionAbility from './@ohos.app.ability.ExtensionAbility'; 17import type UIExtensionContentSession from './@ohos.app.ability.UIExtensionContentSession'; 18import type UIExtensionContext from './application/UIExtensionContext'; 19import type Want from './@ohos.app.ability.Want'; 20 21/** 22 * The class of UI extension ability. 23 * 24 * @extends ExtensionAbility 25 * @syscap SystemCapability.Ability.AbilityRuntime.Core 26 * @StageModelOnly 27 * @since 10 28 */ 29export default class UIExtensionAbility extends ExtensionAbility { 30 /** 31 * Indicates configuration information about an UI extension ability context. 32 * 33 * @type { UIExtensionContext } 34 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 35 * @StageModelOnly 36 * @since 10 37 */ 38 context: UIExtensionContext; 39 40 /** 41 * Called back when an UI extension is started for initialization. 42 * 43 * @syscap SystemCapability.Ability.AbilityRuntime.Core 44 * @StageModelOnly 45 * @since 10 46 */ 47 onCreate(): void; 48 49 /** 50 * Called back when an UI extension session is created. 51 * 52 * @param { Want } want - Indicates the want info of the UI extension. 53 * @param { UIExtensionContentSession } session - Indicates the session of the UI extension page. 54 * @syscap SystemCapability.Ability.AbilityRuntime.Core 55 * @StageModelOnly 56 * @since 10 57 */ 58 onSessionCreate(want: Want, session: UIExtensionContentSession): void; 59 60 /** 61 * Called back when an UI extension session is destroyed. 62 * 63 * @param { UIExtensionContentSession } session - Indicates the session of the UI extension page. 64 * @syscap SystemCapability.Ability.AbilityRuntime.Core 65 * @StageModelOnly 66 * @since 10 67 */ 68 onSessionDestroy(session: UIExtensionContentSession): void; 69 70 /** 71 * Called back when the state of an UI extension changes to foreground. 72 * 73 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 74 * @StageModelOnly 75 * @since 10 76 */ 77 onForeground(): void; 78 79 /** 80 * Called back when the state of an UI extension changes to background. 81 * 82 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 83 * @StageModelOnly 84 * @since 10 85 */ 86 onBackground(): void; 87 88 /** 89 * Called back before an UI extension is destroyed. 90 * 91 * @returns { void | Promise<void> } the promise returned by the function. 92 * @syscap SystemCapability.Ability.AbilityRuntime.Core 93 * @StageModelOnly 94 * @since 10 95 */ 96 onDestroy(): void | Promise<void>; 97} 98