Loading core/java/android/hardware/usb/UsbManager.java +21 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import com.android.internal.util.Preconditions; import android.app.PendingIntent; import android.content.Context; import android.content.pm.PackageManager.NameNotFoundException; import android.os.Bundle; import android.os.ParcelFileDescriptor; import android.os.Process; Loading Loading @@ -475,6 +476,26 @@ public class UsbManager { } } /** * Grants permission to specified package for USB device without showing system dialog. * Only system components can call this function, as it requires the MANAGE_USB permission. * @param device to request permissions for * @param packageName of package to grant permissions * * {@hide} */ public void grantPermission(UsbDevice device, String packageName) { try { int uid = mContext.getPackageManager() .getPackageUidAsUser(packageName, mContext.getUserId()); mService.grantDevicePermission(device, uid); } catch (NameNotFoundException e) { Log.e(TAG, "Package " + packageName + " not found.", e); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Returns true if the specified USB function is currently enabled when in device mode. * <p> Loading Loading
core/java/android/hardware/usb/UsbManager.java +21 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import com.android.internal.util.Preconditions; import android.app.PendingIntent; import android.content.Context; import android.content.pm.PackageManager.NameNotFoundException; import android.os.Bundle; import android.os.ParcelFileDescriptor; import android.os.Process; Loading Loading @@ -475,6 +476,26 @@ public class UsbManager { } } /** * Grants permission to specified package for USB device without showing system dialog. * Only system components can call this function, as it requires the MANAGE_USB permission. * @param device to request permissions for * @param packageName of package to grant permissions * * {@hide} */ public void grantPermission(UsbDevice device, String packageName) { try { int uid = mContext.getPackageManager() .getPackageUidAsUser(packageName, mContext.getUserId()); mService.grantDevicePermission(device, uid); } catch (NameNotFoundException e) { Log.e(TAG, "Package " + packageName + " not found.", e); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Returns true if the specified USB function is currently enabled when in device mode. * <p> Loading