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