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.libraries.tv.tvsystem.display; 18 19 import java.util.Arrays; 20 import java.util.Objects; 21 22 /** 23 * Product-specific information about the display or the directly connected device on the 24 * display chain. For example, if the display is transitively connected, this field may contain 25 * product information about the intermediate device. 26 */ 27 public final class DeviceProductInfo { 28 private final String mName; 29 private final String mManufacturerPnpId; 30 private final String mProductId; 31 private final Integer mModelYear; 32 private final ManufactureDate mManufactureDate; 33 private final int[] mRelativeAddress; 34 DeviceProductInfo( String name, String manufacturerPnpId, String productId, Integer modelYear, ManufactureDate manufactureDate, int[] relativeAddress)35 public DeviceProductInfo( 36 String name, 37 String manufacturerPnpId, 38 String productId, 39 Integer modelYear, 40 ManufactureDate manufactureDate, 41 int[] relativeAddress) { 42 this.mName = name; 43 this.mManufacturerPnpId = manufacturerPnpId; 44 this.mProductId = productId; 45 this.mModelYear = modelYear; 46 this.mManufactureDate = manufactureDate; 47 this.mRelativeAddress = relativeAddress; 48 } 49 50 /** 51 * @return Display name. 52 */ getName()53 public String getName() { 54 return mName; 55 } 56 57 /** 58 * @return Manufacturer Plug and Play ID. 59 */ getManufacturerPnpId()60 public String getManufacturerPnpId() { 61 return mManufacturerPnpId; 62 } 63 64 /** 65 * @return Manufacturer product ID. 66 */ getProductId()67 public String getProductId() { 68 return mProductId; 69 } 70 71 /** 72 * @return Model year of the device. Typically exactly one of model year or 73 * manufacture date will be present. 74 */ getModelYear()75 public Integer getModelYear() { 76 return mModelYear; 77 } 78 79 /** 80 * @return Manufacture date. Typically exactly one of model year or manufacture 81 * date will be present. 82 */ getManufactureDate()83 public ManufactureDate getManufactureDate() { 84 return mManufactureDate; 85 } 86 87 /** 88 * @return Relative address in the display network. For example, for HDMI connected devices this 89 * can be its physical address. Each component of the address is in the range [0, 255]. 90 */ getRelativeAddress()91 public int[] getRelativeAddress() { 92 return mRelativeAddress; 93 } 94 95 @Override toString()96 public String toString() { 97 return "DeviceProductInfo{" 98 + "name=" 99 + mName 100 + ", manufacturerPnpId=" 101 + mManufacturerPnpId 102 + ", productId=" 103 + mProductId 104 + ", modelYear=" 105 + mModelYear 106 + ", manufactureDate=" 107 + mManufactureDate 108 + ", relativeAddress=" 109 + Arrays.toString(mRelativeAddress) 110 + '}'; 111 } 112 113 @Override equals(Object o)114 public boolean equals(Object o) { 115 if (this == o) return true; 116 if (o == null || getClass() != o.getClass()) return false; 117 DeviceProductInfo that = (DeviceProductInfo) o; 118 return Objects.equals(mName, that.mName) 119 && Objects.equals(mManufacturerPnpId, that.mManufacturerPnpId) 120 && Objects.equals(mProductId, that.mProductId) 121 && Objects.equals(mModelYear, that.mModelYear) 122 && Objects.equals(mManufactureDate, that.mManufactureDate) 123 && Arrays.equals(mRelativeAddress, that.mRelativeAddress); 124 } 125 126 @Override hashCode()127 public int hashCode() { 128 return Objects.hash(mName, mManufacturerPnpId, mProductId, mModelYear, mManufactureDate, 129 mRelativeAddress); 130 } 131 132 /** 133 * Stores information about the date of manufacture. 134 */ 135 public static class ManufactureDate { 136 private final Integer mWeek; 137 private final Integer mYear; 138 ManufactureDate(Integer week, Integer year)139 public ManufactureDate(Integer week, Integer year) { 140 mWeek = week; 141 mYear = year; 142 } 143 getYear()144 public Integer getYear() { 145 return mYear; 146 } 147 getWeek()148 public Integer getWeek() { 149 return mWeek; 150 } 151 152 @Override toString()153 public String toString() { 154 return "ManufactureDate{week=" + mWeek + ", year=" + mYear + '}'; 155 } 156 157 @Override equals(Object o)158 public boolean equals(Object o) { 159 if (this == o) return true; 160 if (o == null || getClass() != o.getClass()) return false; 161 ManufactureDate that = (ManufactureDate) o; 162 return Objects.equals(mWeek, that.mWeek) && Objects.equals(mYear, that.mYear); 163 } 164 165 @Override hashCode()166 public int hashCode() { 167 return Objects.hash(mWeek, mYear); 168 } 169 } 170 }