1 /*
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.server.usb.hal.gadget;
17 
18 import android.annotation.IntDef;
19 import android.hardware.usb.gadget.IUsbGadgetCallback;
20 import android.hardware.usb.IUsbOperationInternal;
21 import android.hardware.usb.UsbManager.UsbHalVersion;
22 import android.os.RemoteException;
23 import java.lang.annotation.Retention;
24 import java.lang.annotation.RetentionPolicy;
25 import java.lang.String;
26 
27 /**
28  * @hide
29  */
30 public interface UsbGadgetHal {
31     /**
32      * This function is used to query the USB functions included in the
33      * current USB configuration.
34      *
35      * @param transactionId Used for tracking the current request and is passed down to the HAL
36      *                      implementation as needed.
37      */
getCurrentUsbFunctions(long transactionId)38     public void getCurrentUsbFunctions(long transactionId);
39 
40     /**
41      * The function is used to query current USB speed.
42      *
43      * @param transactionId Used for tracking the current request and is passed down to the HAL
44      *                      implementation as needed.
45      */
getUsbSpeed(long transactionId)46     public void getUsbSpeed(long transactionId);
47 
48     /**
49      * This function is used to reset USB gadget driver.
50      * Performs USB data connection reset. The connection will disconnect and
51      * reconnect.
52      *
53      * @param transactionId Used for tracking the current request and is passed down to the HAL
54      *                      implementation as needed.
55      */
reset(long transactionId)56     public void reset(long transactionId);
57 
58     /**
59      * Invoked to query the version of current gadget hal implementation.
60      */
getGadgetHalVersion()61     public @UsbHalVersion int getGadgetHalVersion() throws RemoteException;
62 
63     /**
64      * This function is used to set the current USB gadget configuration.
65      * The USB gadget needs to be torn down if a USB configuration is already
66      * active.
67      *
68      * @param functions list of functions defined by GadgetFunction to be
69      *                  included in the gadget composition.
70      * @param timeout The maximum time (in milliseconds) within which the
71      *                IUsbGadgetCallback needs to be returned.
72      * @param transactionId Used for tracking the current request and is passed down to the HAL
73      *                      implementation as needed.
74      */
setCurrentUsbFunctions(int request, long functions, boolean chargingFunctions, int timeout, long transactionId)75     public void setCurrentUsbFunctions(int request, long functions,
76         boolean chargingFunctions, int timeout, long transactionId);
77 }
78 
79