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 mSerial; 47 private final String mTags; 48 private final String mType; 49 private final String mVersionBaseOs; 50 private final String mVersionRelease; 51 private final String mVersionSdk; 52 private final String mVersionSecurityPatch; 53 private final String mVersionIncremental; 54 DevicePropertyInfo(String abi, String abi2, String abis, String abis32, String abis64, String board, String brand, String device, String fingerprint, String id, String manufacturer, String model, String product, String referenceFigerprint, String serial, String tags, String type, String versionBaseOs, String versionRelease, String versionSdk, String versionSecurityPatch, String versionIncremental)55 public DevicePropertyInfo(String abi, String abi2, String abis, String abis32, String abis64, 56 String board, String brand, String device, String fingerprint, String id, 57 String manufacturer, String model, String product, String referenceFigerprint, 58 String serial, String tags, String type, String versionBaseOs, String versionRelease, 59 String versionSdk, String versionSecurityPatch, String versionIncremental) { 60 mAbi = abi; 61 mAbi2 = abi2; 62 mAbis = abis; 63 mAbis32 = abis32; 64 mAbis64 = abis64; 65 mBoard = board; 66 mBrand = brand; 67 mDevice = device; 68 mFingerprint = fingerprint; 69 mId = id; 70 mManufacturer = manufacturer; 71 mModel = model; 72 mProduct = product; 73 mReferenceFingerprint = referenceFigerprint; 74 mSerial = serial; 75 mTags = tags; 76 mType = type; 77 mVersionBaseOs = versionBaseOs; 78 mVersionRelease = versionRelease; 79 mVersionSdk = versionSdk; 80 mVersionSecurityPatch = versionSecurityPatch; 81 mVersionIncremental = versionIncremental; 82 } 83 84 /** 85 * Return a {@code Map} with property keys prepended with a given prefix 86 * string. This is intended to be used to generate entries for 87 * {@code} Build tag attributes in CTS test results. 88 */ getPropertytMapWithPrefix(String prefix)89 public Map<String, String> getPropertytMapWithPrefix(String prefix) { 90 Map<String, String> propertyMap = new HashMap<>(); 91 92 propertyMap.put(prefix + "abi", mAbi); 93 propertyMap.put(prefix + "abi2", mAbi2); 94 propertyMap.put(prefix + "abis", mAbis); 95 propertyMap.put(prefix + "abis_32", mAbis32); 96 propertyMap.put(prefix + "abis_64", mAbis64); 97 propertyMap.put(prefix + "board", mBoard); 98 propertyMap.put(prefix + "brand", mBrand); 99 propertyMap.put(prefix + "device", mDevice); 100 propertyMap.put(prefix + "fingerprint", mFingerprint); 101 propertyMap.put(prefix + "id", mId); 102 propertyMap.put(prefix + "manufacturer", mManufacturer); 103 propertyMap.put(prefix + "model", mModel); 104 propertyMap.put(prefix + "product", mProduct); 105 propertyMap.put(prefix + "reference_fingerprint", mReferenceFingerprint); 106 propertyMap.put(prefix + "serial", mSerial); 107 propertyMap.put(prefix + "tags", mTags); 108 propertyMap.put(prefix + "type", mType); 109 propertyMap.put(prefix + "version_base_os", mVersionBaseOs); 110 propertyMap.put(prefix + "version_release", mVersionRelease); 111 propertyMap.put(prefix + "version_sdk", mVersionSdk); 112 propertyMap.put(prefix + "version_security_patch", mVersionSecurityPatch); 113 propertyMap.put(prefix + "version_incremental", mVersionIncremental); 114 115 return propertyMap; 116 } 117 118 } 119