summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicky Niu <rickyniu@google.com>2022-06-06 11:57:46 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-06-06 11:57:46 +0000
commita66a1658a3ff50f03f8d96f4f987bd9d8eb1bab6 (patch)
treef264df50590f77c449e824681d5f9626e9364ea4
parent231b7ede27550998a3890354b32ea405ca94dfbf (diff)
parentb209eb9bd3b23be46505941b6d8f7dfa93d922f9 (diff)
downloadhal-android13-qpr2-s6-release.tar.gz
Original change: https://googleplex-android-review.googlesource.com/c/platform/test/vts-testcase/hal/+/18696350 Change-Id: I3167cd8ce3bebcb93c8ffae6c00640fd44fd9ccb Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--usb/usb/aidl/host/src/com/android/usb/vts/VtsAidlUsbHostTest.java28
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;
}