Loading api/current.xml +12 −1 Original line number Diff line number Diff line Loading @@ -94415,6 +94415,17 @@ visibility="public" > </method> <method name="getDescription" return="java.lang.String" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="getManufacturer" return="java.lang.String" abstract="false" Loading @@ -94437,7 +94448,7 @@ visibility="public" > </method> <method name="getType" <method name="getUri" return="java.lang.String" abstract="false" native="false" core/java/android/hardware/usb/UsbAccessory.java +37 −17 Original line number Diff line number Diff line Loading @@ -30,18 +30,21 @@ public class UsbAccessory implements Parcelable { private final String mManufacturer; private final String mModel; private final String mType; private final String mDescription; private final String mVersion; private final String mUri; /** * UsbAccessory should only be instantiated by UsbService implementation * @hide */ public UsbAccessory(String manufacturer, String model, String type, String version) { public UsbAccessory(String manufacturer, String model, String description, String version, String uri) { mManufacturer = manufacturer; mModel = model; mType = type; mDescription = description; mVersion = version; mUri = uri; } /** Loading @@ -51,8 +54,9 @@ public class UsbAccessory implements Parcelable { public UsbAccessory(String[] strings) { mManufacturer = strings[0]; mModel = strings[1]; mType = strings[2]; mDescription = strings[2]; mVersion = strings[3]; mUri = strings[4]; } /** Loading @@ -74,12 +78,12 @@ public class UsbAccessory implements Parcelable { } /** * Returns the type of the accessory. * Returns a user visible description of the accessory. * * @return the accessory type * @return the accessory description */ public String getType() { return mType; public String getDescription() { return mDescription; } /** Loading @@ -91,6 +95,17 @@ public class UsbAccessory implements Parcelable { return mVersion; } /** * Returns the URI for the accessory. * This is an optional URI that might show information about the accessory * or provide the option to download an application for the accessory * * @return the accessory URI */ public String getUri() { return mUri; } private static boolean compare(String s1, String s2) { if (s1 == null) return (s2 == null); return s1.equals(s2); Loading @@ -102,8 +117,9 @@ public class UsbAccessory implements Parcelable { UsbAccessory accessory = (UsbAccessory)obj; return (compare(mManufacturer, accessory.getManufacturer()) && compare(mModel, accessory.getModel()) && compare(mType, accessory.getType()) && compare(mVersion, accessory.getVersion())); compare(mDescription, accessory.getDescription()) && compare(mVersion, accessory.getVersion()) && compare(mUri, accessory.getUri())); } return false; } Loading @@ -112,16 +128,18 @@ public class UsbAccessory implements Parcelable { public int hashCode() { return ((mManufacturer == null ? 0 : mManufacturer.hashCode()) ^ (mModel == null ? 0 : mModel.hashCode()) ^ (mType == null ? 0 : mType.hashCode()) ^ (mVersion == null ? 0 : mVersion.hashCode())); (mDescription == null ? 0 : mDescription.hashCode()) ^ (mVersion == null ? 0 : mVersion.hashCode()) ^ (mUri == null ? 0 : mUri.hashCode())); } @Override public String toString() { return "UsbAccessory[mManufacturer=" + mManufacturer + ", mModel=" + mModel + ", mType=" + mType + ", mVersion=" + mVersion + "]"; ", mDescription=" + mDescription + ", mVersion=" + mVersion + ", mUri=" + mUri + "]"; } public static final Parcelable.Creator<UsbAccessory> CREATOR = Loading @@ -129,9 +147,10 @@ public class UsbAccessory implements Parcelable { public UsbAccessory createFromParcel(Parcel in) { String manufacturer = in.readString(); String model = in.readString(); String type = in.readString(); String description = in.readString(); String version = in.readString(); return new UsbAccessory(manufacturer, model, type, version); String uri = in.readString(); return new UsbAccessory(manufacturer, model, description, version, uri); } public UsbAccessory[] newArray(int size) { Loading @@ -146,7 +165,8 @@ public class UsbAccessory implements Parcelable { public void writeToParcel(Parcel parcel, int flags) { parcel.writeString(mManufacturer); parcel.writeString(mModel); parcel.writeString(mType); parcel.writeString(mDescription); parcel.writeString(mVersion); parcel.writeString(mUri); } } libs/usb/src/com/android/future/usb/UsbAccessory.java +34 −10 Original line number Diff line number Diff line Loading @@ -23,14 +23,16 @@ public final class UsbAccessory { private final String mManufacturer; private final String mModel; private final String mType; private final String mDescription; private final String mVersion; private final String mUri; /* package */ UsbAccessory(android.hardware.usb.UsbAccessory accessory) { mManufacturer = accessory.getManufacturer(); mModel = accessory.getModel(); mType = accessory.getType(); mDescription = accessory.getDescription(); mVersion = accessory.getVersion(); mUri = accessory.getUri(); } /** Loading @@ -52,12 +54,12 @@ public final class UsbAccessory { } /** * Returns the type of the accessory. * Returns a user visible description of the accessory. * * @return the accessory type * @return the accessory description */ public String getType() { return mType; public String getDescription() { return mDescription; } /** Loading @@ -69,6 +71,17 @@ public final class UsbAccessory { return mVersion; } /** * Returns the URI for the accessory. * This is an optional URI that might show information about the accessory * or provide the option to download an application for the accessory * * @return the accessory URI */ public String getUri() { return mUri; } private static boolean compare(String s1, String s2) { if (s1 == null) return (s2 == null); return s1.equals(s2); Loading @@ -80,17 +93,28 @@ public final class UsbAccessory { UsbAccessory accessory = (UsbAccessory)obj; return (compare(mManufacturer, accessory.getManufacturer()) && compare(mModel, accessory.getModel()) && compare(mType, accessory.getType()) && compare(mVersion, accessory.getVersion())); compare(mDescription, accessory.getDescription()) && compare(mVersion, accessory.getVersion()) && compare(mUri, accessory.getUri())); } return false; } @Override public int hashCode() { return ((mManufacturer == null ? 0 : mManufacturer.hashCode()) ^ (mModel == null ? 0 : mModel.hashCode()) ^ (mDescription == null ? 0 : mDescription.hashCode()) ^ (mVersion == null ? 0 : mVersion.hashCode()) ^ (mUri == null ? 0 : mUri.hashCode())); } @Override public String toString() { return "UsbAccessory[mManufacturer=" + mManufacturer + ", mModel=" + mModel + ", mType=" + mType + ", mVersion=" + mVersion + "]"; ", mDescription=" + mDescription + ", mVersion=" + mVersion + ", mUri=" + mUri + "]"; } } libs/usb/src/com/android/future/usb/UsbManager.java +5 −5 Original line number Diff line number Diff line Loading @@ -130,7 +130,7 @@ public class UsbManager { try { return mService.openAccessory(new android.hardware.usb.UsbAccessory( accessory.getManufacturer(),accessory.getModel(), accessory.getType(), accessory.getVersion())); accessory.getDescription(), accessory.getVersion(), accessory.getUri())); } catch (RemoteException e) { Log.e(TAG, "RemoteException in openAccessory" , e); return null; Loading @@ -150,7 +150,7 @@ public class UsbManager { try { return mService.hasAccessoryPermission(new android.hardware.usb.UsbAccessory( accessory.getManufacturer(),accessory.getModel(), accessory.getType(), accessory.getVersion())); accessory.getDescription(), accessory.getVersion(), accessory.getUri())); } catch (RemoteException e) { Log.e(TAG, "RemoteException in hasPermission", e); return false; Loading @@ -174,7 +174,7 @@ public class UsbManager { try { mService.requestAccessoryPermission(new android.hardware.usb.UsbAccessory( accessory.getManufacturer(),accessory.getModel(), accessory.getType(), accessory.getVersion()), accessory.getDescription(), accessory.getVersion(), accessory.getUri()), mContext.getPackageName(), pi); } catch (RemoteException e) { Log.e(TAG, "RemoteException in requestPermission", e); Loading libs/usb/tests/AccessoryChat/accessorychat/accessorychat.c +10 −1 Original line number Diff line number Diff line Loading @@ -133,10 +133,19 @@ static int usb_device_added(const char *devname, void* client_data) { } else { printf("Found possible android device - attempting to switch to accessory mode\n"); uint16_t protocol; ret = usb_device_control_transfer(device, USB_DIR_IN | USB_TYPE_VENDOR, ACCESSORY_GET_PROTOCOL, 0, 0, &protocol, sizeof(protocol), 0); if (ret == 2) printf("device supports protocol version %d\n", protocol); else fprintf(stderr, "failed to read protocol version\n"); send_string(device, ACCESSORY_STRING_MANUFACTURER, "Google, Inc."); send_string(device, ACCESSORY_STRING_MODEL, "AccessoryChat"); send_string(device, ACCESSORY_STRING_TYPE, "Sample Program"); send_string(device, ACCESSORY_STRING_DESCRIPTION, "Sample Program"); send_string(device, ACCESSORY_STRING_VERSION, "1.0"); send_string(device, ACCESSORY_STRING_URI, "http://www.android.com"); ret = usb_device_control_transfer(device, USB_DIR_OUT | USB_TYPE_VENDOR, ACCESSORY_START, 0, 0, 0, 0, 0); Loading Loading
api/current.xml +12 −1 Original line number Diff line number Diff line Loading @@ -94415,6 +94415,17 @@ visibility="public" > </method> <method name="getDescription" return="java.lang.String" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="getManufacturer" return="java.lang.String" abstract="false" Loading @@ -94437,7 +94448,7 @@ visibility="public" > </method> <method name="getType" <method name="getUri" return="java.lang.String" abstract="false" native="false"
core/java/android/hardware/usb/UsbAccessory.java +37 −17 Original line number Diff line number Diff line Loading @@ -30,18 +30,21 @@ public class UsbAccessory implements Parcelable { private final String mManufacturer; private final String mModel; private final String mType; private final String mDescription; private final String mVersion; private final String mUri; /** * UsbAccessory should only be instantiated by UsbService implementation * @hide */ public UsbAccessory(String manufacturer, String model, String type, String version) { public UsbAccessory(String manufacturer, String model, String description, String version, String uri) { mManufacturer = manufacturer; mModel = model; mType = type; mDescription = description; mVersion = version; mUri = uri; } /** Loading @@ -51,8 +54,9 @@ public class UsbAccessory implements Parcelable { public UsbAccessory(String[] strings) { mManufacturer = strings[0]; mModel = strings[1]; mType = strings[2]; mDescription = strings[2]; mVersion = strings[3]; mUri = strings[4]; } /** Loading @@ -74,12 +78,12 @@ public class UsbAccessory implements Parcelable { } /** * Returns the type of the accessory. * Returns a user visible description of the accessory. * * @return the accessory type * @return the accessory description */ public String getType() { return mType; public String getDescription() { return mDescription; } /** Loading @@ -91,6 +95,17 @@ public class UsbAccessory implements Parcelable { return mVersion; } /** * Returns the URI for the accessory. * This is an optional URI that might show information about the accessory * or provide the option to download an application for the accessory * * @return the accessory URI */ public String getUri() { return mUri; } private static boolean compare(String s1, String s2) { if (s1 == null) return (s2 == null); return s1.equals(s2); Loading @@ -102,8 +117,9 @@ public class UsbAccessory implements Parcelable { UsbAccessory accessory = (UsbAccessory)obj; return (compare(mManufacturer, accessory.getManufacturer()) && compare(mModel, accessory.getModel()) && compare(mType, accessory.getType()) && compare(mVersion, accessory.getVersion())); compare(mDescription, accessory.getDescription()) && compare(mVersion, accessory.getVersion()) && compare(mUri, accessory.getUri())); } return false; } Loading @@ -112,16 +128,18 @@ public class UsbAccessory implements Parcelable { public int hashCode() { return ((mManufacturer == null ? 0 : mManufacturer.hashCode()) ^ (mModel == null ? 0 : mModel.hashCode()) ^ (mType == null ? 0 : mType.hashCode()) ^ (mVersion == null ? 0 : mVersion.hashCode())); (mDescription == null ? 0 : mDescription.hashCode()) ^ (mVersion == null ? 0 : mVersion.hashCode()) ^ (mUri == null ? 0 : mUri.hashCode())); } @Override public String toString() { return "UsbAccessory[mManufacturer=" + mManufacturer + ", mModel=" + mModel + ", mType=" + mType + ", mVersion=" + mVersion + "]"; ", mDescription=" + mDescription + ", mVersion=" + mVersion + ", mUri=" + mUri + "]"; } public static final Parcelable.Creator<UsbAccessory> CREATOR = Loading @@ -129,9 +147,10 @@ public class UsbAccessory implements Parcelable { public UsbAccessory createFromParcel(Parcel in) { String manufacturer = in.readString(); String model = in.readString(); String type = in.readString(); String description = in.readString(); String version = in.readString(); return new UsbAccessory(manufacturer, model, type, version); String uri = in.readString(); return new UsbAccessory(manufacturer, model, description, version, uri); } public UsbAccessory[] newArray(int size) { Loading @@ -146,7 +165,8 @@ public class UsbAccessory implements Parcelable { public void writeToParcel(Parcel parcel, int flags) { parcel.writeString(mManufacturer); parcel.writeString(mModel); parcel.writeString(mType); parcel.writeString(mDescription); parcel.writeString(mVersion); parcel.writeString(mUri); } }
libs/usb/src/com/android/future/usb/UsbAccessory.java +34 −10 Original line number Diff line number Diff line Loading @@ -23,14 +23,16 @@ public final class UsbAccessory { private final String mManufacturer; private final String mModel; private final String mType; private final String mDescription; private final String mVersion; private final String mUri; /* package */ UsbAccessory(android.hardware.usb.UsbAccessory accessory) { mManufacturer = accessory.getManufacturer(); mModel = accessory.getModel(); mType = accessory.getType(); mDescription = accessory.getDescription(); mVersion = accessory.getVersion(); mUri = accessory.getUri(); } /** Loading @@ -52,12 +54,12 @@ public final class UsbAccessory { } /** * Returns the type of the accessory. * Returns a user visible description of the accessory. * * @return the accessory type * @return the accessory description */ public String getType() { return mType; public String getDescription() { return mDescription; } /** Loading @@ -69,6 +71,17 @@ public final class UsbAccessory { return mVersion; } /** * Returns the URI for the accessory. * This is an optional URI that might show information about the accessory * or provide the option to download an application for the accessory * * @return the accessory URI */ public String getUri() { return mUri; } private static boolean compare(String s1, String s2) { if (s1 == null) return (s2 == null); return s1.equals(s2); Loading @@ -80,17 +93,28 @@ public final class UsbAccessory { UsbAccessory accessory = (UsbAccessory)obj; return (compare(mManufacturer, accessory.getManufacturer()) && compare(mModel, accessory.getModel()) && compare(mType, accessory.getType()) && compare(mVersion, accessory.getVersion())); compare(mDescription, accessory.getDescription()) && compare(mVersion, accessory.getVersion()) && compare(mUri, accessory.getUri())); } return false; } @Override public int hashCode() { return ((mManufacturer == null ? 0 : mManufacturer.hashCode()) ^ (mModel == null ? 0 : mModel.hashCode()) ^ (mDescription == null ? 0 : mDescription.hashCode()) ^ (mVersion == null ? 0 : mVersion.hashCode()) ^ (mUri == null ? 0 : mUri.hashCode())); } @Override public String toString() { return "UsbAccessory[mManufacturer=" + mManufacturer + ", mModel=" + mModel + ", mType=" + mType + ", mVersion=" + mVersion + "]"; ", mDescription=" + mDescription + ", mVersion=" + mVersion + ", mUri=" + mUri + "]"; } }
libs/usb/src/com/android/future/usb/UsbManager.java +5 −5 Original line number Diff line number Diff line Loading @@ -130,7 +130,7 @@ public class UsbManager { try { return mService.openAccessory(new android.hardware.usb.UsbAccessory( accessory.getManufacturer(),accessory.getModel(), accessory.getType(), accessory.getVersion())); accessory.getDescription(), accessory.getVersion(), accessory.getUri())); } catch (RemoteException e) { Log.e(TAG, "RemoteException in openAccessory" , e); return null; Loading @@ -150,7 +150,7 @@ public class UsbManager { try { return mService.hasAccessoryPermission(new android.hardware.usb.UsbAccessory( accessory.getManufacturer(),accessory.getModel(), accessory.getType(), accessory.getVersion())); accessory.getDescription(), accessory.getVersion(), accessory.getUri())); } catch (RemoteException e) { Log.e(TAG, "RemoteException in hasPermission", e); return false; Loading @@ -174,7 +174,7 @@ public class UsbManager { try { mService.requestAccessoryPermission(new android.hardware.usb.UsbAccessory( accessory.getManufacturer(),accessory.getModel(), accessory.getType(), accessory.getVersion()), accessory.getDescription(), accessory.getVersion(), accessory.getUri()), mContext.getPackageName(), pi); } catch (RemoteException e) { Log.e(TAG, "RemoteException in requestPermission", e); Loading
libs/usb/tests/AccessoryChat/accessorychat/accessorychat.c +10 −1 Original line number Diff line number Diff line Loading @@ -133,10 +133,19 @@ static int usb_device_added(const char *devname, void* client_data) { } else { printf("Found possible android device - attempting to switch to accessory mode\n"); uint16_t protocol; ret = usb_device_control_transfer(device, USB_DIR_IN | USB_TYPE_VENDOR, ACCESSORY_GET_PROTOCOL, 0, 0, &protocol, sizeof(protocol), 0); if (ret == 2) printf("device supports protocol version %d\n", protocol); else fprintf(stderr, "failed to read protocol version\n"); send_string(device, ACCESSORY_STRING_MANUFACTURER, "Google, Inc."); send_string(device, ACCESSORY_STRING_MODEL, "AccessoryChat"); send_string(device, ACCESSORY_STRING_TYPE, "Sample Program"); send_string(device, ACCESSORY_STRING_DESCRIPTION, "Sample Program"); send_string(device, ACCESSORY_STRING_VERSION, "1.0"); send_string(device, ACCESSORY_STRING_URI, "http://www.android.com"); ret = usb_device_control_transfer(device, USB_DIR_OUT | USB_TYPE_VENDOR, ACCESSORY_START, 0, 0, 0, 0, 0); Loading