Home | History | Annotate | Download | only in usb
      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.content.ComponentName;
     21 import android.hardware.usb.UsbAccessory;
     22 import android.hardware.usb.UsbDevice;
     23 import android.hardware.usb.UsbPort;
     24 import android.hardware.usb.UsbPortStatus;
     25 import android.os.Bundle;
     26 import android.os.ParcelFileDescriptor;
     27 
     28 /** @hide */
     29 interface 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);
     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);
     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 as well as whether USB data
     92      * (for example, MTP exposed pictures) should be made available
     93      * on the USB connection. Unlocking data should only be done with
     94      * user involvement, since exposing pictures or other data could
     95      * leak sensitive user information.
     96      */
     97     void setCurrentFunction(String function, boolean usbDataUnlocked);
     98 
     99     /* Allow USB debugging from the attached host. If alwaysAllow is true, add the
    100      * the public key to list of host keys that the user has approved.
    101      */
    102     void allowUsbDebugging(boolean alwaysAllow, String publicKey);
    103 
    104     /* Deny USB debugging from the attached host */
    105     void denyUsbDebugging();
    106 
    107     /* Clear public keys installed for secure USB debugging */
    108     void clearUsbDebuggingKeys();
    109 
    110     /* Gets the list of USB ports. */
    111     UsbPort[] getPorts();
    112 
    113     /* Gets the status of the specified USB port. */
    114     UsbPortStatus getPortStatus(in String portId);
    115 
    116     /* Sets the port's current role. */
    117     void setPortRoles(in String portId, int powerRole, int dataRole);
    118 
    119    /* Sets USB device connection handler. */
    120    void setUsbDeviceConnectionHandler(in ComponentName usbDeviceConnectionHandler);
    121 }
    122