1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.server.usb.descriptors; 17 18 import com.android.server.usb.descriptors.report.ReportCanvas; 19 20 /** 21 * @hide 22 * An audio class-specific Midi Endpoint. 23 * see midi10.pdf section 6.2.2 24 */ 25 public final class UsbACMidiEndpoint extends UsbACEndpoint { 26 private static final String TAG = "UsbACMidiEndpoint"; 27 28 private byte mNumJacks; 29 private byte[] mJackIds; 30 31 public UsbACMidiEndpoint(int length, byte type, int subclass) { 32 super(length, type, subclass); 33 } 34 35 public byte getNumJacks() { 36 return mNumJacks; 37 } 38 39 public byte[] getJackIds() { 40 return mJackIds; 41 } 42 43 @Override 44 public int parseRawDescriptors(ByteStream stream) { 45 super.parseRawDescriptors(stream); 46 47 mNumJacks = stream.getByte(); 48 mJackIds = new byte[mNumJacks]; 49 for (int jack = 0; jack < mNumJacks; jack++) { 50 mJackIds[jack] = stream.getByte(); 51 } 52 return mLength; 53 } 54 55 @Override 56 public void report(ReportCanvas canvas) { 57 super.report(canvas); 58 59 canvas.writeHeader(3, "AC Midi Endpoint: " + ReportCanvas.getHexString(getType()) 60 + " Length: " + getLength()); 61 canvas.openList(); 62 canvas.writeListItem("" + getNumJacks() + " Jacks."); 63 canvas.closeList(); 64 } 65 }