• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 10
31 */
32export type DriverExtensionContext = _DriverExtensionContext;
33
34/**
35 * class of driver extension ability.
36 * @syscap SystemCapability.Driver.ExternalDevice
37 * @StageModelOnly
38 * @since 10
39 */
40export default class DriverExtensionAbility {
41  /**
42   * Indicates driver extension ability context.
43   *
44   * @type { DriverExtensionContext }
45   * @syscap SystemCapability.Driver.ExternalDevice
46   * @StageModelOnly
47   * @since 10
48   */
49  context: DriverExtensionContext;
50
51  /**
52   * Called back when a driver extension is started for initialization.
53   * @param { Want } want - Indicates the want of created driver extension.
54   * @syscap SystemCapability.Driver.ExternalDevice
55   * @StageModelOnly
56   * @since 10
57   */
58  onInit(want: Want): void;
59
60  /**
61   * Called back before a driver extension is destroyed.
62   * @syscap SystemCapability.Driver.ExternalDevice
63   * @StageModelOnly
64   * @since 10
65   */
66  onRelease(): void;
67
68  /**
69   * Called back when a driver extension is first connected to an ability.
70   * @param { Want } want - Indicates connection information about the Driver ability.
71   * @returns { rpc.RemoteObject | Promise<rpc.RemoteObject> } Rpc remoteObject.
72   * @syscap SystemCapability.Driver.ExternalDevice
73   * @StageModelOnly
74   * @since 10
75   */
76  onConnect(want: Want): rpc.RemoteObject | Promise<rpc.RemoteObject>;
77
78  /**
79   * Called back when all abilities connected to a driver extension are disconnected.
80   * @param { Want } want - Indicates disconnection information about the driver extension.
81   * @returns { void | Promise<void> }
82   * @syscap SystemCapability.Driver.ExternalDevice
83   * @StageModelOnly
84   * @since 10
85   */
86  onDisconnect(want: Want): void | Promise<void>;
87
88  /**
89   * Called when dump client information is required.
90   * It is recommended that developers don't DUMP sensitive information.
91   * @param { Array<string> } params - Indicates th e params from command.
92   * @returns { Array<string> } The dump info array.
93   * @syscap SystemCapability.Driver.ExternalDevice
94   * @StageModelOnly
95   * @since 10
96   */
97  onDump(params: Array<string>): Array<string>;
98}
99