1 /*
2  * Copyright (C) 2020 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 
17 package com.android.tests.usbgadget.libusb;
18 
19 import com.google.common.collect.ImmutableList;
20 import com.sun.jna.Pointer;
21 import com.sun.jna.Structure;
22 import java.util.List;
23 
24 public class InterfaceDescriptor extends Structure {
25     public static class ByReference extends InterfaceDescriptor implements Structure.ByReference {}
26 
InterfaceDescriptor()27     public InterfaceDescriptor() {}
28 
InterfaceDescriptor(Pointer p)29     public InterfaceDescriptor(Pointer p) {
30         super(p);
31         read();
32     }
33 
toArray(int size)34     public InterfaceDescriptor[] toArray(int size) {
35         return (InterfaceDescriptor[]) super.toArray(size);
36     }
37 
38     @Override
getFieldOrder()39     protected List<String> getFieldOrder() {
40         return ImmutableList.of("bLength", "bDescriptorType", "bInterfaceNumber",
41                 "bAlternateSetting", "bNumEndpoints", "bInterfaceClass", "bInterfaceSubClass",
42                 "bInterfaceProtocol", "iInterface", "endpoint", "extra", "extra_length");
43     }
44 
45     public byte bLength;
46     public byte bDescriptorType;
47     public byte bInterfaceNumber;
48     public byte bAlternateSetting;
49     public byte bNumEndpoints;
50     public byte bInterfaceClass;
51     public byte bInterfaceSubClass;
52     public byte bInterfaceProtocol;
53     public byte iInterface;
54     public Pointer endpoint;
55     public Pointer extra;
56     public int extra_length;
57 }
58