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.tree; 17 18 import com.android.server.usb.descriptors.UsbDeviceDescriptor; 19 import com.android.server.usb.descriptors.report.ReportCanvas; 20 21 import java.util.ArrayList; 22 23 /** 24 * @hide 25 * A class to contain THE device descriptor at the root of the tree. 26 */ 27 public final class UsbDescriptorsDeviceNode extends UsbDescriptorsTreeNode { 28 private static final String TAG = "UsbDescriptorsDeviceNode"; 29 30 private final UsbDeviceDescriptor mDeviceDescriptor; 31 32 private final ArrayList<UsbDescriptorsConfigNode> mConfigNodes = new ArrayList<>(); 33 34 /** 35 * Constructor. 36 * @param deviceDescriptor The Device Descriptor object wrapped by this tree node. 37 */ UsbDescriptorsDeviceNode(UsbDeviceDescriptor deviceDescriptor)38 public UsbDescriptorsDeviceNode(UsbDeviceDescriptor deviceDescriptor) { 39 mDeviceDescriptor = deviceDescriptor; 40 } 41 42 /** 43 * Adds a Configuration node to the assocated device node. 44 */ addConfigDescriptorNode(UsbDescriptorsConfigNode configNode)45 public void addConfigDescriptorNode(UsbDescriptorsConfigNode configNode) { 46 mConfigNodes.add(configNode); 47 } 48 49 @Override report(ReportCanvas canvas)50 public void report(ReportCanvas canvas) { 51 mDeviceDescriptor.report(canvas); 52 for (UsbDescriptorsConfigNode node : mConfigNodes) { 53 node.report(canvas); 54 } 55 } 56 } 57