1/* 2 * Copyright (c) 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 16import type rpc from './@ohos.rpc'; 17import type Want from './@ohos.app.ability.Want'; 18import _DriverExtensionContext from './application/DriverExtensionContext'; 19 20 21export type DriverExtensionContext = _DriverExtensionContext; 22 23/** 24 * class of driver extension ability. 25 * @syscap SystemCapability.Driver.ExternalDevice 26 * @StageModelOnly 27 * @since 10 28 */ 29export default class DriverExtensionAbility { 30 /** 31 * Indicates driver extension ability context. 32 * @syscap SystemCapability.Driver.ExternalDevice 33 * @StageModelOnly 34 * @since 10 35 */ 36 context: DriverExtensionContext; 37 38 /** 39 * Called back when a driver extension is started for initialization. 40 * @param { Want } want - Indicates the want of created driver extension. 41 * @syscap SystemCapability.Driver.ExternalDevice 42 * @StageModelOnly 43 * @since 10 44 */ 45 onInit(want: Want): void; 46 47 /** 48 * Called back before a driver extension is destroyed. 49 * @syscap SystemCapability.Driver.ExternalDevice 50 * @StageModelOnly 51 * @since 10 52 */ 53 onRelease(): void; 54 55 /** 56 * Called back when a driver extension is first connected to an ability. 57 * @param { Want } want - Indicates connection information about the Driver ability. 58 * @returns { rpc.RemoteObject | Promise<rpc.RemoteObject> } Rpc remoteObject. 59 * @syscap SystemCapability.Driver.ExternalDevice 60 * @StageModelOnly 61 * @since 10 62 */ 63 onConnect(want: Want): rpc.RemoteObject | Promise<rpc.RemoteObject>; 64 65 /** 66 * Called back when all abilities connected to a driver extension are disconnected. 67 * @param { Want } want - Indicates disconnection information about the driver extension. 68 * @returns { void | Promise<void> } 69 * @syscap SystemCapability.Driver.ExternalDevice 70 * @StageModelOnly 71 * @since 10 72 */ 73 onDisconnect(want: Want): void | Promise<void>; 74 75 /** 76 * Called when dump client information is required. 77 * It is recommended that developers don't DUMP sensitive information. 78 * @param { Array<string> } params - Indicates th e params from command. 79 * @returns { Array<string> } The dump info array. 80 * @syscap SystemCapability.Driver.ExternalDevice 81 * @StageModelOnly 82 * @since 10 83 */ 84 onDump(params: Array<string>): Array<string>; 85} 86