1 /*
2  * Copyright (C) 2011 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 java.io.File;
20 
21 /**
22  * A {@link IDeviceBuildInfo} that also contains a {@link ITestzipBuildInfo}.
23  */
24 public class TestzipDeviceBuildInfo extends BuildInfo implements IDeviceBuildInfo, ITestzipBuildInfo {
25 
26     private static final long serialVersionUID = BuildSerializedVersion.VERSION;
27     private IDeviceBuildInfo mDeviceBuild;
28     private ITestzipBuildInfo mTestzipBuildInfo;
29 
30 
31     @Override
getTestzipDir()32     public File getTestzipDir() {
33         return mTestzipBuildInfo.getTestzipDir();
34     }
35 
36     @Override
setTestzipDir(File testsZipFile, String version)37     public void setTestzipDir(File testsZipFile, String version) {
38         mTestzipBuildInfo.setTestzipDir(testsZipFile, version);
39     }
40 
41     @Override
getTestzipDirVersion()42     public String getTestzipDirVersion() {
43         return mTestzipBuildInfo.getTestzipDirVersion();
44     }
45 
46     /**
47      * @see DeviceBuildInfo#DeviceBuildInfo(String, String)
48      */
TestzipDeviceBuildInfo(String buildId, String buildName)49     public TestzipDeviceBuildInfo(String buildId, String buildName) {
50         super(buildId, buildName);
51     }
52 
53     /**
54      * @return the {@link IDeviceBuildInfo} for the device.
55      */
getDeviceBuildInfo()56     public IDeviceBuildInfo getDeviceBuildInfo() {
57         return mDeviceBuild;
58     }
59 
60     /**
61      * @return the {@link IDeviceBuildInfo} for the device.
62      */
setTestzipBuild(ITestzipBuildInfo testzipBuild)63     public void setTestzipBuild(ITestzipBuildInfo testzipBuild) {
64         mTestzipBuildInfo = testzipBuild;
65     }
66 
67     /**
68      * @return the {@link ITestzipBuildInfo} for the application.
69      */
getTestzipBuildInfo()70     public ITestzipBuildInfo getTestzipBuildInfo() {
71         return mTestzipBuildInfo;
72     }
73 
74     /**
75      * {@inheritDoc}
76      */
77     @Override
getDeviceBuildId()78     public String getDeviceBuildId() {
79         return mDeviceBuild.getDeviceBuildId();
80     }
81 
82     /**
83      * {@inheritDoc}
84      */
85     @Override
getDeviceBuildFlavor()86     public String getDeviceBuildFlavor() {
87         return mDeviceBuild.getDeviceBuildFlavor();
88     }
89     /**
90      * {@inheritDoc}
91      */
92     @Override
getDeviceImageFile()93     public File getDeviceImageFile() {
94         return mDeviceBuild.getDeviceImageFile();
95     }
96 
97     /**
98      * {@inheritDoc}
99      */
100     @Override
getDeviceImageVersion()101     public String getDeviceImageVersion() {
102         return mDeviceBuild.getDeviceImageVersion();
103     }
104 
105     /**
106      * {@inheritDoc}
107      */
108     @Override
setDeviceImageFile(File deviceImageFile, String version)109     public void setDeviceImageFile(File deviceImageFile, String version) {
110         mDeviceBuild.setDeviceImageFile(deviceImageFile, version);
111     }
112 
113     /**
114      * {@inheritDoc}
115      */
116     @Override
getUserDataImageFile()117     public File getUserDataImageFile() {
118         return mDeviceBuild.getUserDataImageFile();
119     }
120 
121     /**
122      * {@inheritDoc}
123      */
124     @Override
getUserDataImageVersion()125     public String getUserDataImageVersion() {
126         return mDeviceBuild.getUserDataImageVersion();
127     }
128 
129     /**
130      * {@inheritDoc}
131      */
132     @Override
setUserDataImageFile(File userDataFile, String version)133     public void setUserDataImageFile(File userDataFile, String version) {
134         mDeviceBuild.setUserDataImageFile(userDataFile, version);
135     }
136 
137     /**
138      * {@inheritDoc}
139      */
140     @Override
getTestsDir()141     public File getTestsDir() {
142         return mTestzipBuildInfo.getTestzipDir();
143     }
144 
145     /**
146      * {@inheritDoc}
147      */
148     @Override
getTestsDirVersion()149     public String getTestsDirVersion() {
150         return mTestzipBuildInfo.getTestzipDirVersion();
151     }
152 
153     /**
154      * {@inheritDoc}
155      */
156     @Override
setTestsDir(File testsDir, String version)157     public void setTestsDir(File testsDir, String version) {
158         mTestzipBuildInfo.setTestzipDir(testsDir, version);
159     }
160 
161     /**
162      * {@inheritDoc}
163      */
164     @Override
getBasebandImageFile()165     public File getBasebandImageFile() {
166         return mDeviceBuild.getBasebandImageFile();
167     }
168 
169     /**
170      * {@inheritDoc}
171      */
172     @Override
getBasebandVersion()173     public String getBasebandVersion() {
174         return mDeviceBuild.getBasebandVersion();
175     }
176 
177     /**
178      * {@inheritDoc}
179      */
180     @Override
setBasebandImage(File basebandFile, String version)181     public void setBasebandImage(File basebandFile, String version) {
182         mDeviceBuild.setBasebandImage(basebandFile, version);
183     }
184 
185     /**
186      * {@inheritDoc}
187      */
188     @Override
getBootloaderImageFile()189     public File getBootloaderImageFile() {
190         return mDeviceBuild.getBootloaderImageFile();
191     }
192 
193     /**
194      * {@inheritDoc}
195      */
196     @Override
getBootloaderVersion()197     public String getBootloaderVersion() {
198         return mDeviceBuild.getBootloaderVersion();
199     }
200 
201     /**
202      * {@inheritDoc}
203      */
204     @Override
setBootloaderImageFile(File bootloaderImgFile, String version)205     public void setBootloaderImageFile(File bootloaderImgFile, String version) {
206         mDeviceBuild.setBootloaderImageFile(bootloaderImgFile, version);
207     }
208 
209     /**
210      * {@inheritDoc}
211      */
212     @Override
getOtaPackageFile()213     public File getOtaPackageFile() {
214         return mDeviceBuild.getOtaPackageFile();
215     }
216 
217     /**
218      * {@inheritDoc}
219      */
220     @Override
getOtaPackageVersion()221     public String getOtaPackageVersion() {
222         return mDeviceBuild.getOtaPackageVersion();
223     }
224 
225     /**
226      * {@inheritDoc}
227      */
228     @Override
setOtaPackageFile(File otaFile, String version)229     public void setOtaPackageFile(File otaFile, String version) {
230         mDeviceBuild.setOtaPackageFile(otaFile, version);
231     }
232 
233     /**
234      * {@inheritDoc}
235      */
236     @Override
getMkbootimgFile()237     public File getMkbootimgFile() {
238         return mDeviceBuild.getMkbootimgFile();
239     }
240 
241     /**
242      * {@inheritDoc}
243      */
244     @Override
getMkbootimgVersion()245     public String getMkbootimgVersion() {
246         return mDeviceBuild.getMkbootimgVersion();
247     }
248 
249     /**
250      * {@inheritDoc}
251      */
252     @Override
setMkbootimgFile(File mkbootimg, String version)253     public void setMkbootimgFile(File mkbootimg, String version) {
254         mDeviceBuild.setMkbootimgFile(mkbootimg, version);
255     }
256 
257     /**
258      * {@inheritDoc}
259      */
260     @Override
getRamdiskFile()261     public File getRamdiskFile() {
262         return mDeviceBuild.getRamdiskFile();
263     }
264 
265     /**
266      * {@inheritDoc}
267      */
268     @Override
getRamdiskVersion()269     public String getRamdiskVersion() {
270         return mDeviceBuild.getRamdiskVersion();
271     }
272 
273     /**
274      * {@inheritDoc}
275      */
276     @Override
setRamdiskFile(File ramdisk, String version)277     public void setRamdiskFile(File ramdisk, String version) {
278         mDeviceBuild.setRamdiskFile(ramdisk, version);
279     }
280 
281     /**
282      * @param deviceBuild
283      */
setDeviceBuild(IDeviceBuildInfo deviceBuild)284     public void setDeviceBuild(IDeviceBuildInfo deviceBuild) {
285         mDeviceBuild = deviceBuild;
286     }
287 
288     /**
289      * {@inheritDoc}
290      */
291     @Override
cleanUp()292     public void cleanUp() {
293         if (mDeviceBuild != null) {
294             mDeviceBuild.cleanUp();
295         }
296 
297         if (mTestzipBuildInfo!= null) {
298             mTestzipBuildInfo.cleanUp();
299         }
300     }
301 
302     /**
303      * {@inheritDoc}
304      */
305     @Override
clone()306     public IBuildInfo clone() {
307         TestzipDeviceBuildInfo copy = new TestzipDeviceBuildInfo(getBuildId(), getBuildTargetName());
308         copy.addAllBuildAttributes(this);
309         IDeviceBuildInfo deviceBuildClone = (IDeviceBuildInfo) mDeviceBuild.clone();
310         copy.setDeviceBuild(deviceBuildClone);
311         ITestzipBuildInfo testzipBuildClone = (ITestzipBuildInfo) mTestzipBuildInfo.clone();
312         copy.setTestsDir(testzipBuildClone.getTestzipDir(), testzipBuildClone.getTestzipDirVersion());
313         return copy;
314     }
315 
316 }
317