• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2025 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 * @addtogroup HdiUsb
18 * @{
19 *
20 * @brief Provides unified APIs for usb services to access usb drivers.
21 *
22 * A usb service can obtain a usb driver object or agent and then call APIs provided by this object or agent to
23 * access different types of usb devices based on the usb IDs, thereby obtaining usb information,
24 * subscribing to or unsubscribing from usb data, enabling or disabling a usb,
25 * setting the usb data reporting mode, and setting usb options such as the accuracy and measurement range.
26 *
27 * @since 5.1
28 * @version 1.0
29 */
30
31package ohos.hdi.usb.v2_0;
32
33import ohos.hdi.usb.v2_0.IUsbdSubscriber;
34
35interface IUsbDeviceInterface {
36
37    /* *
38     * @brief Obtains the list of functions (represented by bit field) supported by the current device.
39     *
40     * @param funcs Indicates the list of functions supported by the current device.
41     *
42     * @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
43     * @since 5.1
44     * @version 1.0
45     */
46    GetCurrentFunctions([out] int funcs);
47
48    /* *
49     * @brief Sets the list of functions (represented by bit field) supported by the current device.
50     *
51     * @param funcs Indicates the list of functions supported by the current device.
52     *
53     * @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
54     * @since 5.1
55     * @version 1.0
56     */
57    SetCurrentFunctions([in] int funcs);
58
59     /* *
60     * @brief Get Accessory Strings.
61     *
62     * @param accessoryInfo Indicates the accessory information.
63     *
64     * @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
65     * @since 5.1
66     * @version 1.0
67     */
68    GetAccessoryInfo([out] String[] accessoryInfo);
69
70    /* *
71     * @brief open the accessory.
72     *
73     * @param fd accessory file descriptor
74     *
75     * @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
76     * @since 5.1
77     * @version 1.0
78     */
79    OpenAccessory([out] FileDescriptor fd);
80
81    /* *
82     * @brief close the accessory.
83     *
84     * @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
85     * @since 5.1
86     * @version 1.0
87     */
88    CloseAccessory([in] FileDescriptor fd);
89
90    /* *
91     * @brief Binds a subscriber.
92     *
93     * @param subscriber Indicates the subscriber.
94     *
95     * @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
96     * @since 5.1
97     * @version 1.0
98     */
99    BindUsbdDeviceSubscriber([in] IUsbdSubscriber subscriber);
100
101    /* *
102     * @brief Unbinds a subscriber.
103     *
104     * @param subscriber Indicates the subscriber.
105     *
106     * @return Returns <b>0</b> if the operation is successful; returns a non-0 value if the operation fails.
107     * @since 5.1
108     * @version 1.0
109     */
110    UnbindUsbdDeviceSubscriber([in] IUsbdSubscriber subscriber);
111}