161847f8eSopenharmony_ci/*
261847f8eSopenharmony_ci * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"),
461847f8eSopenharmony_ci * you may not use this file except in compliance with the License.
561847f8eSopenharmony_ci * You may obtain a copy of the License at
661847f8eSopenharmony_ci *
761847f8eSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
861847f8eSopenharmony_ci *
961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and
1361847f8eSopenharmony_ci * limitations under the License.
1461847f8eSopenharmony_ci */
1561847f8eSopenharmony_ci
1661847f8eSopenharmony_ci/**
1761847f8eSopenharmony_ci * @file
1861847f8eSopenharmony_ci * @kit AbilityKit
1961847f8eSopenharmony_ci */
2061847f8eSopenharmony_ci
2161847f8eSopenharmony_ciimport rpc from './@ohos.rpc';
2261847f8eSopenharmony_ciimport ServiceExtensionContext from './application/ServiceExtensionContext';
2361847f8eSopenharmony_ciimport Want from './@ohos.app.ability.Want';
2461847f8eSopenharmony_ciimport { Configuration } from './@ohos.app.ability.Configuration';
2561847f8eSopenharmony_ci
2661847f8eSopenharmony_ci/**
2761847f8eSopenharmony_ci * class of service extension ability.
2861847f8eSopenharmony_ci *
2961847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core
3061847f8eSopenharmony_ci * @systemapi
3161847f8eSopenharmony_ci * @StageModelOnly
3261847f8eSopenharmony_ci * @since 9
3361847f8eSopenharmony_ci */
3461847f8eSopenharmony_ciexport default class ServiceExtensionAbility {
3561847f8eSopenharmony_ci  /**
3661847f8eSopenharmony_ci   * Indicates service extension ability context.
3761847f8eSopenharmony_ci   *
3861847f8eSopenharmony_ci   * @type { ServiceExtensionContext }
3961847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
4061847f8eSopenharmony_ci   * @systemapi
4161847f8eSopenharmony_ci   * @StageModelOnly
4261847f8eSopenharmony_ci   * @since 9
4361847f8eSopenharmony_ci   */
4461847f8eSopenharmony_ci  context: ServiceExtensionContext;
4561847f8eSopenharmony_ci
4661847f8eSopenharmony_ci  /**
4761847f8eSopenharmony_ci   * Called back when a service extension is started for initialization.
4861847f8eSopenharmony_ci   *
4961847f8eSopenharmony_ci   * @param { Want } want - Indicates the want of created service extension.
5061847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
5161847f8eSopenharmony_ci   * @systemapi
5261847f8eSopenharmony_ci   * @StageModelOnly
5361847f8eSopenharmony_ci   * @since 9
5461847f8eSopenharmony_ci   */
5561847f8eSopenharmony_ci  onCreate(want: Want): void;
5661847f8eSopenharmony_ci
5761847f8eSopenharmony_ci  /**
5861847f8eSopenharmony_ci   * Called back before a service extension is destroyed.
5961847f8eSopenharmony_ci   *
6061847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
6161847f8eSopenharmony_ci   * @systemapi
6261847f8eSopenharmony_ci   * @StageModelOnly
6361847f8eSopenharmony_ci   * @since 9
6461847f8eSopenharmony_ci   */
6561847f8eSopenharmony_ci  onDestroy(): void;
6661847f8eSopenharmony_ci
6761847f8eSopenharmony_ci  /**
6861847f8eSopenharmony_ci   * Called back when a service extension is started.
6961847f8eSopenharmony_ci   *
7061847f8eSopenharmony_ci   * @param { Want } want - Indicates the want of service extension to start.
7161847f8eSopenharmony_ci   * @param { number } startId - Indicates the number of times the service extension has been started.
7261847f8eSopenharmony_ci   *                             The {@code startId} is incremented by 1 every time the service extension is started.
7361847f8eSopenharmony_ci   *                             For example, if the service extension has been started for six times.
7461847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
7561847f8eSopenharmony_ci   * @systemapi
7661847f8eSopenharmony_ci   * @StageModelOnly
7761847f8eSopenharmony_ci   * @since 9
7861847f8eSopenharmony_ci   */
7961847f8eSopenharmony_ci  onRequest(want: Want, startId: number): void;
8061847f8eSopenharmony_ci
8161847f8eSopenharmony_ci  /**
8261847f8eSopenharmony_ci   * Called back when a service extension is first connected to an ability.
8361847f8eSopenharmony_ci   *
8461847f8eSopenharmony_ci   * @param { Want } want - Indicates connection information about the Service ability.
8561847f8eSopenharmony_ci   * @returns { rpc.RemoteObject | Promise<rpc.RemoteObject> } A RemoteObject for communication between the client
8661847f8eSopenharmony_ci   *                                                           and server.
8761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
8861847f8eSopenharmony_ci   * @systemapi
8961847f8eSopenharmony_ci   * @StageModelOnly
9061847f8eSopenharmony_ci   * @since 9
9161847f8eSopenharmony_ci   */
9261847f8eSopenharmony_ci  onConnect(want: Want): rpc.RemoteObject | Promise<rpc.RemoteObject>;
9361847f8eSopenharmony_ci
9461847f8eSopenharmony_ci  /**
9561847f8eSopenharmony_ci   * Called back when all abilities connected to a service extension are disconnected.
9661847f8eSopenharmony_ci   *
9761847f8eSopenharmony_ci   * @param { Want } want - Indicates disconnection information about the service extension.
9861847f8eSopenharmony_ci   * @returns { void | Promise<void> } the promise returned by the function.
9961847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
10061847f8eSopenharmony_ci   * @systemapi
10161847f8eSopenharmony_ci   * @StageModelOnly
10261847f8eSopenharmony_ci   * @since 9
10361847f8eSopenharmony_ci   */
10461847f8eSopenharmony_ci  onDisconnect(want: Want): void | Promise<void>;
10561847f8eSopenharmony_ci
10661847f8eSopenharmony_ci  /**
10761847f8eSopenharmony_ci   * Called when a new client attempts to connect to a service extension after all previous client connections to it
10861847f8eSopenharmony_ci   * are disconnected.
10961847f8eSopenharmony_ci   *
11061847f8eSopenharmony_ci   * @param { Want } want - Indicates the want of the service extension being connected.
11161847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
11261847f8eSopenharmony_ci   * @systemapi
11361847f8eSopenharmony_ci   * @StageModelOnly
11461847f8eSopenharmony_ci   * @since 9
11561847f8eSopenharmony_ci   */
11661847f8eSopenharmony_ci  onReconnect(want: Want): void;
11761847f8eSopenharmony_ci
11861847f8eSopenharmony_ci  /**
11961847f8eSopenharmony_ci   * Called when the system configuration is updated.
12061847f8eSopenharmony_ci   *
12161847f8eSopenharmony_ci   * @param { Configuration } newConfig - Indicates the updated configuration.
12261847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
12361847f8eSopenharmony_ci   * @systemapi
12461847f8eSopenharmony_ci   * @StageModelOnly
12561847f8eSopenharmony_ci   * @since 9
12661847f8eSopenharmony_ci   */
12761847f8eSopenharmony_ci  onConfigurationUpdate(newConfig: Configuration): void;
12861847f8eSopenharmony_ci
12961847f8eSopenharmony_ci  /**
13061847f8eSopenharmony_ci   * Called when dump client information is required.
13161847f8eSopenharmony_ci   * It is recommended that developers don't DUMP sensitive information.
13261847f8eSopenharmony_ci   *
13361847f8eSopenharmony_ci   * @param { Array<string> } params - Indicates the params from command.
13461847f8eSopenharmony_ci   * @returns { Array<string> } The dump info array.
13561847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
13661847f8eSopenharmony_ci   * @systemapi
13761847f8eSopenharmony_ci   * @StageModelOnly
13861847f8eSopenharmony_ci   * @since 9
13961847f8eSopenharmony_ci   */
14061847f8eSopenharmony_ci  onDump(params: Array<string>): Array<string>;
14161847f8eSopenharmony_ci}
142