Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Commit

Permalink
Add configurable ADB commands timeout. Fixes #7. (#8)
Browse files Browse the repository at this point in the history
* Add configurable ADB commands timeout. Fixes #7.

* Reduce default ADB install timeout from 5 to 2 minutes.
  • Loading branch information
koral-- authored and yunikkk committed Nov 6, 2017
1 parent 4fea273 commit 4068958
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions android/src/main/kotlin/com/gojuno/commander/android/Adb.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.gojuno.commander.os.process
import rx.Observable
import rx.Single
import java.io.File
import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeUnit.MINUTES
import java.util.concurrent.TimeUnit.SECONDS

Expand Down Expand Up @@ -53,12 +54,12 @@ fun connectedAdbDevices(): Observable<Set<AdbDevice>> = process(listOf(adb, "dev

fun AdbDevice.log(message: String) = com.gojuno.commander.os.log("[$id] $message")

fun AdbDevice.installApk(pathToApk: String): Observable<Unit> {
fun AdbDevice.installApk(pathToApk: String, timeout: Pair<Int, TimeUnit> = 2 to MINUTES): Observable<Unit> {
val adbDevice = this
val installApk = process(
commandAndArgs = listOf(adb, "-s", adbDevice.id, "install", "-r", pathToApk),
unbufferedOutput = true,
timeout = 5 to MINUTES
timeout = timeout
)

return Observable
Expand Down Expand Up @@ -90,11 +91,11 @@ fun AdbDevice.installApk(pathToApk: String): Observable<Unit> {
.doOnError { adbDevice.log("Error during installing apk: $it, pathToApk = $pathToApk") }
}

fun AdbDevice.pullFolder(folderOnDevice: String, folderOnHostMachine: File, logErrors: Boolean): Single<Boolean> {
fun AdbDevice.pullFolder(folderOnDevice: String, folderOnHostMachine: File, logErrors: Boolean, timeout: Pair<Int, TimeUnit> = 60 to SECONDS): Single<Boolean> {
val adbDevice = this
val pullFiles = process(
commandAndArgs = listOf(adb, "-s", adbDevice.id, "pull", folderOnDevice, folderOnHostMachine.absolutePath),
timeout = 60 to SECONDS,
timeout = timeout,
unbufferedOutput = true
)

Expand Down

0 comments on commit 4068958

Please sign in to comment.