1 /*
2  * Copyright (C) 2015 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.targetprep;
17 
18 import com.android.tradefed.build.IBuildInfo;
19 import com.android.tradefed.config.Option;
20 import com.android.tradefed.config.OptionClass;
21 import com.android.tradefed.targetprep.PushFilePreparer;
22 
23 import java.io.File;
24 
25 /** Pushes specified testing artifacts from Compatibility repository. */
26 @OptionClass(alias = "file-pusher")
27 public final class FilePusher extends PushFilePreparer {
28 
29     @Option(name = "append-bitness",
30             description = "Append the ABI's bitness to the filename.")
31     private boolean mAppendBitness = false;
32 
33     /**
34      * {@inheritDoc}
35      */
36     @Override
resolveRelativeFilePath(IBuildInfo buildInfo, String fileName)37     public File resolveRelativeFilePath(IBuildInfo buildInfo, String fileName) {
38         return super.resolveRelativeFilePath(
39                 buildInfo,
40                 String.format(
41                         "%s%s", fileName, shouldAppendBitness() ? getAbi().getBitness() : ""));
42     }
43 
44     /** Whether or not to append bitness to the file name. */
shouldAppendBitness()45     public boolean shouldAppendBitness() {
46         return mAppendBitness;
47     }
48 }
49