1 /* 2 * Copyright (C) 2020 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.compatibility.targetprep; 18 19 import com.android.tradefed.build.IBuildInfo; 20 import com.android.tradefed.config.Option; 21 import com.android.tradefed.device.ITestDevice; 22 import com.android.tradefed.targetprep.ITargetPreparer; 23 24 import com.google.common.annotations.VisibleForTesting; 25 26 import java.io.File; 27 28 /** 29 * A Tradefed preparer that receives module preparer options and stores the values in IBuildInfo. 30 */ 31 public final class AppSetupPreparerConfigurationReceiver implements ITargetPreparer { 32 33 @Option( 34 name = AppSetupPreparer.OPTION_GCS_APK_DIR, 35 description = "GCS path where the test apk files are located.") 36 private File mOptionGcsApkDir; 37 AppSetupPreparerConfigurationReceiver()38 public AppSetupPreparerConfigurationReceiver() { 39 this(null); 40 } 41 42 @VisibleForTesting AppSetupPreparerConfigurationReceiver(File optionGcsApkDir)43 public AppSetupPreparerConfigurationReceiver(File optionGcsApkDir) { 44 mOptionGcsApkDir = optionGcsApkDir; 45 } 46 47 /** {@inheritDoc} */ 48 @Override setUp(ITestDevice device, IBuildInfo buildInfo)49 public void setUp(ITestDevice device, IBuildInfo buildInfo) { 50 if (mOptionGcsApkDir == null) { 51 return; 52 } 53 buildInfo.addBuildAttribute( 54 AppSetupPreparer.OPTION_GCS_APK_DIR, mOptionGcsApkDir.getPath()); 55 } 56 } 57