1 /* 2 * Copyright (C) 2012 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.tradefed.build; 17 18 import java.io.File; 19 import java.io.IOException; 20 21 /** 22 * A {@link IBuildInfo} that represents a kernel build. 23 */ 24 public class KernelBuildInfo extends BuildInfo implements IKernelBuildInfo { 25 private static final long serialVersionUID = BuildSerializedVersion.VERSION; 26 private final static String KERNEL_FILE = "kernel"; 27 28 private String mSha1 = null; 29 private String mShortSha1 = null; 30 private long mCommitTime = 0; 31 32 /** 33 * Creates a {@link KernelBuildInfo}. 34 */ 35 public KernelBuildInfo() { 36 super(); 37 } 38 39 /** 40 * Creates a {@link KernelBuildInfo}. 41 * 42 * @param sha1 the git sha1, used as the build id 43 * @param shortSha1 the git short sha1 44 * @param commitTime the git commit time 45 * @param buildName the build name 46 */ 47 public KernelBuildInfo(String sha1, String shortSha1, long commitTime, String buildName) { 48 super(sha1, buildName); 49 mSha1 = sha1; 50 mShortSha1 = shortSha1; 51 mCommitTime = commitTime; 52 } 53 54 /** 55 * {@inheritDoc} 56 */ 57 @Override 58 public File getKernelFile() { 59 return getFile(KERNEL_FILE); 60 } 61 62 /** 63 * {@inheritDoc} 64 */ 65 @Override 66 public String getKernelVersion() { 67 return getVersion(KERNEL_FILE); 68 } 69 70 /** 71 * {@inheritDoc} 72 */ 73 @Override 74 public void setKernelFile(File kernelFile, String version) { 75 setFile(KERNEL_FILE, kernelFile, version); 76 } 77 78 /** 79 * {@inheritDoc} 80 */ 81 @Override 82 public String getSha1() { 83 return mSha1; 84 } 85 86 /** 87 * {@inheritDoc} 88 */ 89 @Override 90 public void setSha1(String sha1) { 91 mSha1 = sha1; 92 } 93 94 /** 95 * {@inheritDoc} 96 */ 97 @Override 98 public String getShortSha1() { 99 return mShortSha1; 100 } 101 102 /** 103 * {@inheritDoc} 104 */ 105 @Override 106 public void setShortSha1(String shortSha1) { 107 mShortSha1 = shortSha1; 108 } 109 110 /** 111 * {@inheritDoc} 112 */ 113 @Override 114 public long getCommitTime() { 115 return mCommitTime; 116 } 117 118 /** 119 * {@inheritDoc} 120 */ 121 @Override 122 public void setCommitTime(long time) { 123 mCommitTime = time; 124 } 125 126 /** 127 * {@inheritDoc} 128 */ 129 @Override 130 public IBuildInfo clone() { 131 KernelBuildInfo copy = new KernelBuildInfo(getSha1(), getShortSha1(), 132 getCommitTime(), getBuildTargetName()); 133 copy.addAllBuildAttributes(this); 134 try { 135 copy.addAllFiles(this); 136 } catch (IOException e) { 137 throw new RuntimeException(e); 138 } 139 copy.setBuildBranch(getBuildBranch()); 140 copy.setBuildFlavor(getBuildFlavor()); 141 142 return copy; 143 } 144 } 145