IUsbManager.aidl revision f59717ddb5ef324ee3fdb12b83e7d1b709793d28
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
17package android.hardware.usb;
18
19import android.app.PendingIntent;
20import android.hardware.usb.UsbAccessory;
21import android.hardware.usb.UsbDevice;
22import android.os.Bundle;
23import android.os.ParcelFileDescriptor;
24
25/** @hide */
26interface IUsbManager
27{
28    /* Returns a list of all currently attached USB devices */
29    void getDeviceList(out Bundle devices);
30
31    /* Returns a file descriptor for communicating with the USB device.
32     * The native fd can be passed to usb_device_new() in libusbhost.
33     */
34    ParcelFileDescriptor openDevice(String deviceName);
35
36    /* Returns the currently attached USB accessory */
37    UsbAccessory getCurrentAccessory();
38
39    /* Returns a file descriptor for communicating with the USB accessory.
40     * This file descriptor can be used with standard Java file operations.
41     */
42    ParcelFileDescriptor openAccessory(in UsbAccessory accessory);
43
44    /* Sets the default package for a USB device
45     * (or clears it if the package name is null)
46     */
47    void setDevicePackage(in UsbDevice device, String packageName);
48
49    /* Sets the default package for a USB accessory
50     * (or clears it if the package name is null)
51     */
52    void setAccessoryPackage(in UsbAccessory accessory, String packageName);
53
54    /* Returns true if the caller has permission to access the device. */
55    boolean hasDevicePermission(in UsbDevice device);
56
57    /* Returns true if the caller has permission to access the accessory. */
58    boolean hasAccessoryPermission(in UsbAccessory accessory);
59
60    /* Requests permission for the given package to access the device.
61     * Will display a system dialog to query the user if permission
62     * had not already been given.
63     */
64    void requestDevicePermission(in UsbDevice device, String packageName, in PendingIntent pi);
65
66    /* Requests permission for the given package to access the accessory.
67     * Will display a system dialog to query the user if permission
68     * had not already been given. Result is returned via pi.
69     */
70    void requestAccessoryPermission(in UsbAccessory accessory, String packageName,
71            in PendingIntent pi);
72
73    /* Grants permission for the given UID to access the device */
74    void grantDevicePermission(in UsbDevice device, int uid);
75
76    /* Grants permission for the given UID to access the accessory */
77    void grantAccessoryPermission(in UsbAccessory accessory, int uid);
78
79    /* Returns true if the USB manager has default preferences or permissions for the package */
80    boolean hasDefaults(String packageName);
81
82    /* Clears default preferences and permissions for the package */
83    void clearDefaults(String packageName);
84
85    /* Sets the current USB function. */
86    void setCurrentFunction(String function, boolean makeDefault);
87
88    /* Sets the file path for USB mass storage backing file. */
89    void setMassStorageBackingFile(String path);
90}
91