1 /* 2 * Copyright (C) 2017 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 package com.android.compatibility.common.tradefed.result; 17 18 import com.android.tradefed.log.LogUtil.CLog; 19 import java.util.Map; 20 21 /** Override the result reporter to specify vendor device information in the VTS report. */ 22 public class VtsResultReporter extends ResultReporter { 23 private static final String BUILD_VENDOR_FINGERPRINT = "build_vendor_fingerprint"; 24 private static final String BUILD_VENDOR_MANUFACTURER = "build_vendor_manufacturer"; 25 private static final String BUILD_VENDOR_MODEL = "build_vendor_model"; 26 27 /** Determine if the property is empty or not. */ isEmptyProperty(String property)28 private static boolean isEmptyProperty(String property) { 29 return (property == null || property.trim().isEmpty() || property.equals("null")); 30 } 31 32 /** Override the vendor fingerprint and manufacturer in the report. */ 33 @Override addDeviceBuildInfoToResult()34 protected void addDeviceBuildInfoToResult() { 35 super.addDeviceBuildInfoToResult(); 36 Map<String, String> props = mapBuildInfo(); 37 String vendorFingerprint = props.get(BUILD_VENDOR_FINGERPRINT); 38 String vendorManufacturer = props.get(BUILD_VENDOR_MANUFACTURER); 39 String vendorModel = props.get(BUILD_VENDOR_MODEL); 40 if (!isEmptyProperty(vendorFingerprint) && !isEmptyProperty(vendorManufacturer) 41 && !isEmptyProperty(vendorModel)) { 42 addDeviceBuildInfoToResult(vendorFingerprint, vendorManufacturer, vendorModel); 43 } else { 44 CLog.w(String.format( 45 "Vendor build information missing. Fingerprint: '%s', manufacturer: '%s', model: '%s'", 46 vendorFingerprint, vendorManufacturer, vendorModel)); 47 } 48 } 49 } 50