1 /* 2 * Copyright (C) 2016 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.compatibility.common.util; 18 19 import java.util.HashMap; 20 import java.util.Map; 21 22 /** 23 * Utility class for collecting device information. This is used to enforce 24 * consistent property collection host-side and device-side for CTS reports. 25 * 26 * Note that properties across sources can differ, e.g. {@code android.os.Build} 27 * properties sometimes deviate from the read-only properties that they're based 28 * on. 29 */ 30 public final class DevicePropertyInfo { 31 32 private final String mAbi; 33 private final String mAbi2; 34 private final String mAbis; 35 private final String mAbis32; 36 private final String mAbis64; 37 private final String mBoard; 38 private final String mBrand; 39 private final String mDevice; 40 private final String mFingerprint; 41 private final String mId; 42 private final String mManufacturer; 43 private final String mModel; 44 private final String mProduct; 45 private final String mReferenceFingerprint; 46 private final String mVendorFingerprint; 47 private final String mSerial; 48 private final String mTags; 49 private final String mType; 50 private final String mVersionBaseOs; 51 private final String mVersionRelease; 52 private final String mVersionSdk; 53 private final String mVersionSecurityPatch; 54 private final String mVersionIncremental; 55 private final String mBootimageFingerprint; 56 DevicePropertyInfo( String abi, String abi2, String abis, String abis32, String abis64, String board, String brand, String device, String fingerprint, String vendorFingerprint, String id, String manufacturer, String model, String product, String referenceFingerprint, String serial, String tags, String type, String versionBaseOs, String versionRelease, String versionSdk, String versionSecurityPatch, String versionIncremental)57 public DevicePropertyInfo( 58 String abi, 59 String abi2, 60 String abis, 61 String abis32, 62 String abis64, 63 String board, 64 String brand, 65 String device, 66 String fingerprint, 67 String vendorFingerprint, 68 String id, 69 String manufacturer, 70 String model, 71 String product, 72 String referenceFingerprint, 73 String serial, 74 String tags, 75 String type, 76 String versionBaseOs, 77 String versionRelease, 78 String versionSdk, 79 String versionSecurityPatch, 80 String versionIncremental) { 81 mAbi = abi; 82 mAbi2 = abi2; 83 mAbis = abis; 84 mAbis32 = abis32; 85 mAbis64 = abis64; 86 mBoard = board; 87 mBrand = brand; 88 mDevice = device; 89 mFingerprint = fingerprint; 90 mVendorFingerprint = vendorFingerprint; 91 mId = id; 92 mManufacturer = manufacturer; 93 mModel = model; 94 mProduct = product; 95 mReferenceFingerprint = referenceFingerprint; 96 mSerial = serial; 97 mTags = tags; 98 mType = type; 99 mVersionBaseOs = versionBaseOs; 100 mVersionRelease = versionRelease; 101 mVersionSdk = versionSdk; 102 mVersionSecurityPatch = versionSecurityPatch; 103 mVersionIncremental = versionIncremental; 104 mBootimageFingerprint = "unknown"; 105 } 106 DevicePropertyInfo( String abi, String abi2, String abis, String abis32, String abis64, String board, String brand, String device, String fingerprint, String vendorFingerprint, String id, String manufacturer, String model, String product, String referenceFingerprint, String serial, String tags, String type, String versionBaseOs, String versionRelease, String versionSdk, String versionSecurityPatch, String versionIncremental, String bootimageFingerprint)107 public DevicePropertyInfo( 108 String abi, 109 String abi2, 110 String abis, 111 String abis32, 112 String abis64, 113 String board, 114 String brand, 115 String device, 116 String fingerprint, 117 String vendorFingerprint, 118 String id, 119 String manufacturer, 120 String model, 121 String product, 122 String referenceFingerprint, 123 String serial, 124 String tags, 125 String type, 126 String versionBaseOs, 127 String versionRelease, 128 String versionSdk, 129 String versionSecurityPatch, 130 String versionIncremental, 131 String bootimageFingerprint) { 132 mAbi = abi; 133 mAbi2 = abi2; 134 mAbis = abis; 135 mAbis32 = abis32; 136 mAbis64 = abis64; 137 mBoard = board; 138 mBrand = brand; 139 mDevice = device; 140 mFingerprint = fingerprint; 141 mVendorFingerprint = vendorFingerprint; 142 mId = id; 143 mManufacturer = manufacturer; 144 mModel = model; 145 mProduct = product; 146 mReferenceFingerprint = referenceFingerprint; 147 mSerial = serial; 148 mTags = tags; 149 mType = type; 150 mVersionBaseOs = versionBaseOs; 151 mVersionRelease = versionRelease; 152 mVersionSdk = versionSdk; 153 mVersionSecurityPatch = versionSecurityPatch; 154 mVersionIncremental = versionIncremental; 155 mBootimageFingerprint = bootimageFingerprint; 156 } 157 158 /** 159 * Return a {@code Map} with property keys prepended with a given prefix 160 * string. This is intended to be used to generate entries for 161 * {@code} Build tag attributes in CTS test results. 162 */ getPropertytMapWithPrefix(String prefix)163 public Map<String, String> getPropertytMapWithPrefix(String prefix) { 164 Map<String, String> propertyMap = new HashMap<>(); 165 166 propertyMap.put(prefix + "abi", mAbi); 167 propertyMap.put(prefix + "abi2", mAbi2); 168 propertyMap.put(prefix + "abis", mAbis); 169 propertyMap.put(prefix + "abis_32", mAbis32); 170 propertyMap.put(prefix + "abis_64", mAbis64); 171 propertyMap.put(prefix + "board", mBoard); 172 propertyMap.put(prefix + "brand", mBrand); 173 propertyMap.put(prefix + "device", mDevice); 174 propertyMap.put(prefix + "fingerprint", mFingerprint); 175 propertyMap.put(prefix + "vendor_fingerprint", mVendorFingerprint); 176 propertyMap.put(prefix + "bootimage_fingerprint", mBootimageFingerprint); 177 propertyMap.put(prefix + "id", mId); 178 propertyMap.put(prefix + "manufacturer", mManufacturer); 179 propertyMap.put(prefix + "model", mModel); 180 propertyMap.put(prefix + "product", mProduct); 181 propertyMap.put(prefix + "reference_fingerprint", mReferenceFingerprint); 182 propertyMap.put(prefix + "serial", mSerial); 183 propertyMap.put(prefix + "tags", mTags); 184 propertyMap.put(prefix + "type", mType); 185 propertyMap.put(prefix + "version_base_os", mVersionBaseOs); 186 propertyMap.put(prefix + "version_release", mVersionRelease); 187 propertyMap.put(prefix + "version_sdk", mVersionSdk); 188 propertyMap.put(prefix + "version_security_patch", mVersionSecurityPatch); 189 propertyMap.put(prefix + "version_incremental", mVersionIncremental); 190 191 return propertyMap; 192 } 193 194 } 195