Loading api/current.xml +0 −11 Original line number Diff line number Diff line Loading @@ -111,17 +111,6 @@ visibility="public" > </field> <field name="ACCESS_USB" type="java.lang.String" transient="false" volatile="false" value=""android.permission.ACCESS_USB"" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="ACCESS_WIFI_STATE" type="java.lang.String" transient="false" core/java/android/hardware/IUsbManager.aidl +34 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.hardware; import android.hardware.UsbAccessory; import android.hardware.UsbDevice; import android.os.Bundle; import android.os.ParcelFileDescriptor; Loading @@ -25,7 +26,39 @@ interface IUsbManager { /* Returns a list of all currently attached USB devices */ void getDeviceList(out Bundle devices); /* Returns a file descriptor for communicating with the USB device. * The native fd can be passed to usb_device_new() in libusbhost. */ ParcelFileDescriptor openDevice(String deviceName); /* Returns the currently attached USB accessory */ UsbAccessory getCurrentAccessory(); ParcelFileDescriptor openAccessory(); /* Returns a file descriptor for communicating with the USB accessory. * This file descriptor can be used with standard Java file operations. */ ParcelFileDescriptor openAccessory(in UsbAccessory accessory); /* Sets the default package for a USB device * (or clears it if the package name is null) */ oneway void setDevicePackage(in UsbDevice device, String packageName); /* Sets the default package for a USB device * (or clears it if the package name is null) */ void setAccessoryPackage(in UsbAccessory accessory, String packageName); /* Grants permission for the given UID to access the device */ void grantDevicePermission(in UsbDevice device, int uid); /* Grants permission for the given UID to access the accessory */ void grantAccessoryPermission(in UsbAccessory accessory, int uid); /* Returns true if the USB manager has default preferences or permissions for the package */ boolean hasDefaults(String packageName, int uid); /* Clears default preferences and permissions for the package */ oneway void clearDefaults(String packageName, int uid); } core/java/android/hardware/UsbAccessory.java +17 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,23 @@ public final class UsbAccessory implements Parcelable { return mVersion; } private static boolean compare(String s1, String s2) { if (s1 == null) return (s2 == null); return s1.equals(s2); } @Override public boolean equals(Object obj) { if (obj instanceof UsbAccessory) { UsbAccessory accessory = (UsbAccessory)obj; return (compare(mManufacturer, accessory.getManufacturer()) && compare(mModel, accessory.getModel()) && compare(mType, accessory.getType()) && compare(mVersion, accessory.getVersion())); } return false; } @Override public String toString() { return "UsbAccessory[mManufacturer=" + mManufacturer + Loading core/java/android/hardware/UsbManager.java +6 −5 Original line number Diff line number Diff line Loading @@ -163,14 +163,15 @@ public class UsbManager { /** * Name of extra for {@link #ACTION_USB_DEVICE_ATTACHED} and * {@link #ACTION_USB_DEVICE_DETACHED} broadcasts. * {@link #ACTION_USB_DEVICE_DETACHED} broadcasts * containing the UsbDevice object for the device. */ public static final String EXTRA_DEVICE = "device"; /** * Name of extra for {@link #ACTION_USB_ACCESSORY_ATTACHED} broadcast * Name of extra for {@link #ACTION_USB_ACCESSORY_ATTACHED} and * {@link #ACTION_USB_ACCESSORY_DETACHED} broadcasts * containing the UsbAccessory object for the accessory. */ public static final String EXTRA_ACCESSORY = "accessory"; Loading Loading @@ -244,7 +245,7 @@ public class UsbManager { return new UsbAccessory[] { accessory }; } } catch (RemoteException e) { Log.e(TAG, "RemoteException in openAccessory" , e); Log.e(TAG, "RemoteException in getAccessoryList" , e); return null; } } Loading @@ -257,7 +258,7 @@ public class UsbManager { */ public ParcelFileDescriptor openAccessory(UsbAccessory accessory) { try { return mService.openAccessory(); return mService.openAccessory(accessory); } catch (RemoteException e) { Log.e(TAG, "RemoteException in openAccessory" , e); return null; Loading core/java/com/android/internal/app/ResolverActivity.java +16 −5 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ public class ResolverActivity extends AlertActivity implements protected void onCreate(Bundle savedInstanceState, Intent intent, CharSequence title, Intent[] initialIntents, List<ResolveInfo> rList, boolean alwaysUseOption) { boolean alwaysUseOption, boolean alwaysChoose) { super.onCreate(savedInstanceState); mPm = getPackageManager(); intent.setComponent(null); Loading @@ -90,9 +90,10 @@ public class ResolverActivity extends AlertActivity implements mClearDefaultHint.setVisibility(View.GONE); } mAdapter = new ResolveListAdapter(this, intent, initialIntents, rList); if (mAdapter.getCount() > 1) { int count = mAdapter.getCount(); if (count > 1 || (count == 1 && alwaysChoose)) { ap.mAdapter = mAdapter; } else if (mAdapter.getCount() == 1) { } else if (count == 1) { startActivity(mAdapter.intentForPosition(0)); finish(); return; Loading @@ -103,11 +104,22 @@ public class ResolverActivity extends AlertActivity implements setupAlert(); } protected void onCreate(Bundle savedInstanceState, Intent intent, CharSequence title, Intent[] initialIntents, List<ResolveInfo> rList, boolean alwaysUseOption) { onCreate(savedInstanceState, intent, title, initialIntents, rList, alwaysUseOption, false); } public void onClick(DialogInterface dialog, int which) { ResolveInfo ri = mAdapter.resolveInfoForPosition(which); Intent intent = mAdapter.intentForPosition(which); boolean alwaysCheck = (mAlwaysCheck != null && mAlwaysCheck.isChecked()); onIntentSelected(ri, intent, alwaysCheck); finish(); } if ((mAlwaysCheck != null) && mAlwaysCheck.isChecked()) { protected void onIntentSelected(ResolveInfo ri, Intent intent, boolean alwaysCheck) { if (alwaysCheck) { // Build a reasonable intent filter, based on what matched. IntentFilter filter = new IntentFilter(); Loading Loading @@ -190,7 +202,6 @@ public class ResolverActivity extends AlertActivity implements if (intent != null) { startActivity(intent); } finish(); } private final class DisplayResolveInfo { Loading Loading
api/current.xml +0 −11 Original line number Diff line number Diff line Loading @@ -111,17 +111,6 @@ visibility="public" > </field> <field name="ACCESS_USB" type="java.lang.String" transient="false" volatile="false" value=""android.permission.ACCESS_USB"" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="ACCESS_WIFI_STATE" type="java.lang.String" transient="false"
core/java/android/hardware/IUsbManager.aidl +34 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.hardware; import android.hardware.UsbAccessory; import android.hardware.UsbDevice; import android.os.Bundle; import android.os.ParcelFileDescriptor; Loading @@ -25,7 +26,39 @@ interface IUsbManager { /* Returns a list of all currently attached USB devices */ void getDeviceList(out Bundle devices); /* Returns a file descriptor for communicating with the USB device. * The native fd can be passed to usb_device_new() in libusbhost. */ ParcelFileDescriptor openDevice(String deviceName); /* Returns the currently attached USB accessory */ UsbAccessory getCurrentAccessory(); ParcelFileDescriptor openAccessory(); /* Returns a file descriptor for communicating with the USB accessory. * This file descriptor can be used with standard Java file operations. */ ParcelFileDescriptor openAccessory(in UsbAccessory accessory); /* Sets the default package for a USB device * (or clears it if the package name is null) */ oneway void setDevicePackage(in UsbDevice device, String packageName); /* Sets the default package for a USB device * (or clears it if the package name is null) */ void setAccessoryPackage(in UsbAccessory accessory, String packageName); /* Grants permission for the given UID to access the device */ void grantDevicePermission(in UsbDevice device, int uid); /* Grants permission for the given UID to access the accessory */ void grantAccessoryPermission(in UsbAccessory accessory, int uid); /* Returns true if the USB manager has default preferences or permissions for the package */ boolean hasDefaults(String packageName, int uid); /* Clears default preferences and permissions for the package */ oneway void clearDefaults(String packageName, int uid); }
core/java/android/hardware/UsbAccessory.java +17 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,23 @@ public final class UsbAccessory implements Parcelable { return mVersion; } private static boolean compare(String s1, String s2) { if (s1 == null) return (s2 == null); return s1.equals(s2); } @Override public boolean equals(Object obj) { if (obj instanceof UsbAccessory) { UsbAccessory accessory = (UsbAccessory)obj; return (compare(mManufacturer, accessory.getManufacturer()) && compare(mModel, accessory.getModel()) && compare(mType, accessory.getType()) && compare(mVersion, accessory.getVersion())); } return false; } @Override public String toString() { return "UsbAccessory[mManufacturer=" + mManufacturer + Loading
core/java/android/hardware/UsbManager.java +6 −5 Original line number Diff line number Diff line Loading @@ -163,14 +163,15 @@ public class UsbManager { /** * Name of extra for {@link #ACTION_USB_DEVICE_ATTACHED} and * {@link #ACTION_USB_DEVICE_DETACHED} broadcasts. * {@link #ACTION_USB_DEVICE_DETACHED} broadcasts * containing the UsbDevice object for the device. */ public static final String EXTRA_DEVICE = "device"; /** * Name of extra for {@link #ACTION_USB_ACCESSORY_ATTACHED} broadcast * Name of extra for {@link #ACTION_USB_ACCESSORY_ATTACHED} and * {@link #ACTION_USB_ACCESSORY_DETACHED} broadcasts * containing the UsbAccessory object for the accessory. */ public static final String EXTRA_ACCESSORY = "accessory"; Loading Loading @@ -244,7 +245,7 @@ public class UsbManager { return new UsbAccessory[] { accessory }; } } catch (RemoteException e) { Log.e(TAG, "RemoteException in openAccessory" , e); Log.e(TAG, "RemoteException in getAccessoryList" , e); return null; } } Loading @@ -257,7 +258,7 @@ public class UsbManager { */ public ParcelFileDescriptor openAccessory(UsbAccessory accessory) { try { return mService.openAccessory(); return mService.openAccessory(accessory); } catch (RemoteException e) { Log.e(TAG, "RemoteException in openAccessory" , e); return null; Loading
core/java/com/android/internal/app/ResolverActivity.java +16 −5 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ public class ResolverActivity extends AlertActivity implements protected void onCreate(Bundle savedInstanceState, Intent intent, CharSequence title, Intent[] initialIntents, List<ResolveInfo> rList, boolean alwaysUseOption) { boolean alwaysUseOption, boolean alwaysChoose) { super.onCreate(savedInstanceState); mPm = getPackageManager(); intent.setComponent(null); Loading @@ -90,9 +90,10 @@ public class ResolverActivity extends AlertActivity implements mClearDefaultHint.setVisibility(View.GONE); } mAdapter = new ResolveListAdapter(this, intent, initialIntents, rList); if (mAdapter.getCount() > 1) { int count = mAdapter.getCount(); if (count > 1 || (count == 1 && alwaysChoose)) { ap.mAdapter = mAdapter; } else if (mAdapter.getCount() == 1) { } else if (count == 1) { startActivity(mAdapter.intentForPosition(0)); finish(); return; Loading @@ -103,11 +104,22 @@ public class ResolverActivity extends AlertActivity implements setupAlert(); } protected void onCreate(Bundle savedInstanceState, Intent intent, CharSequence title, Intent[] initialIntents, List<ResolveInfo> rList, boolean alwaysUseOption) { onCreate(savedInstanceState, intent, title, initialIntents, rList, alwaysUseOption, false); } public void onClick(DialogInterface dialog, int which) { ResolveInfo ri = mAdapter.resolveInfoForPosition(which); Intent intent = mAdapter.intentForPosition(which); boolean alwaysCheck = (mAlwaysCheck != null && mAlwaysCheck.isChecked()); onIntentSelected(ri, intent, alwaysCheck); finish(); } if ((mAlwaysCheck != null) && mAlwaysCheck.isChecked()) { protected void onIntentSelected(ResolveInfo ri, Intent intent, boolean alwaysCheck) { if (alwaysCheck) { // Build a reasonable intent filter, based on what matched. IntentFilter filter = new IntentFilter(); Loading Loading @@ -190,7 +202,6 @@ public class ResolverActivity extends AlertActivity implements if (intent != null) { startActivity(intent); } finish(); } private final class DisplayResolveInfo { Loading