Skip to content

Commit

Permalink
Version 2.0.69-alpha
Browse files Browse the repository at this point in the history
- Fix UiObject references to UiObject2
  • Loading branch information
dtmilano committed Jan 14, 2024
1 parent 352b6fb commit 4ce1987
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 14 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ android {
applicationId "com.dtmilano.android.culebratester2"
minSdk 26
targetSdk 33
versionCode 20068
versionName "2.0.68-alpha"
versionCode 20069
versionName "2.0.69-alpha"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.dtmilano.android.culebratester2.location

import io.ktor.locations.KtorExperimentalLocationsAPI
import io.ktor.locations.Location
import io.swagger.server.models.StatusResponse
import org.apache.commons.io.IOUtils
import java.util.concurrent.TimeUnit

/**
* See https://github.com/ktorio/ktor/issues/1660 for the reason why we need the extra parameter
* in nested classes:
*
* "One of the problematic features is nested location classes and nested location objects.
*
* What we are thinking of to change:
*
* a nested location class should always have a property of the outer class or object
* nested objects in objects are not allowed
* The motivation for the first point is the fact that a location class nested to another, makes no
* sense without the ability to refer to the outer class."
*/
@KtorExperimentalLocationsAPI
@Location("/am")
class Am {

@Location("/forceStop")
class ForceStop(
private val pkg: String,
private val parent: Am = Am()) {
fun response(): io.swagger.server.models.StatusResponse {
val command = listOf("am", "force-stop", pkg)
println("Executing $command")
val pb = ProcessBuilder(command)
val p = pb.start()
val stdOut = IOUtils.toString(p.inputStream, Charsets.UTF_8)
val stdErr = IOUtils.toString(p.errorStream, Charsets.UTF_8)
val exitStatus = p.waitFor(30, TimeUnit.SECONDS)
println("$command: exit status: $exitStatus")
return if (exitStatus) {
StatusResponse(StatusResponse.Status.OK)
} else {
StatusResponse(StatusResponse.Status.ERROR, errorMessage = stdErr)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import io.swagger.server.models.StringResponse
import java.math.BigDecimal
import javax.inject.Inject

private const val TAG = "UiObject2"
private const val TAG = "UiObject"

/**
* See https://github.com/ktorio/ktor/issues/1660 for the reason why we need the extra parameter
Expand Down Expand Up @@ -158,7 +158,7 @@ class UiObject {
@Location("/{oid}/exists")
/*inner*/ class Exists(
val oid: Int,
private val parent: UiObject2 = UiObject2()
private val parent: UiObject = UiObject()
) {
private var holder: Holder

Expand All @@ -184,7 +184,7 @@ class UiObject {
@Location("/{oid}/getBounds")
/*inner*/ class GetBounds(
val oid: Int,
private val parent: UiObject2 = UiObject2()
private val parent: UiObject = UiObject()
) {
private var holder: Holder

Expand Down Expand Up @@ -212,7 +212,7 @@ class UiObject {
/*inner*/ class GetChild(
val oid: Int,
private val uiSelector: String? = null,
private val parent: UiObject2 = UiObject2()
private val parent: UiObject = UiObject()
) {
private var holder: Holder

Expand Down Expand Up @@ -247,7 +247,7 @@ class UiObject {
@Location("/{oid}/getChildCount")
/*inner*/ class GetChildCount(
val oid: Int,
private val parent: UiObject2 = UiObject2()
private val parent: UiObject = UiObject()
) {
private var holder: Holder

Expand All @@ -273,7 +273,7 @@ class UiObject {
@Location("/{oid}/getClassName")
/*inner*/ class GetClassName(
val oid: Int,
private val parent: UiObject2 = UiObject2()
private val parent: UiObject = UiObject()
) {
private var holder: Holder

Expand All @@ -300,7 +300,7 @@ class UiObject {
@Location("/{oid}/getContentDescription")
/*inner*/ class GetContentDescription(
val oid: Int,
private val parent: UiObject2 = UiObject2()
private val parent: UiObject = UiObject()
) {
private var holder: Holder

Expand Down Expand Up @@ -368,7 +368,7 @@ class UiObject {
val oid: Int,
private val percentage: Int,
private val steps: Int,
private val parent: UiObject2 = UiObject2()
private val parent: UiObject = UiObject()
) {
private var holder: Holder

Expand Down Expand Up @@ -399,7 +399,7 @@ class UiObject {
val oid: Int,
private val percentage: Int,
private val steps: Int,
private val parent: UiObject2 = UiObject2()
private val parent: UiObject = UiObject()
) {
private var holder: Holder

Expand Down Expand Up @@ -429,7 +429,7 @@ class UiObject {
/*inner*/ class WaitForExists(
val oid: Int,
private val timeout: Long,
private val parent: UiObject2 = UiObject2()
private val parent: UiObject = UiObject()
) {
private var holder: Holder

Expand Down Expand Up @@ -474,4 +474,4 @@ class UiObject {
return HttpException(HttpStatusCode.NotFound, "⚠️ UiObject matching $bsb not found")
}
}
}
}
2 changes: 1 addition & 1 deletion openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ info:
- the server should have been started using `./culebratester2 start-server`
then you will be able to invoke the API and see the responses.
version: 2.0.68
version: 2.0.69
servers:
- url: http://localhost:9987/v2
paths:
Expand Down

0 comments on commit 4ce1987

Please sign in to comment.