Home | History | Annotate | Download | only in descriptors
      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 Header descriptor.
     23  * see Audio20.pdf section 4.7.2 Class-Specific AC Interface Descriptor
     24  */
     25 public final class Usb20ACHeader extends UsbACHeaderInterface {
     26     private static final String TAG = "Usb20ACHeader";
     27 
     28     private byte mCategory;     // 5:1 Constant, indicating the primary use of this audio function.
     29                                 // See audio20.pdf Appendix A.7, Audio Function Category Codes.
     30     private byte mControls;     // 8:1 See audio20.pdf Table 4-5.
     31 
     32     public Usb20ACHeader(int length, byte type, byte subtype, int subclass, int spec) {
     33         super(length, type, subtype, subclass, spec);
     34     }
     35 
     36     public byte getCategory() {
     37         return mCategory;
     38     }
     39 
     40     public byte getControls() {
     41         return mControls;
     42     }
     43 
     44     @Override
     45     public int parseRawDescriptors(ByteStream stream) {
     46         mCategory = stream.getByte();
     47         mTotalLength = stream.unpackUsbShort();
     48         mControls = stream.getByte();
     49 
     50         return mLength;
     51     }
     52 
     53     @Override
     54     public void report(ReportCanvas canvas) {
     55         super.report(canvas);
     56 
     57         canvas.openList();
     58         canvas.writeListItem("Category: " + ReportCanvas.getHexString(getCategory()));
     59         canvas.writeListItem("Controls: " + ReportCanvas.getHexString(getControls()));
     60         canvas.closeList();
     61     }
     62 }
     63