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.tradefed.targetprep; 18 19 import com.android.tradefed.build.IBuildInfo; 20 import com.android.tradefed.device.DeviceNotAvailableException; 21 import com.android.tradefed.device.ITestDevice; 22 import com.android.tradefed.targetprep.BuildError; 23 import com.android.tradefed.targetprep.TargetSetupError; 24 import com.android.tradefed.util.ArrayUtil; 25 26 import java.io.FileNotFoundException; 27 import java.util.HashMap; 28 import java.util.Map; 29 import java.util.Map.Entry; 30 31 /** 32 * Collects device info. 33 * This's a fork of DeviceInfoCollector and is forked in order to simplify the change 34 * deployment process and reduce the deployment time, which are critical for VTS services. 35 */ 36 public class VtsDeviceInfoCollector implements ITargetPreparer { 37 38 // TODO(trong): remove "cts:" prefix, will need a custom ResultReporter. 39 private static final Map<String, String> BUILD_KEYS = new HashMap<>(); 40 static { 41 BUILD_KEYS.put("cts:build_id", "ro.build.id"); 42 BUILD_KEYS.put("cts:build_product", "ro.product.name"); 43 BUILD_KEYS.put("cts:build_device", "ro.product.device"); 44 BUILD_KEYS.put("cts:build_board", "ro.product.board"); 45 BUILD_KEYS.put("cts:build_manufacturer", "ro.product.manufacturer"); 46 BUILD_KEYS.put("cts:build_brand", "ro.product.brand"); 47 BUILD_KEYS.put("cts:build_model", "ro.product.model"); 48 BUILD_KEYS.put("cts:build_type", "ro.build.type"); 49 BUILD_KEYS.put("cts:build_tags", "ro.build.tags"); 50 BUILD_KEYS.put("cts:build_fingerprint", "ro.vendor.build.fingerprint"); 51 BUILD_KEYS.put("cts:build_abi", "ro.product.cpu.abi"); 52 BUILD_KEYS.put("cts:build_abi2", "ro.product.cpu.abi2"); 53 BUILD_KEYS.put("cts:build_abis", "ro.product.cpu.abilist"); 54 BUILD_KEYS.put("cts:build_abis_32", "ro.product.cpu.abilist32"); 55 BUILD_KEYS.put("cts:build_abis_64", "ro.product.cpu.abilist64"); 56 BUILD_KEYS.put("cts:build_serial", "ro.serialno"); 57 BUILD_KEYS.put("cts:build_version_release", "ro.build.version.release"); 58 BUILD_KEYS.put("cts:build_version_sdk", "ro.build.version.sdk"); 59 BUILD_KEYS.put("cts:build_version_base_os", "ro.build.version.base_os"); 60 BUILD_KEYS.put("cts:build_version_security_patch", "ro.build.version.security_patch"); 61 BUILD_KEYS.put("cts:build_reference_fingerprint", "ro.build.reference.fingerprint"); 62 BUILD_KEYS.put("cts:build_system_fingerprint", "ro.build.fingerprint"); 63 BUILD_KEYS.put("cts:build_vendor_fingerprint", "ro.vendor.build.fingerprint"); 64 } 65 66 @Override setUp(ITestDevice device, IBuildInfo buildInfo)67 public void setUp(ITestDevice device, IBuildInfo buildInfo) throws TargetSetupError, 68 BuildError, DeviceNotAvailableException { 69 for (Entry<String, String> entry : BUILD_KEYS.entrySet()) { 70 buildInfo.addBuildAttribute(entry.getKey(), 71 ArrayUtil.join(",", device.getProperty(entry.getValue()))); 72 } 73 } 74 } 75