• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
16/**
17 * @file
18 * @kit AbilityKit
19 */
20
21import AbilityConstant from './@ohos.app.ability.AbilityConstant';
22import ExtensionAbility from './@ohos.app.ability.ExtensionAbility';
23import type UIExtensionContentSession from './@ohos.app.ability.UIExtensionContentSession';
24import type UIExtensionContext from './application/UIExtensionContext';
25import type Want from './@ohos.app.ability.Want';
26
27/**
28 * The class of UI extension ability.
29 *
30 * @extends ExtensionAbility
31 * @syscap SystemCapability.Ability.AbilityRuntime.Core
32 * @StageModelOnly
33 * @since 10
34 */
35export default class UIExtensionAbility extends ExtensionAbility {
36  /**
37   * Indicates configuration information about an UI extension ability context.
38   *
39   * @type { UIExtensionContext }
40   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
41   * @StageModelOnly
42   * @since 10
43   */
44  context: UIExtensionContext;
45
46  /**
47   * Called back when an UI extension is started for initialization.
48   *
49   * @syscap SystemCapability.Ability.AbilityRuntime.Core
50   * @StageModelOnly
51   * @since 10
52   */
53   /**
54   * Called back when an UI extension is started for initialization.
55   *
56   * @param { AbilityConstant.LaunchParam } launchParam - Indicates the LaunchParam information about UIExtensionAbility.
57   * @syscap SystemCapability.Ability.AbilityRuntime.Core
58   * @StageModelOnly
59   * @since 12
60   */
61  onCreate(launchParam: AbilityConstant.LaunchParam): void;
62
63  /**
64   * Called back when an UI extension session is created.
65   *
66   * @param { Want } want - Indicates the want info of the UI extension.
67   * @param { UIExtensionContentSession } session - Indicates the session of the UI extension page.
68   * @syscap SystemCapability.Ability.AbilityRuntime.Core
69   * @StageModelOnly
70   * @since 10
71   */
72  onSessionCreate(want: Want, session: UIExtensionContentSession): void;
73
74  /**
75   * Called back when an UI extension session is destroyed.
76   *
77   * @param { UIExtensionContentSession } session - Indicates the session of the UI extension page.
78   * @syscap SystemCapability.Ability.AbilityRuntime.Core
79   * @StageModelOnly
80   * @since 10
81   */
82  onSessionDestroy(session: UIExtensionContentSession): void;
83
84  /**
85   * Called back when the state of an UI extension changes to foreground.
86   *
87   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
88   * @StageModelOnly
89   * @since 10
90   */
91  onForeground(): void;
92
93  /**
94   * Called back when the state of an UI extension changes to background.
95   *
96   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
97   * @StageModelOnly
98   * @since 10
99   */
100  onBackground(): void;
101
102  /**
103   * Called back before an UI extension is destroyed.
104   *
105   * @returns { void | Promise<void> } the promise returned by the function.
106   * @syscap SystemCapability.Ability.AbilityRuntime.Core
107   * @StageModelOnly
108   * @since 10
109   */
110  onDestroy(): void | Promise<void>;
111}
112