diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-06-11 15:52:15 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-06-11 15:52:15 +0000 |
commit | 551e74d59a0addfa60f0a8e6d396bcd9bdef449b (patch) | |
tree | f264df50590f77c449e824681d5f9626e9364ea4 | |
parent | a3da6f9ef3a94bb7a47b9ffd381a07b6ee0e4c85 (diff) | |
parent | dc227dfc89cada0e6d4d74d8956e8cd1b61c8531 (diff) | |
download | hal-android13-frc-neuralnetworks-release.tar.gz |
Snap for 8712302 from dc227dfc89cada0e6d4d74d8956e8cd1b61c8531 to tm-frc-neuralnetworks-releaset_frc_neu_330443030t_frc_neu_330443000android13-frc-neuralnetworks-release
Change-Id: I42314c0a86951ed4962abc047161d18ad309c117
-rw-r--r-- | usb/usb/aidl/host/src/com/android/usb/vts/VtsAidlUsbHostTest.java | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/usb/usb/aidl/host/src/com/android/usb/vts/VtsAidlUsbHostTest.java b/usb/usb/aidl/host/src/com/android/usb/vts/VtsAidlUsbHostTest.java index 1a2e0b3f..d62ff6c2 100644 --- a/usb/usb/aidl/host/src/com/android/usb/vts/VtsAidlUsbHostTest.java +++ b/usb/usb/aidl/host/src/com/android/usb/vts/VtsAidlUsbHostTest.java @@ -19,9 +19,14 @@ package com.android.tests.usbport; import com.android.tradefed.device.DeviceNotAvailableException; import com.android.tradefed.device.ITestDevice; import com.android.tradefed.log.LogUtil.CLog; +import com.android.tradefed.invoker.TestInformation; import com.android.tradefed.testtype.DeviceJUnit4ClassRunner; import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test; +import com.android.tradefed.testtype.junit4.BeforeClassWithInfo; +import com.google.common.base.Strings; +import java.util.Arrays; +import java.util.HashSet; import java.util.concurrent.atomic.AtomicBoolean; import org.junit.Assert; @@ -34,8 +39,11 @@ import org.junit.runner.RunWith; public final class VtsAidlUsbHostTest extends BaseHostJUnit4Test { public static final String TAG = VtsAidlUsbHostTest.class.getSimpleName(); + private static final String HAL_SERVICE = "android.hardware.usb-service"; private static final long CONN_TIMEOUT = 5000; + private static boolean mHasService; + private ITestDevice mDevice; private AtomicBoolean mReconnected = new AtomicBoolean(false); @@ -44,13 +52,26 @@ public final class VtsAidlUsbHostTest extends BaseHostJUnit4Test { mDevice = getDevice(); } + @BeforeClassWithInfo + public static void beforeClassWithDevice(TestInformation testInfo) throws Exception { + String serviceFound = + testInfo.getDevice() + .executeShellCommand(String.format("ps -A | grep \"%s\"", HAL_SERVICE)) + .trim(); + mHasService = !Strings.isNullOrEmpty(serviceFound); + } + @Test public void testResetUsbPort() throws Exception { + Assume.assumeTrue( + String.format("The device doesn't have service %s", HAL_SERVICE), mHasService); Assert.assertNotNull("Target device does not exist", mDevice); - String portResult; - + String portResult, content; String deviceSerialNumber = mDevice.getSerialNumber(); + HashSet<String> noSupportCases = + new HashSet<>(Arrays.asList("No USB ports", + "There is no available reset USB port")); CLog.i("testResetUsbPort on device [%s]", deviceSerialNumber); @@ -74,8 +95,9 @@ public final class VtsAidlUsbHostTest extends BaseHostJUnit4Test { CLog.i("Invoke shell command [" + cmd + "]"); long startTime = System.currentTimeMillis(); portResult = mDevice.executeShellCommand(cmd); + content = portResult.trim(); - if (portResult != null && "No USB ports".equals(portResult.trim())) { + if (portResult != null && (noSupportCases.contains(content))) { CLog.i("portResult: %s", portResult); return; } |