1/* 2 * Copyright (c) 2022-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 rpc from './@ohos.rpc'; 22import ServiceExtensionContext from './application/ServiceExtensionContext'; 23import Want from './@ohos.app.ability.Want'; 24import { Configuration } from './@ohos.app.ability.Configuration'; 25 26/** 27 * class of service extension ability. 28 * 29 * @syscap SystemCapability.Ability.AbilityRuntime.Core 30 * @systemapi 31 * @StageModelOnly 32 * @since arkts {'1.1':'9', '1.2':'20'} 33 * @arkts 1.1&1.2 34 */ 35declare class ServiceExtensionAbility { 36 /** 37 * Indicates service extension ability context. 38 * 39 * @type { ServiceExtensionContext } 40 * @syscap SystemCapability.Ability.AbilityRuntime.Core 41 * @systemapi 42 * @StageModelOnly 43 * @since arkts {'1.1':'9', '1.2':'20'} 44 * @arkts 1.1&1.2 45 */ 46 context: ServiceExtensionContext; 47 48 /** 49 * Called back when a service extension is started for initialization. 50 * 51 * @param { Want } want - Indicates the want of created service extension. 52 * @syscap SystemCapability.Ability.AbilityRuntime.Core 53 * @systemapi 54 * @StageModelOnly 55 * @since arkts {'1.1':'9', '1.2':'20'} 56 * @arkts 1.1&1.2 57 */ 58 onCreate(want: Want): void; 59 60 /** 61 * Called back before a service extension is destroyed. 62 * 63 * @syscap SystemCapability.Ability.AbilityRuntime.Core 64 * @systemapi 65 * @StageModelOnly 66 * @since arkts {'1.1':'9', '1.2':'20'} 67 * @arkts 1.1&1.2 68 */ 69 onDestroy(): void; 70 71 /** 72 * Called back when a service extension is started. 73 * 74 * @param { Want } want - Indicates the want of service extension to start. 75 * @param { number } startId - Indicates the number of times the service extension has been started. 76 * The {@code startId} is incremented by 1 every time the service extension is started. 77 * For example, if the service extension has been started for six times. 78 * @syscap SystemCapability.Ability.AbilityRuntime.Core 79 * @systemapi 80 * @StageModelOnly 81 * @since arkts {'1.1':'9', '1.2':'20'} 82 * @arkts 1.1&1.2 83 */ 84 onRequest(want: Want, startId: number): void; 85 86 /** 87 * Called back when a service extension is first connected to an ability. 88 * 89 * @param { Want } want - Indicates connection information about the Service ability. 90 * @returns { rpc.RemoteObject | Promise<rpc.RemoteObject> } A RemoteObject for communication between the client 91 * and server. 92 * @syscap SystemCapability.Ability.AbilityRuntime.Core 93 * @systemapi 94 * @StageModelOnly 95 * @since arkts {'1.1':'9', '1.2':'20'} 96 * @arkts 1.1&1.2 97 */ 98 onConnect(want: Want): rpc.RemoteObject | Promise<rpc.RemoteObject>; 99 100 /** 101 * Called back when all abilities connected to a service extension are disconnected. 102 * 103 * @param { Want } want - Indicates disconnection information about the service extension. 104 * @returns { void | Promise<void> } the promise returned by the function. 105 * @syscap SystemCapability.Ability.AbilityRuntime.Core 106 * @systemapi 107 * @StageModelOnly 108 * @since 9 109 */ 110 onDisconnect(want: Want): void | Promise<void>; 111 112 /** 113 * Called back when all abilities connected to a service extension are disconnected. 114 * 115 * @param { Want } want - Indicates disconnection information about the service extension. 116 * @returns { void } the promise returned by the function. 117 * @syscap SystemCapability.Ability.AbilityRuntime.Core 118 * @systemapi 119 * @StageModelOnly 120 * @since 20 121 * @arkts 1.2 122 */ 123 onDisconnect(want: Want): void; 124 125 /** 126 * Asynchronous callback when all abilities connected to a service extension are disconnected. 127 * The next lifecycle callback onDestroy() will be triggered when the returned Promise object resolves. 128 * 129 * @param { Want } want - Indicates disconnection information about the service extension. 130 * @returns { Promise<void> } the promise returned by the function. 131 * @syscap SystemCapability.Ability.AbilityRuntime.Core 132 * @systemapi 133 * @StageModelOnly 134 * @since 20 135 * @arkts 1.2 136 */ 137 onDisconnectAsync(want: Want): Promise<void>; 138 139 /** 140 * Called when a new client attempts to connect to a service extension after all previous client connections to it 141 * are disconnected. 142 * 143 * @param { Want } want - Indicates the want of the service extension being connected. 144 * @syscap SystemCapability.Ability.AbilityRuntime.Core 145 * @systemapi 146 * @StageModelOnly 147 * @since 9 148 */ 149 onReconnect(want: Want): void; 150 151 /** 152 * Called when the system configuration is updated. 153 * 154 * @param { Configuration } newConfig - Indicates the updated configuration. 155 * @syscap SystemCapability.Ability.AbilityRuntime.Core 156 * @systemapi 157 * @StageModelOnly 158 * @since arkts {'1.1':'9', '1.2':'20'} 159 * @arkts 1.1&1.2 160 */ 161 onConfigurationUpdate(newConfig: Configuration): void; 162 163 /** 164 * Called when dump client information is required. 165 * It is recommended that developers don't DUMP sensitive information. 166 * 167 * @param { Array<string> } params - Indicates the params from command. 168 * @returns { Array<string> } The dump info array. 169 * @syscap SystemCapability.Ability.AbilityRuntime.Core 170 * @systemapi 171 * @StageModelOnly 172 * @since 9 173 */ 174 onDump(params: Array<string>): Array<string>; 175} 176 177export default ServiceExtensionAbility;