IUsbManager.aidl revision 6d319b8aaa961862afac48010d96d03afb11fa1c
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.content.ComponentName; 21import android.hardware.usb.UsbAccessory; 22import android.hardware.usb.UsbDevice; 23import android.hardware.usb.UsbPort; 24import android.hardware.usb.UsbPortStatus; 25import android.os.Bundle; 26import android.os.ParcelFileDescriptor; 27 28/** @hide */ 29interface IUsbManager 30{ 31 /* Returns a list of all currently attached USB devices */ 32 void getDeviceList(out Bundle devices); 33 34 /* Returns a file descriptor for communicating with the USB device. 35 * The native fd can be passed to usb_device_new() in libusbhost. 36 */ 37 ParcelFileDescriptor openDevice(String deviceName, String packageName); 38 39 /* Returns the currently attached USB accessory */ 40 UsbAccessory getCurrentAccessory(); 41 42 /* Returns a file descriptor for communicating with the USB accessory. 43 * This file descriptor can be used with standard Java file operations. 44 */ 45 ParcelFileDescriptor openAccessory(in UsbAccessory accessory); 46 47 /* Sets the default package for a USB device 48 * (or clears it if the package name is null) 49 */ 50 void setDevicePackage(in UsbDevice device, String packageName, int userId); 51 52 /* Sets the default package for a USB accessory 53 * (or clears it if the package name is null) 54 */ 55 void setAccessoryPackage(in UsbAccessory accessory, String packageName, int userId); 56 57 /* Returns true if the caller has permission to access the device. */ 58 boolean hasDevicePermission(in UsbDevice device, String packageName); 59 60 /* Returns true if the caller has permission to access the accessory. */ 61 boolean hasAccessoryPermission(in UsbAccessory accessory); 62 63 /* Requests permission for the given package to access the device. 64 * Will display a system dialog to query the user if permission 65 * had not already been given. 66 */ 67 void requestDevicePermission(in UsbDevice device, String packageName, in PendingIntent pi); 68 69 /* Requests permission for the given package to access the accessory. 70 * Will display a system dialog to query the user if permission 71 * had not already been given. Result is returned via pi. 72 */ 73 void requestAccessoryPermission(in UsbAccessory accessory, String packageName, 74 in PendingIntent pi); 75 76 /* Grants permission for the given UID to access the device */ 77 void grantDevicePermission(in UsbDevice device, int uid); 78 79 /* Grants permission for the given UID to access the accessory */ 80 void grantAccessoryPermission(in UsbAccessory accessory, int uid); 81 82 /* Returns true if the USB manager has default preferences or permissions for the package */ 83 boolean hasDefaults(String packageName, int userId); 84 85 /* Clears default preferences and permissions for the package */ 86 void clearDefaults(String packageName, int userId); 87 88 /* Returns true if the specified USB function is enabled. */ 89 boolean isFunctionEnabled(String function); 90 91 /* Sets the current USB function. */ 92 void setCurrentFunctions(long functions); 93 94 /* Compatibility version of setCurrentFunctions(long). */ 95 void setCurrentFunction(String function, boolean usbDataUnlocked); 96 97 /* Gets the current USB functions. */ 98 long getCurrentFunctions(); 99 100 /* Sets the screen unlocked USB function(s), which will be set automatically 101 * when the screen is unlocked. 102 */ 103 void setScreenUnlockedFunctions(long functions); 104 105 /* Gets the current screen unlocked functions. */ 106 long getScreenUnlockedFunctions(); 107 108 /* Get the functionfs control handle for the given function. Usb 109 * descriptors will already be written, and the handle will be 110 * ready to use. 111 */ 112 ParcelFileDescriptor getControlFd(long function); 113 114 /* Allow USB debugging from the attached host. If alwaysAllow is true, add the 115 * the public key to list of host keys that the user has approved. 116 */ 117 void allowUsbDebugging(boolean alwaysAllow, String publicKey); 118 119 /* Deny USB debugging from the attached host */ 120 void denyUsbDebugging(); 121 122 /* Clear public keys installed for secure USB debugging */ 123 void clearUsbDebuggingKeys(); 124 125 /* Gets the list of USB ports. */ 126 UsbPort[] getPorts(); 127 128 /* Gets the status of the specified USB port. */ 129 UsbPortStatus getPortStatus(in String portId); 130 131 /* Sets the port's current role. */ 132 void setPortRoles(in String portId, int powerRole, int dataRole); 133 134 /* Sets USB device connection handler. */ 135 void setUsbDeviceConnectionHandler(in ComponentName usbDeviceConnectionHandler); 136} 137