2022-10-17 11:06:52 +00:00
|
|
|
/*
|
2023-05-06 06:59:50 +00:00
|
|
|
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
2022-10-17 11:06:52 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"),
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2023-12-11 09:08:03 +00:00
|
|
|
/**
|
|
|
|
* @file
|
2024-01-08 07:25:39 +00:00
|
|
|
* @kit AbilityKit
|
2023-12-11 09:08:03 +00:00
|
|
|
*/
|
|
|
|
|
2023-05-06 06:59:50 +00:00
|
|
|
import rpc from './@ohos.rpc';
|
|
|
|
import ServiceExtensionContext from './application/ServiceExtensionContext';
|
2022-10-18 12:14:04 +00:00
|
|
|
import Want from './@ohos.app.ability.Want';
|
|
|
|
import { Configuration } from './@ohos.app.ability.Configuration';
|
2022-10-17 11:06:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* class of service extension ability.
|
2023-05-06 06:59:50 +00:00
|
|
|
*
|
2022-10-17 11:06:52 +00:00
|
|
|
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
2022-10-17 11:11:12 +00:00
|
|
|
* @systemapi
|
2022-11-16 03:03:26 +00:00
|
|
|
* @StageModelOnly
|
2022-10-17 11:11:12 +00:00
|
|
|
* @since 9
|
2022-10-17 11:06:52 +00:00
|
|
|
*/
|
|
|
|
export default class ServiceExtensionAbility {
|
2023-04-21 09:47:24 +00:00
|
|
|
/**
|
|
|
|
* Indicates service extension ability context.
|
2023-05-06 06:59:50 +00:00
|
|
|
*
|
2023-05-26 02:24:08 +00:00
|
|
|
* @type { ServiceExtensionContext }
|
2023-04-21 09:47:24 +00:00
|
|
|
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
|
|
|
* @systemapi
|
|
|
|
* @StageModelOnly
|
|
|
|
* @since 9
|
|
|
|
*/
|
|
|
|
context: ServiceExtensionContext;
|
2022-10-17 11:06:52 +00:00
|
|
|
|
2023-04-21 09:47:24 +00:00
|
|
|
/**
|
|
|
|
* Called back when a service extension is started for initialization.
|
2023-05-06 06:59:50 +00:00
|
|
|
*
|
2023-04-21 09:47:24 +00:00
|
|
|
* @param { Want } want - Indicates the want of created service extension.
|
|
|
|
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
|
|
|
* @systemapi
|
|
|
|
* @StageModelOnly
|
|
|
|
* @since 9
|
|
|
|
*/
|
|
|
|
onCreate(want: Want): void;
|
2022-10-17 11:06:52 +00:00
|
|
|
|
2023-04-21 09:47:24 +00:00
|
|
|
/**
|
|
|
|
* Called back before a service extension is destroyed.
|
2023-05-06 06:59:50 +00:00
|
|
|
*
|
2023-04-21 09:47:24 +00:00
|
|
|
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
|
|
|
* @systemapi
|
|
|
|
* @StageModelOnly
|
|
|
|
* @since 9
|
|
|
|
*/
|
|
|
|
onDestroy(): void;
|
2022-10-17 11:06:52 +00:00
|
|
|
|
2023-04-21 09:47:24 +00:00
|
|
|
/**
|
|
|
|
* Called back when a service extension is started.
|
2023-05-06 06:59:50 +00:00
|
|
|
*
|
2023-04-21 09:47:24 +00:00
|
|
|
* @param { Want } want - Indicates the want of service extension to start.
|
|
|
|
* @param { number } startId - Indicates the number of times the service extension has been started.
|
|
|
|
* The {@code startId} is incremented by 1 every time the service extension is started.
|
|
|
|
* For example, if the service extension has been started for six times.
|
|
|
|
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
|
|
|
* @systemapi
|
|
|
|
* @StageModelOnly
|
|
|
|
* @since 9
|
|
|
|
*/
|
|
|
|
onRequest(want: Want, startId: number): void;
|
2022-10-17 11:06:52 +00:00
|
|
|
|
2023-04-21 09:47:24 +00:00
|
|
|
/**
|
|
|
|
* Called back when a service extension is first connected to an ability.
|
2023-05-06 06:59:50 +00:00
|
|
|
*
|
2023-04-21 09:47:24 +00:00
|
|
|
* @param { Want } want - Indicates connection information about the Service ability.
|
2023-05-06 06:59:50 +00:00
|
|
|
* @returns { rpc.RemoteObject | Promise<rpc.RemoteObject> } A RemoteObject for communication between the client
|
|
|
|
* and server.
|
2023-04-21 09:47:24 +00:00
|
|
|
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
|
|
|
* @systemapi
|
|
|
|
* @StageModelOnly
|
|
|
|
* @since 9
|
|
|
|
*/
|
|
|
|
onConnect(want: Want): rpc.RemoteObject | Promise<rpc.RemoteObject>;
|
2022-10-17 11:06:52 +00:00
|
|
|
|
2023-04-21 09:47:24 +00:00
|
|
|
/**
|
|
|
|
* Called back when all abilities connected to a service extension are disconnected.
|
2023-05-06 06:59:50 +00:00
|
|
|
*
|
2023-04-21 09:47:24 +00:00
|
|
|
* @param { Want } want - Indicates disconnection information about the service extension.
|
2023-05-06 06:59:50 +00:00
|
|
|
* @returns { void | Promise<void> } the promise returned by the function.
|
2023-04-21 09:47:24 +00:00
|
|
|
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
|
|
|
* @systemapi
|
|
|
|
* @StageModelOnly
|
|
|
|
* @since 9
|
|
|
|
*/
|
|
|
|
onDisconnect(want: Want): void | Promise<void>;
|
2022-10-17 11:06:52 +00:00
|
|
|
|
2023-04-21 09:47:24 +00:00
|
|
|
/**
|
|
|
|
* Called when a new client attempts to connect to a service extension after all previous client connections to it
|
|
|
|
* are disconnected.
|
2023-05-06 06:59:50 +00:00
|
|
|
*
|
2023-04-21 09:47:24 +00:00
|
|
|
* @param { Want } want - Indicates the want of the service extension being connected.
|
|
|
|
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
|
|
|
* @systemapi
|
|
|
|
* @StageModelOnly
|
|
|
|
* @since 9
|
|
|
|
*/
|
|
|
|
onReconnect(want: Want): void;
|
2022-10-17 11:06:52 +00:00
|
|
|
|
2023-04-21 09:47:24 +00:00
|
|
|
/**
|
|
|
|
* Called when the system configuration is updated.
|
2023-05-06 06:59:50 +00:00
|
|
|
*
|
2023-04-21 09:47:24 +00:00
|
|
|
* @param { Configuration } newConfig - Indicates the updated configuration.
|
|
|
|
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
|
|
|
* @systemapi
|
|
|
|
* @StageModelOnly
|
|
|
|
* @since 9
|
|
|
|
*/
|
|
|
|
onConfigurationUpdate(newConfig: Configuration): void;
|
2022-10-17 11:06:52 +00:00
|
|
|
|
2023-04-21 09:47:24 +00:00
|
|
|
/**
|
|
|
|
* Called when dump client information is required.
|
|
|
|
* It is recommended that developers don't DUMP sensitive information.
|
2023-05-06 06:59:50 +00:00
|
|
|
*
|
2023-04-21 09:47:24 +00:00
|
|
|
* @param { Array<string> } params - Indicates the params from command.
|
|
|
|
* @returns { Array<string> } The dump info array.
|
|
|
|
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
|
|
|
* @systemapi
|
|
|
|
* @StageModelOnly
|
|
|
|
* @since 9
|
|
|
|
*/
|
|
|
|
onDump(params: Array<string>): Array<string>;
|
2022-10-17 11:06:52 +00:00
|
|
|
}
|