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 16/** 17 * @file 18 * @kit DriverDevelopmentKit 19 */ 20 21import type rpc from './@ohos.rpc'; 22import type Want from './@ohos.app.ability.Want'; 23import _DriverExtensionContext from './application/DriverExtensionContext'; 24 25/** 26 * Define a DriverExtensionContext for store context. 27 * 28 * @typedef { _DriverExtensionContext } 29 * @syscap SystemCapability.Driver.ExternalDevice 30 * @since arkts {'1.1':'10', '1.2':'20'} 31 * @arkts 1.1&1.2 32 */ 33export type DriverExtensionContext = _DriverExtensionContext; 34 35/** 36 * class of driver extension ability. 37 * @syscap SystemCapability.Driver.ExternalDevice 38 * @StageModelOnly 39 * @since arkts {'1.1':'10', '1.2':'20'} 40 * @arkts 1.1&1.2 41 */ 42declare class DriverExtensionAbility { 43 /** 44 * Indicates driver extension ability context. 45 * 46 * @type { DriverExtensionContext } 47 * @syscap SystemCapability.Driver.ExternalDevice 48 * @StageModelOnly 49 * @since arkts {'1.1':'10', '1.2':'20'} 50 * @arkts 1.1&1.2 51 */ 52 context: DriverExtensionContext; 53 54 /** 55 * Called back when a driver extension is started for initialization. 56 * @param { Want } want - Indicates the want of created driver extension. 57 * @syscap SystemCapability.Driver.ExternalDevice 58 * @StageModelOnly 59 * @since arkts {'1.1':'10', '1.2':'20'} 60 * @arkts 1.1&1.2 61 */ 62 onInit(want: Want): void; 63 64 /** 65 * Called back before a driver extension is destroyed. 66 * @syscap SystemCapability.Driver.ExternalDevice 67 * @StageModelOnly 68 * @since arkts {'1.1':'10', '1.2':'20'} 69 * @arkts 1.1&1.2 70 */ 71 onRelease(): void; 72 73 /** 74 * Called back when a driver extension is first connected to an ability. 75 * @param { Want } want - Indicates connection information about the Driver ability. 76 * @returns { rpc.RemoteObject | Promise<rpc.RemoteObject> } Rpc remoteObject. 77 * @syscap SystemCapability.Driver.ExternalDevice 78 * @StageModelOnly 79 * @since arkts {'1.1':'10', '1.2':'20'} 80 * @arkts 1.1&1.2 81 */ 82 onConnect(want: Want): rpc.RemoteObject | Promise<rpc.RemoteObject>; 83 84 /** 85 * Called back when all abilities connected to a driver extension are disconnected. 86 * @param { Want } want - Indicates disconnection information about the driver extension. 87 * @returns { void | Promise<void> } 88 * @syscap SystemCapability.Driver.ExternalDevice 89 * @StageModelOnly 90 * @since 10 91 */ 92 onDisconnect(want: Want): void | Promise<void>; 93 94 /** 95 * Called back when all abilities connected to a driver extension are disconnected. 96 * @param { Want } want - Indicates disconnection information about the driver extension. 97 * @returns { undefined | Promise<void> } 98 * @syscap SystemCapability.Driver.ExternalDevice 99 * @stagemodelonly 100 * @since 20 101 * @arkts 1.2 102 */ 103 onDisconnect(want: Want): undefined | Promise<void>; 104 105 /** 106 * Called when dump client information is required. 107 * It is recommended that developers don't DUMP sensitive information. 108 * @param { Array<string> } params - Indicates th e params from command. 109 * @returns { Array<string> } The dump info array. 110 * @syscap SystemCapability.Driver.ExternalDevice 111 * @StageModelOnly 112 * @since arkts {'1.1':'10', '1.2':'20'} 113 * @arkts 1.1&1.2 114 */ 115 onDump(params: Array<string>): Array<string>; 116} 117 118/** 119 * class of driver extension ability. 120 * @syscap SystemCapability.Driver.ExternalDevice 121 * @stagemodelonly 122 * @since arkts {'1.1':'10', '1.2':'20'} 123 * @arkts 1.1&1.2 124 */ 125export default DriverExtensionAbility; 126