diff options
author | Yuchao Zhou <superzhou@google.com> | 2016-04-01 09:10:40 -0700 |
---|---|---|
committer | Yuchao Zhou <superzhou@google.com> | 2016-04-07 13:54:38 -0700 |
commit | 347da2c537c447664ef6400f367d096c73ddfcbc (patch) | |
tree | cb963e6a3c0a0166cb0625a112411960262d4fe2 /src/com/android/tradefed/targetprep | |
parent | bb91c6b9689adae548fc8231944880c418d18970 (diff) | |
download | tradefederation-347da2c537c447664ef6400f367d096c73ddfcbc.tar.gz |
Adding a new preparer to initialize attenuator
When a test running with RF attenuator is hit by exception,
host system upgrade, Tradefed Upgrade, power otage etc.
The attenuator setting will be in unknown state.
This preparer can make sure attenuator value is reset before the
test start, epsecially before the pairing between phone and watch
started. By defailtm this preparer is disable, user need to enable
it in command file and pass in the ipaddess list for all the
attenuators in the physical setup.
Change-Id: Id0d4a6bd75c1d0ea885fc14d05fab2aae51a180b
Diffstat (limited to 'src/com/android/tradefed/targetprep')
-rw-r--r-- | src/com/android/tradefed/targetprep/AttenuatorPreparer.java | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/com/android/tradefed/targetprep/AttenuatorPreparer.java b/src/com/android/tradefed/targetprep/AttenuatorPreparer.java new file mode 100644 index 000000000..6027d9fc0 --- /dev/null +++ b/src/com/android/tradefed/targetprep/AttenuatorPreparer.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.tradefed.targetprep; + +import com.android.tradefed.build.IBuildInfo; +import com.android.tradefed.config.Option; +import com.android.tradefed.config.OptionClass; +import com.android.tradefed.device.DeviceNotAvailableException; +import com.android.tradefed.device.ITestDevice; +import com.android.tradefed.log.LogUtil.CLog; +import com.android.tradefed.util.AttenuatorUtil; +import com.android.tradefed.util.RunUtil; + +import java.util.ArrayList; +import java.util.List; + +@OptionClass(alias = "attenuator") +public class AttenuatorPreparer implements ITargetPreparer { + @Option(name = "attenuator-value", description = "Initial value for the attenuator") + private int initValue = 0; + + @Option(name = "disable", description = "Disable this preparer") + private boolean mDisable = true; + + @Option(name = "attenuator-ip", description = "IP address for attenuators") + private List<String> mIpAddresses = new ArrayList<String>(); + + /** + * {@inheritDoc} + */ + @Override + public void setUp(ITestDevice device, IBuildInfo buildInfo) throws TargetSetupError, + DeviceNotAvailableException { + if (mDisable) + return; + for (String ipAddress : mIpAddresses) { + CLog.v("Initialize attenuator %s to %d at setup", mIpAddresses, initValue); + AttenuatorUtil att = new AttenuatorUtil(ipAddress); + att.setValue(initValue); + } + } +} + |