blob: 00b0bffdd1f5344e37f8a31413158d39962e454e [file] [log] [blame]
Mike Lockwoode7d511e2010-12-30 13:39:37 -05001/*
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
Mike Lockwoodc4308f02011-03-01 08:04:54 -080017package android.hardware.usb;
Mike Lockwoode7d511e2010-12-30 13:39:37 -050018
Mike Lockwood3a68b832011-03-08 10:08:59 -050019import android.app.PendingIntent;
Mike Lockwoodc4308f02011-03-01 08:04:54 -080020import android.hardware.usb.UsbAccessory;
21import android.hardware.usb.UsbDevice;
Jeff Brown76c4c662015-07-07 12:44:17 -070022import android.hardware.usb.UsbPort;
23import android.hardware.usb.UsbPortStatus;
Mike Lockwoode7d511e2010-12-30 13:39:37 -050024import android.os.Bundle;
25import android.os.ParcelFileDescriptor;
26
27/** @hide */
28interface IUsbManager
29{
30 /* Returns a list of all currently attached USB devices */
31 void getDeviceList(out Bundle devices);
Mike Lockwood02eb8742011-02-27 09:10:37 -080032
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 */
Mike Lockwoode7d511e2010-12-30 13:39:37 -050036 ParcelFileDescriptor openDevice(String deviceName);
Mike Lockwood02eb8742011-02-27 09:10:37 -080037
38 /* Returns the currently attached USB accessory */
Mike Lockwood9182d3c2011-02-15 09:50:22 -050039 UsbAccessory getCurrentAccessory();
Mike Lockwood02eb8742011-02-27 09:10:37 -080040
41 /* Returns a file descriptor for communicating with the USB accessory.
42 * This file descriptor can be used with standard Java file operations.
43 */
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 */
Jeff Sharkeyfc3f24b2012-10-01 21:45:52 -070049 void setDevicePackage(in UsbDevice device, String packageName, int userId);
Mike Lockwood02eb8742011-02-27 09:10:37 -080050
Mike Lockwood62cfeeb2011-03-11 18:39:03 -050051 /* Sets the default package for a USB accessory
Mike Lockwood02eb8742011-02-27 09:10:37 -080052 * (or clears it if the package name is null)
53 */
Jeff Sharkeyfc3f24b2012-10-01 21:45:52 -070054 void setAccessoryPackage(in UsbAccessory accessory, String packageName, int userId);
Mike Lockwood02eb8742011-02-27 09:10:37 -080055
Mike Lockwood3a68b832011-03-08 10:08:59 -050056 /* Returns true if the caller has permission to access the device. */
57 boolean hasDevicePermission(in UsbDevice device);
58
59 /* Returns true if the caller has permission to access the 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 */
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 */
72 void requestAccessoryPermission(in UsbAccessory accessory, String packageName,
73 in PendingIntent pi);
74
Mike Lockwood02eb8742011-02-27 09:10:37 -080075 /* Grants permission for the given UID to access the device */
76 void grantDevicePermission(in UsbDevice device, int uid);
77
78 /* Grants permission for the given UID to access the accessory */
79 void grantAccessoryPermission(in UsbAccessory accessory, int uid);
80
81 /* Returns true if the USB manager has default preferences or permissions for the package */
Jeff Sharkeyfc3f24b2012-10-01 21:45:52 -070082 boolean hasDefaults(String packageName, int userId);
Mike Lockwood02eb8742011-02-27 09:10:37 -080083
84 /* Clears default preferences and permissions for the package */
Jeff Sharkeyfc3f24b2012-10-01 21:45:52 -070085 void clearDefaults(String packageName, int userId);
Mike Lockwood02e45692011-06-14 15:43:51 -040086
Jeff Brown460a1462015-06-30 17:57:12 -070087 /* Returns true if the specified USB function is enabled. */
88 boolean isFunctionEnabled(String function);
89
Jerry Zhang935372b2016-10-12 15:49:32 -070090 /* Sets the current USB function as well as whether USB data
91 * (for example, MTP exposed pictures) should be made available
92 * on the USB connection. Unlocking data should only be done with
93 * user involvement, since exposing pictures or other data could
94 * leak sensitive user information.
Nick Kralevich67401902015-06-10 09:38:42 -070095 */
Jerry Zhang935372b2016-10-12 15:49:32 -070096 void setCurrentFunction(String function, boolean usbDataUnlocked);
Nick Kralevich67401902015-06-10 09:38:42 -070097
Benoit Goby4e68bd42012-04-25 18:06:00 -070098 /* Allow USB debugging from the attached host. If alwaysAllow is true, add the
99 * the public key to list of host keys that the user has approved.
100 */
101 void allowUsbDebugging(boolean alwaysAllow, String publicKey);
102
103 /* Deny USB debugging from the attached host */
104 void denyUsbDebugging();
Benoit Gobycd7a17c2012-12-21 16:44:50 -0800105
106 /* Clear public keys installed for secure USB debugging */
107 void clearUsbDebuggingKeys();
Jeff Brown76c4c662015-07-07 12:44:17 -0700108
109 /* Gets the list of USB ports. */
110 UsbPort[] getPorts();
111
112 /* Gets the status of the specified USB port. */
113 UsbPortStatus getPortStatus(in String portId);
114
115 /* Sets the port's current role. */
116 void setPortRoles(in String portId, int powerRole, int dataRole);
Mike Lockwoode7d511e2010-12-30 13:39:37 -0500117}