Skip to content

Commit 81fb3bd

Browse files
DeviceInfracopybara-github
authored andcommitted
Internal change
PiperOrigin-RevId: 702740393
1 parent a590c38 commit 81fb3bd

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/java/com/google/devtools/mobileharness/platform/android/sdktool/adb/AndroidAdbUtil.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,18 @@ public String content(UtilArgs utilArgs, AndroidContent contentArgs)
381381
return content(utilArgs, contentArgs, DEFAULT_COMMAND_TIMEOUT);
382382
}
383383

384+
/** Function for restart adb server. This is only for virtual device managed by Mobile Harness. */
385+
public void restartAdbServer() throws MobileHarnessException, InterruptedException {
386+
try {
387+
androidAdbInternalUtil.killAdbServer();
388+
// Start the ADB server if it is not already running
389+
var unused = androidAdbInternalUtil.listDevices(Duration.ofSeconds(10));
390+
} catch (MobileHarnessException e) {
391+
throw new MobileHarnessException(
392+
AndroidErrorId.ANDROID_ADB_UTIL_CMD_ERROR, e.getMessage(), e);
393+
}
394+
}
395+
384396
/**
385397
* Function for "adb shell content". By default without --user specified, command run as {@code
386398
* USER_SYSTEM}. See Android source code for content command:

0 commit comments

Comments
 (0)