• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 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 ExtensionAbility from './@ohos.app.ability.ExtensionAbility';
22import type Want from './@ohos.app.ability.Want';
23import type UIServiceExtensionContext from './application/UIServiceExtensionContext';
24import type UIServiceHostProxy from './application/UIServiceHostProxy';
25import window from './@ohos.window';
26
27/**
28 * The class of UI service extension ability.
29 *
30 * @extends ExtensionAbility
31 * @syscap SystemCapability.Ability.AbilityRuntime.Core
32 * @systemapi
33 * @stagemodelonly
34 * @since 14
35 */
36export default class UIServiceExtensionAbility extends ExtensionAbility {
37  /**
38   * Indicates configuration information about an UI service extension ability context.
39   *
40   * @type { UIServiceExtensionContext }
41   * @syscap SystemCapability.Ability.AbilityRuntime.Core
42   * @systemapi
43   * @stagemodelonly
44   * @since 14
45   */
46  context: UIServiceExtensionContext;
47
48  /**
49   * Called back when an UI service extension is started for initialization.
50   *
51   * @param { Want } want - Indicates the want of created UI service extension.
52   * @syscap SystemCapability.Ability.AbilityRuntime.Core
53   * @systemapi
54   * @stagemodelonly
55   * @since 14
56   */
57  onCreate(want: Want): void;
58
59  /**
60   * Called back when a UI service extension is started.
61   *
62   * @param { Want } want - Indicates the want of UI service extension to start.
63   * @param { number } startId - Indicates the number of times the UI service extension has been started.
64   *                             The {@code startId} is incremented by 1 every time the UI service extension is started.
65   *                             For example, if the UI service extension has been started for six times.
66   * @syscap SystemCapability.Ability.AbilityRuntime.Core
67   * @systemapi
68   * @stagemodelonly
69   * @since 14
70   */
71  onRequest(want: Want, startId: number): void;
72
73  /**
74   * Called back when a UI service extension is connected to an ability.
75   *
76   * @param { Want } want - Indicates connection information about the UI service ability.
77   * @param { UIServiceHostProxy } proxy - Indicates the UI service host proxy.
78   * @syscap SystemCapability.Ability.AbilityRuntime.Core
79   * @systemapi
80   * @stagemodelonly
81   * @since 14
82   */
83  onConnect(want: Want, proxy: UIServiceHostProxy): void;
84
85  /**
86   * Called back when ability connected to a UI service extension is disconnected.
87   *
88   * @param { Want } want - Indicates disconnection information about the UI service extension.
89   * @param { UIServiceHostProxy } proxy - Indicates the UI service host proxy.
90   * @syscap SystemCapability.Ability.AbilityRuntime.Core
91   * @systemapi
92   * @stagemodelonly
93   * @since 14
94   */
95  onDisconnect(want: Want, proxy: UIServiceHostProxy): void;
96
97  /**
98   * Called back when a window will create.
99   *
100   * @param { window.ExtensionWindowConfig } config - Indicates the extension window config.
101   * @syscap SystemCapability.Ability.AbilityRuntime.Core
102   * @systemapi
103   * @stagemodelonly
104   * @since 14
105   */
106  onWindowWillCreate(config: window.ExtensionWindowConfig): void;
107
108  /**
109   * Called back when a window  is created.
110   *
111   * @param { window.Window } window - Indicates the created Window.
112   * @syscap SystemCapability.Ability.AbilityRuntime.Core
113   * @systemapi
114   * @stagemodelonly
115   * @since 14
116   */
117  onWindowDidCreate(window: window.Window): void;
118
119  /**
120   * Called back when data is sent.
121   *
122   * @param { UIServiceHostProxy } proxy - Indicates the UI service host proxy.
123   * @param { Record<string, Object> } data - Indicates the received data.
124   * @syscap SystemCapability.Ability.AbilityRuntime.Core
125   * @systemapi
126   * @stagemodelonly
127   * @since 14
128   */
129  onData(proxy: UIServiceHostProxy, data: Record<string, Object>): void;
130
131  /**
132   * Called back before a UI service extension is destroyed.
133   *
134   * @syscap SystemCapability.Ability.AbilityRuntime.Core
135   * @systemapi
136   * @stagemodelonly
137   * @since 14
138   */
139  onDestroy(): void;
140}
141