1 /* 2 * Copyright (C) 2010 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.build; 18 19 import com.android.tradefed.build.BuildInfoKey.BuildInfoFileKey; 20 21 import java.io.File; 22 23 /** 24 * A {@link IBuildInfo} that represents a complete Android device build and (optionally) its tests. 25 */ 26 public class DeviceBuildInfo extends BuildInfo implements IDeviceBuildInfo { 27 28 private static final long serialVersionUID = BuildSerializedVersion.VERSION; 29 private String mDeviceBuildFlavor = null; 30 DeviceBuildInfo()31 public DeviceBuildInfo() { 32 super(); 33 } 34 DeviceBuildInfo(String buildId, String buildTargetName)35 public DeviceBuildInfo(String buildId, String buildTargetName) { 36 super(buildId, buildTargetName); 37 } 38 DeviceBuildInfo(BuildInfo buildInfo)39 public DeviceBuildInfo(BuildInfo buildInfo) { 40 super(buildInfo); 41 } 42 43 /** 44 * {@inheritDoc} 45 * 46 * @return {@link #getDeviceImageVersion()} if not {@code null}, else 47 * {@link IBuildInfo#UNKNOWN_BUILD_ID} 48 * 49 * @see #getDeviceImageVersion() 50 */ 51 @Override getDeviceBuildId()52 public String getDeviceBuildId() { 53 String buildId = getDeviceImageVersion(); 54 return buildId == null ? UNKNOWN_BUILD_ID : buildId; 55 } 56 57 /** 58 * {@inheritDoc} 59 */ 60 @Override getDeviceBuildFlavor()61 public String getDeviceBuildFlavor() { 62 return mDeviceBuildFlavor == null ? getBuildFlavor() : mDeviceBuildFlavor; 63 } 64 65 /** {@inheritDoc} */ 66 @Override setDeviceBuildFlavor(String deviceBuildFlavor)67 public void setDeviceBuildFlavor(String deviceBuildFlavor) { 68 mDeviceBuildFlavor = deviceBuildFlavor; 69 } 70 71 /** 72 * {@inheritDoc} 73 */ 74 @Override getDeviceImageFile()75 public File getDeviceImageFile() { 76 return getFile(BuildInfoFileKey.DEVICE_IMAGE); 77 } 78 79 /** 80 * {@inheritDoc} 81 */ 82 @Override getDeviceImageVersion()83 public String getDeviceImageVersion() { 84 return getVersion(BuildInfoFileKey.DEVICE_IMAGE); 85 } 86 87 /** 88 * {@inheritDoc} 89 */ 90 @Override setDeviceImageFile(File deviceImageFile, String version)91 public void setDeviceImageFile(File deviceImageFile, String version) { 92 setFile(BuildInfoFileKey.DEVICE_IMAGE, deviceImageFile, version); 93 } 94 95 /** 96 * {@inheritDoc} 97 */ 98 @Override getUserDataImageFile()99 public File getUserDataImageFile() { 100 return getFile(BuildInfoFileKey.USERDATA_IMAGE); 101 } 102 103 /** 104 * {@inheritDoc} 105 */ 106 @Override getUserDataImageVersion()107 public String getUserDataImageVersion() { 108 return getVersion(BuildInfoFileKey.USERDATA_IMAGE); 109 } 110 111 /** 112 * {@inheritDoc} 113 */ 114 @Override setUserDataImageFile(File userDataFile, String version)115 public void setUserDataImageFile(File userDataFile, String version) { 116 setFile(BuildInfoFileKey.USERDATA_IMAGE, userDataFile, version); 117 } 118 119 /** 120 * {@inheritDoc} 121 */ 122 @Override getTestsDir()123 public File getTestsDir() { 124 return getFile(BuildInfoFileKey.TESTDIR_IMAGE); 125 } 126 127 /** 128 * {@inheritDoc} 129 */ 130 @Override getTestsDirVersion()131 public String getTestsDirVersion() { 132 return getVersion(BuildInfoFileKey.TESTDIR_IMAGE); 133 } 134 135 /** 136 * {@inheritDoc} 137 */ 138 @Override setTestsDir(File testsDir, String version)139 public void setTestsDir(File testsDir, String version) { 140 setFile(BuildInfoFileKey.TESTDIR_IMAGE, testsDir, version); 141 } 142 143 /** 144 * {@inheritDoc} 145 */ 146 @Override getBasebandImageFile()147 public File getBasebandImageFile() { 148 return getFile(BuildInfoFileKey.BASEBAND_IMAGE); 149 } 150 151 /** 152 * {@inheritDoc} 153 */ 154 @Override getBasebandVersion()155 public String getBasebandVersion() { 156 return getVersion(BuildInfoFileKey.BASEBAND_IMAGE); 157 } 158 159 /** 160 * {@inheritDoc} 161 */ 162 @Override setBasebandImage(File basebandFile, String version)163 public void setBasebandImage(File basebandFile, String version) { 164 setFile(BuildInfoFileKey.BASEBAND_IMAGE, basebandFile, version); 165 } 166 167 /** 168 * {@inheritDoc} 169 */ 170 @Override getBootloaderImageFile()171 public File getBootloaderImageFile() { 172 return getFile(BuildInfoFileKey.BOOTLOADER_IMAGE); 173 } 174 175 /** 176 * {@inheritDoc} 177 */ 178 @Override getBootloaderVersion()179 public String getBootloaderVersion() { 180 return getVersion(BuildInfoFileKey.BOOTLOADER_IMAGE); 181 } 182 183 /** 184 * {@inheritDoc} 185 */ 186 @Override setBootloaderImageFile(File bootloaderImgFile, String version)187 public void setBootloaderImageFile(File bootloaderImgFile, String version) { 188 setFile(BuildInfoFileKey.BOOTLOADER_IMAGE, bootloaderImgFile, version); 189 } 190 191 /** 192 * {@inheritDoc} 193 */ 194 @Override getOtaPackageFile()195 public File getOtaPackageFile() { 196 return getFile(BuildInfoFileKey.OTA_IMAGE); 197 } 198 199 /** 200 * {@inheritDoc} 201 */ 202 @Override getOtaPackageVersion()203 public String getOtaPackageVersion() { 204 return getVersion(BuildInfoFileKey.OTA_IMAGE); 205 } 206 207 /** 208 * {@inheritDoc} 209 */ 210 @Override setOtaPackageFile(File otaFile, String version)211 public void setOtaPackageFile(File otaFile, String version) { 212 setFile(BuildInfoFileKey.OTA_IMAGE, otaFile, version); 213 } 214 215 /** 216 * {@inheritDoc} 217 */ 218 @Override getMkbootimgFile()219 public File getMkbootimgFile() { 220 return getFile(BuildInfoFileKey.MKBOOTIMG_IMAGE); 221 } 222 223 /** 224 * {@inheritDoc} 225 */ 226 @Override getMkbootimgVersion()227 public String getMkbootimgVersion() { 228 return getVersion(BuildInfoFileKey.MKBOOTIMG_IMAGE); 229 } 230 231 /** 232 * {@inheritDoc} 233 */ 234 @Override setMkbootimgFile(File mkbootimg, String version)235 public void setMkbootimgFile(File mkbootimg, String version) { 236 setFile(BuildInfoFileKey.MKBOOTIMG_IMAGE, mkbootimg, version); 237 } 238 239 /** 240 * {@inheritDoc} 241 */ 242 @Override getRamdiskFile()243 public File getRamdiskFile() { 244 return getFile(BuildInfoFileKey.RAMDISK_IMAGE); 245 } 246 247 /** 248 * {@inheritDoc} 249 */ 250 @Override getRamdiskVersion()251 public String getRamdiskVersion() { 252 return getVersion(BuildInfoFileKey.RAMDISK_IMAGE); 253 } 254 255 /** 256 * {@inheritDoc} 257 */ 258 @Override setRamdiskFile(File ramdisk, String version)259 public void setRamdiskFile(File ramdisk, String version) { 260 setFile(BuildInfoFileKey.RAMDISK_IMAGE, ramdisk, version); 261 } 262 } 263