• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 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 
17 package android.hardware.usb;
18 
19 import android.app.PendingIntent;
20 import android.hardware.usb.UsbAccessory;
21 import android.hardware.usb.UsbDevice;
22 import android.hardware.usb.UsbPort;
23 import android.hardware.usb.UsbPortStatus;
24 import android.os.Bundle;
25 import android.os.ParcelFileDescriptor;
26 
27 /** @hide */
28 interface IUsbManager
29 {
30     /* Returns a list of all currently attached USB devices */
getDeviceList(out Bundle devices)31     void getDeviceList(out Bundle devices);
32 
33     /* Returns a file descriptor for communicating with the USB device.
34      * The native fd can be passed to usb_device_new() in libusbhost.
35      */
openDevice(String deviceName)36     ParcelFileDescriptor openDevice(String deviceName);
37 
38     /* Returns the currently attached USB accessory */
getCurrentAccessory()39     UsbAccessory getCurrentAccessory();
40 
41     /* Returns a file descriptor for communicating with the USB accessory.
42      * This file descriptor can be used with standard Java file operations.
43      */
openAccessory(in UsbAccessory accessory)44     ParcelFileDescriptor openAccessory(in UsbAccessory accessory);
45 
46     /* Sets the default package for a USB device
47      * (or clears it if the package name is null)
48      */
setDevicePackage(in UsbDevice device, String packageName, int userId)49     void setDevicePackage(in UsbDevice device, String packageName, int userId);
50 
51     /* Sets the default package for a USB accessory
52      * (or clears it if the package name is null)
53      */
setAccessoryPackage(in UsbAccessory accessory, String packageName, int userId)54     void setAccessoryPackage(in UsbAccessory accessory, String packageName, int userId);
55 
56     /* Returns true if the caller has permission to access the device. */
hasDevicePermission(in UsbDevice device)57     boolean hasDevicePermission(in UsbDevice device);
58 
59     /* Returns true if the caller has permission to access the accessory. */
hasAccessoryPermission(in UsbAccessory accessory)60     boolean hasAccessoryPermission(in UsbAccessory accessory);
61 
62     /* Requests permission for the given package to access the device.
63      * Will display a system dialog to query the user if permission
64      * had not already been given.
65      */
requestDevicePermission(in UsbDevice device, String packageName, in PendingIntent pi)66     void requestDevicePermission(in UsbDevice device, String packageName, in PendingIntent pi);
67 
68     /* Requests permission for the given package to access the accessory.
69      * Will display a system dialog to query the user if permission
70      * had not already been given. Result is returned via pi.
71      */
requestAccessoryPermission(in UsbAccessory accessory, String packageName, in PendingIntent pi)72     void requestAccessoryPermission(in UsbAccessory accessory, String packageName,
73             in PendingIntent pi);
74 
75     /* Grants permission for the given UID to access the device */
grantDevicePermission(in UsbDevice device, int uid)76     void grantDevicePermission(in UsbDevice device, int uid);
77 
78     /* Grants permission for the given UID to access the accessory */
grantAccessoryPermission(in UsbAccessory accessory, int uid)79     void grantAccessoryPermission(in UsbAccessory accessory, int uid);
80 
81     /* Returns true if the USB manager has default preferences or permissions for the package */
hasDefaults(String packageName, int userId)82     boolean hasDefaults(String packageName, int userId);
83 
84     /* Clears default preferences and permissions for the package */
clearDefaults(String packageName, int userId)85     void clearDefaults(String packageName, int userId);
86 
87     /* Returns true if the specified USB function is enabled. */
isFunctionEnabled(String function)88     boolean isFunctionEnabled(String function);
89 
90     /* Sets the current USB function. */
setCurrentFunction(String function)91     void setCurrentFunction(String function);
92 
93     /* Sets whether USB data (for example, MTP exposed pictures) should be made
94      * available on the USB connection. Unlocking data should only be done with
95      * user involvement, since exposing pictures or other data could leak sensitive
96      * user information.
97      */
setUsbDataUnlocked(boolean unlock)98     void setUsbDataUnlocked(boolean unlock);
99 
100     /* Allow USB debugging from the attached host. If alwaysAllow is true, add the
101      * the public key to list of host keys that the user has approved.
102      */
allowUsbDebugging(boolean alwaysAllow, String publicKey)103     void allowUsbDebugging(boolean alwaysAllow, String publicKey);
104 
105     /* Deny USB debugging from the attached host */
denyUsbDebugging()106     void denyUsbDebugging();
107 
108     /* Clear public keys installed for secure USB debugging */
clearUsbDebuggingKeys()109     void clearUsbDebuggingKeys();
110 
111     /* Gets the list of USB ports. */
getPorts()112     UsbPort[] getPorts();
113 
114     /* Gets the status of the specified USB port. */
getPortStatus(in String portId)115     UsbPortStatus getPortStatus(in String portId);
116 
117     /* Sets the port's current role. */
setPortRoles(in String portId, int powerRole, int dataRole)118     void setPortRoles(in String portId, int powerRole, int dataRole);
119 }
120