• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.config.Option;
21 import com.android.tradefed.device.DeviceNotAvailableException;
22 import com.android.tradefed.device.ITestDevice;
23 import com.android.tradefed.util.ArrayUtil;
24 import java.util.HashMap;
25 import java.util.Map;
26 import java.util.Map.Entry;
27 
28 /**
29  * Collects device info. This's a fork of DeviceInfoCollector and is forked in order to simplify the
30  * change deployment process and reduce the deployment time, which are critical for VTS services.
31  */
32 public class VtsDeviceInfoCollector implements ITargetPreparer {
33     // TODO(trong): remove "cts:" prefix, will need a custom ResultReporter.
34     private static final Map<String, String> BUILD_KEYS = new HashMap<>();
35     private static final Map<String, String> BUILD_LEGACY_PROPERTIES = new HashMap<>();
36     private static final long REBOOT_TIMEOUT = 1000 * 60 * 2; // 2 minutes.
37 
38     // The name of a system property which tells whether to stop properly configured
39     // native servers where properly configured means a server's init.rc is
40     // configured to stop when that property's value is 1.
41     static final String SYSPROP_VTS_NATIVE_SERVER = "vts.native_server.on";
42 
43     @Deprecated
44     @Option(name = "disable-framework", description = "Initialize device by stopping framework.")
45     private boolean mDisableFramework = false;
46 
47     static {
48         BUILD_KEYS.put("cts:build_id", "ro.build.id");
49         BUILD_KEYS.put("cts:build_product", "ro.product.name");
50         BUILD_KEYS.put("cts:build_device", "ro.product.device");
51         BUILD_KEYS.put("cts:build_board", "ro.product.board");
52         BUILD_KEYS.put("cts:build_manufacturer", "ro.product.vendor.manufacturer");
53         BUILD_KEYS.put("cts:build_brand", "ro.product.brand");
54         BUILD_KEYS.put("cts:build_model", "ro.product.vendor.model");
55         BUILD_KEYS.put("cts:build_type", "ro.build.type");
56         BUILD_KEYS.put("cts:build_tags", "ro.build.tags");
57         /**
58          * build_fingerprint is used for certification
59          */
60         BUILD_KEYS.put("cts:build_fingerprint", "ro.odm.build.fingerprint");
61         /**
62          * Unaltered is for retry.
63          */
64         BUILD_KEYS.put("cts:build_fingerprint_unaltered", "ro.build.fingerprint");
65         BUILD_KEYS.put("cts:build_abi", "ro.product.cpu.abi");
66         BUILD_KEYS.put("cts:build_abi2", "ro.product.cpu.abi2");
67         BUILD_KEYS.put("cts:build_abis", "ro.product.cpu.abilist");
68         BUILD_KEYS.put("cts:build_abis_32", "ro.product.cpu.abilist32");
69         BUILD_KEYS.put("cts:build_abis_64", "ro.product.cpu.abilist64");
70         BUILD_KEYS.put("cts:build_first_api_level", "ro.product.first_api_level");
71         BUILD_KEYS.put("cts:build_serial", "ro.serialno");
72         BUILD_KEYS.put("cts:build_version_release", "ro.build.version.release");
73         BUILD_KEYS.put("cts:build_version_sdk", "ro.build.version.sdk");
74         BUILD_KEYS.put("cts:build_version_base_os", "ro.build.version.base_os");
75         BUILD_KEYS.put("cts:build_version_security_patch", "ro.build.version.security_patch");
76         BUILD_KEYS.put("cts:build_reference_fingerprint", "ro.build.reference.fingerprint");
77         BUILD_KEYS.put("cts:build_system_fingerprint", "ro.build.fingerprint");
78         BUILD_KEYS.put("cts:build_vendor_fingerprint", "ro.vendor.build.fingerprint");
79         BUILD_KEYS.put("cts:build_vendor_manufacturer", "ro.product.vendor.manufacturer");
80         BUILD_KEYS.put("cts:build_vendor_model", "ro.product.vendor.model");
81 
82         BUILD_LEGACY_PROPERTIES.put(
83                 "ro.product.vendor.manufacturer", "ro.vendor.product.manufacturer");
84         BUILD_LEGACY_PROPERTIES.put("ro.product.vendor.model", "ro.vendor.product.model");
85         BUILD_LEGACY_PROPERTIES.put("ro.odm.build.fingerprint", "ro.vendor.build.fingerprint");
86     }
87 
88     @Override
setUp(ITestDevice device, IBuildInfo buildInfo)89     public void setUp(ITestDevice device, IBuildInfo buildInfo)
90             throws TargetSetupError, BuildError, DeviceNotAvailableException {
91         for (Entry<String, String> entry : BUILD_KEYS.entrySet()) {
92             String propertyValue = device.getProperty(entry.getValue());
93             if ((propertyValue == null || propertyValue.length() == 0)
94                     && BUILD_LEGACY_PROPERTIES.containsKey(entry.getValue())) {
95                 propertyValue = device.getProperty(BUILD_LEGACY_PROPERTIES.get(entry.getValue()));
96             }
97             buildInfo.addBuildAttribute(entry.getKey(), ArrayUtil.join(",", propertyValue));
98         }
99     }
100 }
101