• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2025 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 rpc from './@ohos.rpc';
22import AppServiceExtensionContext from './application/AppServiceExtensionContext';
23import Want from './@ohos.app.ability.Want';
24import ExtensionAbility from './@ohos.app.ability.ExtensionAbility';
25
26/**
27 * class of app service extension ability.
28 *
29 * @extends ExtensionAbility
30 * @syscap SystemCapability.Ability.AbilityRuntime.Core
31 * @stagemodelonly
32 * @since 20
33 */
34export default class AppServiceExtensionAbility extends ExtensionAbility {
35  /**
36   * Indicates app service extension ability context.
37   *
38   * @type { AppServiceExtensionContext }
39   * @syscap SystemCapability.Ability.AbilityRuntime.Core
40   * @stagemodelonly
41   * @since 20
42   */
43  context: AppServiceExtensionContext;
44
45  /**
46   * Called back when an app service extension is started for initialization.
47   *
48   * @param { Want } want - Indicates the want of created app service extension.
49   * @syscap SystemCapability.Ability.AbilityRuntime.Core
50   * @stagemodelonly
51   * @since 20
52   */
53  onCreate(want: Want): void;
54
55  /**
56   * Called back before an app service extension is destroyed.
57   *
58   * @syscap SystemCapability.Ability.AbilityRuntime.Core
59   * @stagemodelonly
60   * @since 20
61   */
62  onDestroy(): void;
63
64  /**
65   * Called back when an app service extension is started.
66   *
67   * @param { Want } want - Indicates the want of app service extension to start.
68   * @param { number } startId - Indicates the number of times the app service extension has been started.
69   *                             The {@code startId} is incremented by 1 every time the app service extension is started.
70   * @syscap SystemCapability.Ability.AbilityRuntime.Core
71   * @stagemodelonly
72   * @since 20
73   */
74  onRequest(want: Want, startId: number): void;
75
76  /**
77   * Called back when an app service extension is first connected to an ability.
78   *
79   * @param { Want } want - Indicates connection information about the app service ability.
80   * @returns { rpc.RemoteObject } A RemoteObject for communication between the client and server.
81   * @syscap SystemCapability.Ability.AbilityRuntime.Core
82   * @stagemodelonly
83   * @since 20
84   */
85  onConnect(want: Want): rpc.RemoteObject;
86
87  /**
88   * Called back when all abilities connected to an app service extension are disconnected.
89   *
90   * @param { Want } want - Indicates disconnection information about the app service extension.
91   * @syscap SystemCapability.Ability.AbilityRuntime.Core
92   * @stagemodelonly
93   * @since 20
94   */
95  onDisconnect(want: Want): void;
96}
97