Merge "Add video class-specific descriptors to UsbDescriptorParser framework."
This commit is contained in:
@@ -63,6 +63,8 @@ public class UsbDevice implements Parcelable {
|
||||
private final boolean mHasAudioPlayback;
|
||||
private final boolean mHasAudioCapture;
|
||||
private final boolean mHasMidi;
|
||||
private final boolean mHasVideoPlayback;
|
||||
private final boolean mHasVideoCapture;
|
||||
|
||||
/** All interfaces on the device. Initialized on first call to getInterfaceList */
|
||||
@UnsupportedAppUsage
|
||||
@@ -77,7 +79,8 @@ public class UsbDevice implements Parcelable {
|
||||
int protocol, @Nullable String manufacturerName, @Nullable String productName,
|
||||
@NonNull String version, @NonNull UsbConfiguration[] configurations,
|
||||
@NonNull IUsbSerialReader serialNumberReader,
|
||||
boolean hasAudioPlayback, boolean hasAudioCapture, boolean hasMidi) {
|
||||
boolean hasAudioPlayback, boolean hasAudioCapture, boolean hasMidi,
|
||||
boolean hasVideoPlayback, boolean hasVideoCapture) {
|
||||
mName = Preconditions.checkNotNull(name);
|
||||
mVendorId = vendorId;
|
||||
mProductId = productId;
|
||||
@@ -92,6 +95,8 @@ public class UsbDevice implements Parcelable {
|
||||
mHasAudioPlayback = hasAudioPlayback;
|
||||
mHasAudioCapture = hasAudioCapture;
|
||||
mHasMidi = hasMidi;
|
||||
mHasVideoPlayback = hasVideoPlayback;
|
||||
mHasVideoCapture = hasVideoCapture;
|
||||
|
||||
// Make sure the binder belongs to the system
|
||||
if (ActivityThread.isSystem()) {
|
||||
@@ -236,6 +241,16 @@ public class UsbDevice implements Parcelable {
|
||||
return mHasMidi;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public boolean getHasVideoPlayback() {
|
||||
return mHasVideoPlayback;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public boolean getHasVideoCapture() {
|
||||
return mHasVideoCapture;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link UsbConfiguration} at the given index.
|
||||
*
|
||||
@@ -316,6 +331,8 @@ public class UsbDevice implements Parcelable {
|
||||
+ ", mHasAudioPlayback=" + mHasAudioPlayback
|
||||
+ ", mHasAudioCapture=" + mHasAudioCapture
|
||||
+ ", mHasMidi=" + mHasMidi
|
||||
+ ", mHasVideoCapture=" + mHasVideoCapture
|
||||
+ ", mHasVideoPlayback=" + mHasVideoPlayback
|
||||
+ ", mConfigurations=[");
|
||||
for (int i = 0; i < mConfigurations.length; i++) {
|
||||
builder.append("\n");
|
||||
@@ -345,10 +362,12 @@ public class UsbDevice implements Parcelable {
|
||||
boolean hasAudioPlayback = in.readInt() == 1;
|
||||
boolean hasAudioCapture = in.readInt() == 1;
|
||||
boolean hasMidi = in.readInt() == 1;
|
||||
|
||||
boolean hasVideoPlayback = in.readInt() == 1;
|
||||
boolean hasVideoCapture = in.readInt() == 1;
|
||||
UsbDevice device = new UsbDevice(name, vendorId, productId, clasz, subClass, protocol,
|
||||
manufacturerName, productName, version, configurations, serialNumberReader,
|
||||
hasAudioPlayback, hasAudioCapture, hasMidi);
|
||||
hasAudioPlayback, hasAudioCapture, hasMidi,
|
||||
hasVideoPlayback, hasVideoCapture);
|
||||
|
||||
return device;
|
||||
}
|
||||
@@ -377,6 +396,8 @@ public class UsbDevice implements Parcelable {
|
||||
parcel.writeInt(mHasAudioPlayback ? 1 : 0);
|
||||
parcel.writeInt(mHasAudioCapture ? 1 : 0);
|
||||
parcel.writeInt(mHasMidi ? 1 : 0);
|
||||
parcel.writeInt(mHasVideoPlayback ? 1 : 0);
|
||||
parcel.writeInt(mHasVideoCapture ? 1 : 0);
|
||||
}
|
||||
|
||||
public static int getDeviceId(String name) {
|
||||
@@ -407,6 +428,8 @@ public class UsbDevice implements Parcelable {
|
||||
private final boolean mHasAudioPlayback;
|
||||
private final boolean mHasAudioCapture;
|
||||
private final boolean mHasMidi;
|
||||
private final boolean mHasVideoPlayback;
|
||||
private final boolean mHasVideoCapture;
|
||||
|
||||
// Temporary storage for serial number. Serial number reader need to be wrapped in a
|
||||
// IUsbSerialReader as they might be used as PII.
|
||||
@@ -416,7 +439,8 @@ public class UsbDevice implements Parcelable {
|
||||
int protocol, @Nullable String manufacturerName, @Nullable String productName,
|
||||
@NonNull String version, @NonNull UsbConfiguration[] configurations,
|
||||
@Nullable String serialNumber,
|
||||
boolean hasAudioPlayback, boolean hasAudioCapture, boolean hasMidi) {
|
||||
boolean hasAudioPlayback, boolean hasAudioCapture, boolean hasMidi,
|
||||
boolean hasVideoPlayback, boolean hasVideoCapture) {
|
||||
mName = Preconditions.checkNotNull(name);
|
||||
mVendorId = vendorId;
|
||||
mProductId = productId;
|
||||
@@ -431,6 +455,8 @@ public class UsbDevice implements Parcelable {
|
||||
mHasAudioPlayback = hasAudioPlayback;
|
||||
mHasAudioCapture = hasAudioCapture;
|
||||
mHasMidi = hasMidi;
|
||||
mHasVideoPlayback = hasVideoPlayback;
|
||||
mHasVideoCapture = hasVideoCapture;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -443,7 +469,8 @@ public class UsbDevice implements Parcelable {
|
||||
public UsbDevice build(@NonNull IUsbSerialReader serialReader) {
|
||||
return new UsbDevice(mName, mVendorId, mProductId, mClass, mSubclass, mProtocol,
|
||||
mManufacturerName, mProductName, mVersion, mConfigurations, serialReader,
|
||||
mHasAudioPlayback, mHasAudioCapture, mHasMidi);
|
||||
mHasAudioPlayback, mHasAudioCapture, mHasMidi,
|
||||
mHasVideoPlayback, mHasVideoCapture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ abstract class UsbACEndpoint extends UsbDescriptor {
|
||||
int length, byte type) {
|
||||
UsbInterfaceDescriptor interfaceDesc = parser.getCurInterface();
|
||||
int subClass = interfaceDesc.getUsbSubclass();
|
||||
// TODO shouldn't this switch on subtype?
|
||||
switch (subClass) {
|
||||
case AUDIO_AUDIOCONTROL:
|
||||
if (UsbDescriptorParser.DEBUG) {
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.ArrayList;
|
||||
*/
|
||||
public final class UsbDescriptorParser {
|
||||
private static final String TAG = "UsbDescriptorParser";
|
||||
public static final boolean DEBUG = true;
|
||||
public static final boolean DEBUG = false;
|
||||
|
||||
private final String mDeviceAddr;
|
||||
|
||||
@@ -43,6 +43,11 @@ public final class UsbDescriptorParser {
|
||||
// Obtained from the first AudioClass Header descriptor.
|
||||
private int mACInterfacesSpec = UsbDeviceDescriptor.USBSPEC_1_0;
|
||||
|
||||
// The VideoClass spec implemented by the VideoClass Interfaces
|
||||
// This may well be different than the overall USB Spec.
|
||||
// Obtained from the first VidieoClass Header descriptor.
|
||||
private int mVCInterfacesSpec = UsbDeviceDescriptor.USBSPEC_1_0;
|
||||
|
||||
/**
|
||||
* Connect this parser to an existing set of already parsed descriptors.
|
||||
* This is useful for reporting.
|
||||
@@ -90,6 +95,14 @@ public final class UsbDescriptorParser {
|
||||
return mACInterfacesSpec;
|
||||
}
|
||||
|
||||
public void setVCInterfaceSpec(int spec) {
|
||||
mVCInterfacesSpec = spec;
|
||||
}
|
||||
|
||||
public int getVCInterfaceSpec() {
|
||||
return mVCInterfacesSpec;
|
||||
}
|
||||
|
||||
private class UsbDescriptorsStreamFormatException extends Exception {
|
||||
String mMessage;
|
||||
UsbDescriptorsStreamFormatException(String message) {
|
||||
@@ -186,19 +199,20 @@ public final class UsbDescriptorParser {
|
||||
break;
|
||||
|
||||
case UsbDescriptor.CLASSID_VIDEO:
|
||||
Log.d(TAG, " UsbDescriptor.CLASSID_VIDEO subType:0x"
|
||||
+ Integer.toHexString(stream.getByte()));
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, " UsbDescriptor.CLASSID_VIDEO");
|
||||
}
|
||||
descriptor = UsbVCInterface.allocDescriptor(this, stream, length, type);
|
||||
break;
|
||||
|
||||
case UsbDescriptor.CLASSID_AUDIOVIDEO:
|
||||
Log.d(TAG, " UsbDescriptor.CLASSID_AUDIOVIDEO subType:0x"
|
||||
+ Integer.toHexString(stream.getByte()));
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, " UsbDescriptor.CLASSID_AUDIOVIDEO");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
Log.d(TAG, " Unparsed Class-specific Interface:0x"
|
||||
+ Integer.toHexString(mCurInterfaceDescriptor.getUsbClass()));
|
||||
Log.w(TAG, " Unparsed Class-specific");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -206,23 +220,32 @@ public final class UsbDescriptorParser {
|
||||
|
||||
case UsbDescriptor.DESCRIPTORTYPE_CLASSSPECIFIC_ENDPOINT:
|
||||
if (mCurInterfaceDescriptor != null) {
|
||||
switch (mCurInterfaceDescriptor.getUsbClass()) {
|
||||
int subClass = mCurInterfaceDescriptor.getUsbClass();
|
||||
switch (subClass) {
|
||||
case UsbDescriptor.CLASSID_AUDIO:
|
||||
descriptor = UsbACEndpoint.allocDescriptor(this, length, type);
|
||||
break;
|
||||
case UsbDescriptor.CLASSID_VIDEO:
|
||||
Log.d(TAG, "UsbDescriptor.CLASSID_VIDEO subType:0x"
|
||||
+ Integer.toHexString(stream.getByte()));
|
||||
descriptor = UsbVCEndpoint.allocDescriptor(this, length, type);
|
||||
|
||||
case UsbDescriptor.CLASSID_VIDEO: {
|
||||
Byte subtype = stream.getByte();
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "UsbDescriptor.CLASSID_VIDEO type:0x"
|
||||
+ Integer.toHexString(type));
|
||||
}
|
||||
descriptor = UsbVCEndpoint.allocDescriptor(this, length, type, subtype);
|
||||
}
|
||||
break;
|
||||
|
||||
case UsbDescriptor.CLASSID_AUDIOVIDEO:
|
||||
Log.d(TAG, "UsbDescriptor.CLASSID_AUDIOVIDEO subType:0x"
|
||||
+ Integer.toHexString(stream.getByte()));
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "UsbDescriptor.CLASSID_AUDIOVIDEO type:0x"
|
||||
+ Integer.toHexString(type));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
Log.d(TAG, " Unparsed Class-specific Endpoint:0x"
|
||||
+ Integer.toHexString(mCurInterfaceDescriptor.getUsbClass()));
|
||||
Log.w(TAG, " Unparsed Class-specific Endpoint:0x"
|
||||
+ Integer.toHexString(subClass));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -552,6 +575,30 @@ public final class UsbDescriptorParser {
|
||||
return hasAudioTerminal(UsbACInterface.ACI_INPUT_TERMINAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public boolean hasVideoCapture() {
|
||||
for (UsbDescriptor descriptor : mDescriptors) {
|
||||
if (descriptor instanceof UsbVCInputTerminal) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public boolean hasVideoPlayback() {
|
||||
for (UsbDescriptor descriptor : mDescriptors) {
|
||||
if (descriptor instanceof UsbVCOutputTerminal) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
|
||||
@@ -160,7 +160,8 @@ public final class UsbDeviceDescriptor extends UsbDescriptor {
|
||||
return new UsbDevice.Builder(parser.getDeviceAddr(), mVendorID,
|
||||
mProductID, mDevClass, mDevSubClass, mProtocol, mfgName, prodName, versionString,
|
||||
configs, serialStr, parser.hasAudioPlayback(), parser.hasAudioCapture(),
|
||||
parser.hasMIDIInterface());
|
||||
parser.hasMIDIInterface(),
|
||||
parser.hasVideoPlayback(), parser.hasVideoCapture());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,41 +20,54 @@ import android.util.Log;
|
||||
/**
|
||||
* @hide
|
||||
* A video class-specific Endpoint
|
||||
* see
|
||||
* see USB_Video_Class_1.1.pdf - 3.10 VideoStreaming Endpoint Descriptors
|
||||
*/
|
||||
abstract class UsbVCEndpoint extends UsbDescriptor {
|
||||
private static final String TAG = "UsbVCEndpoint";
|
||||
|
||||
UsbVCEndpoint(int length, byte type, int subclass) {
|
||||
|
||||
public static final byte VCEP_UNDEFINED = 0x00;
|
||||
public static final byte VCEP_GENERAL = 0x01;
|
||||
public static final byte VCEP_ENDPOINT = 0x02;
|
||||
public static final byte VCEP_INTERRUPT = 0x03;
|
||||
|
||||
UsbVCEndpoint(int length, byte type) {
|
||||
super(length, type);
|
||||
// mSubclass = subclass;
|
||||
}
|
||||
|
||||
public static UsbDescriptor allocDescriptor(UsbDescriptorParser parser,
|
||||
int length, byte type) {
|
||||
int length, byte type, byte subtype) {
|
||||
UsbInterfaceDescriptor interfaceDesc = parser.getCurInterface();
|
||||
int subClass = interfaceDesc.getUsbSubclass();
|
||||
switch (subClass) {
|
||||
// case AUDIO_AUDIOCONTROL:
|
||||
// if (UsbDescriptorParser.DEBUG) {
|
||||
// Log.i(TAG, "---> AUDIO_AUDIOCONTROL");
|
||||
// }
|
||||
// return new UsbACAudioControlEndpoint(length, type, subClass);
|
||||
//
|
||||
// case AUDIO_AUDIOSTREAMING:
|
||||
// if (UsbDescriptorParser.DEBUG) {
|
||||
// Log.i(TAG, "---> AUDIO_AUDIOSTREAMING");
|
||||
// }
|
||||
// return new UsbACAudioStreamEndpoint(length, type, subClass);
|
||||
//
|
||||
// case AUDIO_MIDISTREAMING:
|
||||
// if (UsbDescriptorParser.DEBUG) {
|
||||
// Log.i(TAG, "---> AUDIO_MIDISTREAMING");
|
||||
// }
|
||||
// return new UsbACMidiEndpoint(length, type, subClass);
|
||||
|
||||
// TODO - create classes for each specific subtype
|
||||
// (don't need it to answer if this device supports video
|
||||
switch (subtype) {
|
||||
case VCEP_UNDEFINED:
|
||||
if (UsbDescriptorParser.DEBUG) {
|
||||
Log.d(TAG, "---> VCEP_UNDEFINED");
|
||||
}
|
||||
return null;
|
||||
|
||||
case VCEP_GENERAL:
|
||||
if (UsbDescriptorParser.DEBUG) {
|
||||
Log.d(TAG, "---> VCEP_GENERAL");
|
||||
}
|
||||
return null;
|
||||
|
||||
case VCEP_ENDPOINT:
|
||||
if (UsbDescriptorParser.DEBUG) {
|
||||
Log.d(TAG, "---> VCEP_ENDPOINT");
|
||||
}
|
||||
return null;
|
||||
|
||||
case VCEP_INTERRUPT:
|
||||
if (UsbDescriptorParser.DEBUG) {
|
||||
Log.d(TAG, "---> VCEP_INTERRUPT");
|
||||
}
|
||||
return null;
|
||||
|
||||
default:
|
||||
Log.w(TAG, "Unknown Video Class Endpoint id:0x" + Integer.toHexString(subClass));
|
||||
Log.w(TAG, "Unknown Video Class Endpoint id:0x" + Integer.toHexString(subtype));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.server.usb.descriptors;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.server.usb.descriptors.report.ReportCanvas;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
* A video class-specific Interface Header.
|
||||
* see USB_Video_Class_1.1.pdf section 3.9.2 - Class-Specific VS Interface Descriptors
|
||||
*/
|
||||
public final class UsbVCHeader extends UsbVCHeaderInterface {
|
||||
private static final String TAG = "UsbVCHeader";
|
||||
|
||||
// TODO Add data members for this descriptor's data
|
||||
|
||||
public UsbVCHeader(int length, byte type, byte subtype, int spec) {
|
||||
super(length, type, subtype, spec);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int parseRawDescriptors(ByteStream stream) {
|
||||
if (UsbDescriptorParser.DEBUG) {
|
||||
Log.d(TAG, " ---> parseRawDescriptors()");
|
||||
}
|
||||
// TODO parse data members for this descriptor's data
|
||||
return super.parseRawDescriptors(stream);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void report(ReportCanvas canvas) {
|
||||
super.report(canvas);
|
||||
// TODO add reporting specific to this descriptor
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.server.usb.descriptors;
|
||||
|
||||
import com.android.server.usb.descriptors.report.ReportCanvas;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
* A video class-specific Interface Header super class.
|
||||
* see USB_Video_Class_1.1.pdf section 3.9.2 - Class-Specific VS Interface Descriptors
|
||||
*/
|
||||
public abstract class UsbVCHeaderInterface extends UsbVCInterface {
|
||||
private static final String TAG = "UsbVCHeaderInterface";
|
||||
|
||||
protected int mVDCRelease; // Video Device Class Specification Release (BCD).
|
||||
protected int mTotalLength; // Total number of bytes returned for the class-specific
|
||||
// VideoControl interface descriptor. Includes the combined length
|
||||
// of this descriptor header and all Unit and Terminal descriptors.
|
||||
|
||||
public UsbVCHeaderInterface(
|
||||
int length, byte type, byte subtype, int vdcRelease) {
|
||||
super(length, type, subtype);
|
||||
mVDCRelease = vdcRelease;
|
||||
}
|
||||
|
||||
public int getVDCRelease() {
|
||||
return mVDCRelease;
|
||||
}
|
||||
|
||||
public int getTotalLength() {
|
||||
return mTotalLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void report(ReportCanvas canvas) {
|
||||
super.report(canvas);
|
||||
|
||||
canvas.openList();
|
||||
canvas.writeListItem("Release: " + ReportCanvas.getBCDString(getVDCRelease()));
|
||||
canvas.writeListItem("Total Length: " + getTotalLength());
|
||||
canvas.closeList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.server.usb.descriptors;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.server.usb.descriptors.report.ReportCanvas;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
* A video class-specific Input terminal interface.
|
||||
* see USB_Video_Class_1.1.pdf section 3.7.2.1 Input Terminal Descriptor
|
||||
*/
|
||||
public final class UsbVCInputTerminal extends UsbVCInterface {
|
||||
private static final String TAG = "UsbVCInputTerminal";
|
||||
|
||||
// TODO Define members to hold the data from this descriptor
|
||||
public UsbVCInputTerminal(int length, byte type, byte subtype) {
|
||||
super(length, type, subtype);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int parseRawDescriptors(ByteStream stream) {
|
||||
// TODO Parse the data from this descriptor
|
||||
if (UsbDescriptorParser.DEBUG) {
|
||||
Log.d(TAG, " ---> parseRawDescriptors()");
|
||||
}
|
||||
return super.parseRawDescriptors(stream);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void report(ReportCanvas canvas) {
|
||||
// TODO Add reporting specific to this descriptor
|
||||
super.report(canvas);
|
||||
}
|
||||
};
|
||||
@@ -29,20 +29,17 @@ public abstract class UsbVCInterface extends UsbDescriptor {
|
||||
public static final byte VCI_UNDEFINED = 0x00;
|
||||
public static final byte VCI_VEADER = 0x01;
|
||||
public static final byte VCI_INPUT_TERMINAL = 0x02;
|
||||
public static final byte VCI_VOUTPUT_TERMINAL = 0x03;
|
||||
public static final byte VCI_OUTPUT_TERMINAL = 0x03;
|
||||
public static final byte VCI_SELECTOR_UNIT = 0x04;
|
||||
public static final byte VCI_VROCESSING_UNIT = 0x05;
|
||||
public static final byte VCI_VEXTENSION_UNIT = 0x06;
|
||||
public static final byte VCI_PROCESSING_UNIT = 0x05;
|
||||
public static final byte VCI_EXTENSION_UNIT = 0x06;
|
||||
|
||||
// See “Universal Serial Bus Device Class Definition for Video
|
||||
// See “Universal Serial Bus Device Class Definition for Video
|
||||
protected final byte mSubtype; // 2:1 HEADER descriptor subtype
|
||||
protected final int mSubclass; // from the mSubclass member of the
|
||||
// "enclosing" Interface Descriptor
|
||||
|
||||
public UsbVCInterface(int length, byte type, byte subtype, int subclass) {
|
||||
public UsbVCInterface(int length, byte type, byte subtype) {
|
||||
super(length, type);
|
||||
mSubtype = subtype;
|
||||
mSubclass = subclass;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,12 +49,10 @@ public abstract class UsbVCInterface extends UsbDescriptor {
|
||||
int length, byte type) {
|
||||
byte subtype = stream.getByte();
|
||||
UsbInterfaceDescriptor interfaceDesc = parser.getCurInterface();
|
||||
int subClass = interfaceDesc.getUsbSubclass();
|
||||
if (UsbDescriptorParser.DEBUG) {
|
||||
Log.d(TAG, " Video Class-specific Interface subClass:0x"
|
||||
+ Integer.toHexString(subClass));
|
||||
Log.d(TAG, " Video Class-specific Interface subtype: " + subtype);
|
||||
}
|
||||
switch (subClass) {
|
||||
switch (subtype) {
|
||||
// TODO - Create descriptor classes and parse these...
|
||||
case VCI_UNDEFINED:
|
||||
if (UsbDescriptorParser.DEBUG) {
|
||||
@@ -66,44 +61,51 @@ public abstract class UsbVCInterface extends UsbDescriptor {
|
||||
break;
|
||||
|
||||
case VCI_VEADER:
|
||||
{
|
||||
if (UsbDescriptorParser.DEBUG) {
|
||||
Log.d(TAG, " ---> VCI_VEADER");
|
||||
}
|
||||
break;
|
||||
int vcInterfaceSpec = stream.unpackUsbShort();
|
||||
parser.setVCInterfaceSpec(vcInterfaceSpec);
|
||||
if (UsbDescriptorParser.DEBUG) {
|
||||
Log.d(TAG, " vcInterfaceSpec:0x" + Integer.toHexString(vcInterfaceSpec));
|
||||
}
|
||||
return new UsbVCHeader(length, type, subtype, vcInterfaceSpec);
|
||||
}
|
||||
|
||||
case VCI_INPUT_TERMINAL:
|
||||
if (UsbDescriptorParser.DEBUG) {
|
||||
Log.d(TAG, " ---> VCI_INPUT_TERMINAL");
|
||||
}
|
||||
break;
|
||||
return new UsbVCInputTerminal(length, type, subtype);
|
||||
|
||||
case VCI_VOUTPUT_TERMINAL:
|
||||
case VCI_OUTPUT_TERMINAL:
|
||||
if (UsbDescriptorParser.DEBUG) {
|
||||
Log.d(TAG, " ---> VCI_VOUTPUT_TERMINAL");
|
||||
Log.d(TAG, " ---> VCI_OUTPUT_TERMINAL");
|
||||
}
|
||||
break;
|
||||
return new UsbVCOutputTerminal(length, type, subtype);
|
||||
|
||||
case VCI_SELECTOR_UNIT:
|
||||
if (UsbDescriptorParser.DEBUG) {
|
||||
Log.d(TAG, " ---> VCI_SELECTOR_UNIT");
|
||||
}
|
||||
break;
|
||||
return new UsbVCSelectorUnit(length, type, subtype);
|
||||
|
||||
case VCI_VROCESSING_UNIT:
|
||||
case VCI_PROCESSING_UNIT:
|
||||
if (UsbDescriptorParser.DEBUG) {
|
||||
Log.d(TAG, " ---> VCI_VROCESSING_UNIT");
|
||||
Log.d(TAG, " ---> VCI_PROCESSING_UNIT");
|
||||
}
|
||||
break;
|
||||
return new UsbVCProcessingUnit(length, type, subtype);
|
||||
|
||||
case VCI_VEXTENSION_UNIT:
|
||||
case VCI_EXTENSION_UNIT:
|
||||
if (UsbDescriptorParser.DEBUG) {
|
||||
Log.d(TAG, " ---> VCI_VEXTENSION_UNIT");
|
||||
Log.d(TAG, " ---> VCI_EXTENSION_UNIT");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
Log.w(TAG, "Unknown Video Class Interface Subclass: 0x"
|
||||
+ Integer.toHexString(subClass));
|
||||
Log.w(TAG, "Unknown Video Class Interface subtype: 0x"
|
||||
+ Integer.toHexString(subtype));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.server.usb.descriptors;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.server.usb.descriptors.report.ReportCanvas;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
* A video class-specific Output Terminal Descriptor.
|
||||
* see USB_Video_Class_1.1.pdf section 3.7.2.2 Output Terminal Descriptor
|
||||
*/
|
||||
public final class UsbVCOutputTerminal extends UsbVCInterface {
|
||||
private static final String TAG = "UsbVCOutputTerminal";
|
||||
|
||||
// TODO Add members for the data in this descriptor
|
||||
public UsbVCOutputTerminal(int length, byte type, byte subtype) {
|
||||
super(length, type, subtype);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int parseRawDescriptors(ByteStream stream) {
|
||||
// TODO Parse the data in this descriptor
|
||||
if (UsbDescriptorParser.DEBUG) {
|
||||
Log.d(TAG, " ---> parseRawDescriptors()");
|
||||
}
|
||||
return super.parseRawDescriptors(stream);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void report(ReportCanvas canvas) {
|
||||
super.report(canvas);
|
||||
// TODO Add reporting specific to this descriptor
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.server.usb.descriptors;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.server.usb.descriptors.report.ReportCanvas;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
* An video class-specific Processing Unit Interface.
|
||||
* see USB_Video_Class_1.1.pdf section Table 3-8 Processing Unit Descriptor
|
||||
*/
|
||||
public final class UsbVCProcessingUnit extends UsbVCInterface {
|
||||
private static final String TAG = "UsbVCProcessingUnit";
|
||||
|
||||
// TODO Add data members for this descriptor
|
||||
|
||||
public UsbVCProcessingUnit(int length, byte type, byte subtype) {
|
||||
super(length, type, subtype);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int parseRawDescriptors(ByteStream stream) {
|
||||
// TODO Parse this descriptor
|
||||
if (UsbDescriptorParser.DEBUG) {
|
||||
Log.d(TAG, " ---> parseRawDescriptors()");
|
||||
}
|
||||
return super.parseRawDescriptors(stream);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void report(ReportCanvas canvas) {
|
||||
super.report(canvas);
|
||||
// TODO Add reporting specific to this descriptor
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.server.usb.descriptors;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.server.usb.descriptors.report.ReportCanvas;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
* An video class-specific Selector Unit Descriptor
|
||||
* see USB_Video_Class_1.1.pdf section 3.7.2.4
|
||||
*/
|
||||
public final class UsbVCSelectorUnit extends UsbVCInterface {
|
||||
private static final String TAG = "UsbVCSelectorUnit";
|
||||
|
||||
// TODO Add data members for this descriptor
|
||||
|
||||
public UsbVCSelectorUnit(int length, byte type, byte subtype) {
|
||||
super(length, type, subtype);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int parseRawDescriptors(ByteStream stream) {
|
||||
// TODO Parse this descriptor
|
||||
if (UsbDescriptorParser.DEBUG) {
|
||||
Log.d(TAG, " ---> parseRawDescriptors()");
|
||||
}
|
||||
return super.parseRawDescriptors(stream);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void report(ReportCanvas canvas) {
|
||||
super.report(canvas);
|
||||
// TODO Add reporting specific to this descriptor
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user