| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.hardware.usb; |
| 18 |
|
| 19 |
import android.annotation.Nullable; |
| 20 |
import android.os.Parcel; |
| 21 |
import android.os.Parcelable; |
| 22 |
import com.android.internal.util.Preconditions; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
public class UsbInterface implements Parcelable { |
| 38 |
|
| 39 |
private final int mId; |
| 40 |
private final int mAlternateSetting; |
| 41 |
private @Nullable final String mName; |
| 42 |
private final int mClass; |
| 43 |
private final int mSubclass; |
| 44 |
private final int mProtocol; |
| 45 |
|
| 46 |
|
| 47 |
private Parcelable[] mEndpoints; |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
public UsbInterface(int id, int alternateSetting, @Nullable String name, |
| 54 |
int Class, int subClass, int protocol) { |
| 55 |
mId = id; |
| 56 |
mAlternateSetting = alternateSetting; |
| 57 |
mName = name; |
| 58 |
mClass = Class; |
| 59 |
mSubclass = subClass; |
| 60 |
mProtocol = protocol; |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
public int getId() { |
| 71 |
return mId; |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
public int getAlternateSetting() { |
| 84 |
return mAlternateSetting; |
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
public @Nullable String getName() { |
| 93 |
return mName; |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
public int getInterfaceClass() { |
| 103 |
return mClass; |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
public int getInterfaceSubclass() { |
| 112 |
return mSubclass; |
| 113 |
} |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
public int getInterfaceProtocol() { |
| 121 |
return mProtocol; |
| 122 |
} |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
public int getEndpointCount() { |
| 130 |
return mEndpoints.length; |
| 131 |
} |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
public UsbEndpoint getEndpoint(int index) { |
| 139 |
return (UsbEndpoint)mEndpoints[index]; |
| 140 |
} |
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
public void setEndpoints(Parcelable[] endpoints) { |
| 147 |
mEndpoints = Preconditions.checkArrayElementsNotNull(endpoints, "endpoints"); |
| 148 |
} |
| 149 |
|
| 150 |
@Override |
| 151 |
public String toString() { |
| 152 |
StringBuilder builder = new StringBuilder("UsbInterface[mId=" + mId + |
| 153 |
",mAlternateSetting=" + mAlternateSetting + |
| 154 |
",mName=" + mName + ",mClass=" + mClass + |
| 155 |
",mSubclass=" + mSubclass + ",mProtocol=" + mProtocol + |
| 156 |
",mEndpoints=["); |
| 157 |
for (int i = 0; i < mEndpoints.length; i++) { |
| 158 |
builder.append("\n"); |
| 159 |
builder.append(mEndpoints[i].toString()); |
| 160 |
} |
| 161 |
builder.append("]"); |
| 162 |
return builder.toString(); |
| 163 |
} |
| 164 |
|
| 165 |
public static final @android.annotation.NonNull Parcelable.Creator<UsbInterface> CREATOR = |
| 166 |
new Parcelable.Creator<UsbInterface>() { |
| 167 |
public UsbInterface createFromParcel(Parcel in) { |
| 168 |
int id = in.readInt(); |
| 169 |
int alternateSetting = in.readInt(); |
| 170 |
String name = in.readString(); |
| 171 |
int Class = in.readInt(); |
| 172 |
int subClass = in.readInt(); |
| 173 |
int protocol = in.readInt(); |
| 174 |
Parcelable[] endpoints = in.readParcelableArray(UsbEndpoint.class.getClassLoader()); |
| 175 |
UsbInterface intf = new UsbInterface(id, alternateSetting, name, Class, subClass, protocol); |
| 176 |
intf.setEndpoints(endpoints); |
| 177 |
return intf; |
| 178 |
} |
| 179 |
|
| 180 |
public UsbInterface[] newArray(int size) { |
| 181 |
return new UsbInterface[size]; |
| 182 |
} |
| 183 |
}; |
| 184 |
|
| 185 |
public int describeContents() { |
| 186 |
return 0; |
| 187 |
} |
| 188 |
|
| 189 |
public void writeToParcel(Parcel parcel, int flags) { |
| 190 |
parcel.writeInt(mId); |
| 191 |
parcel.writeInt(mAlternateSetting); |
| 192 |
parcel.writeString(mName); |
| 193 |
parcel.writeInt(mClass); |
| 194 |
parcel.writeInt(mSubclass); |
| 195 |
parcel.writeInt(mProtocol); |
| 196 |
parcel.writeParcelableArray(mEndpoints, 0); |
| 197 |
} |
| 198 |
} |