Skip to content

Commit ccd8217

Browse files
authored
Revert "Implement a fix for SemanticsHandles bug on Android (#1395)" (#1397)
This reverts commit 868cef3.
1 parent 868cef3 commit ccd8217

40 files changed

+2160
-2561
lines changed

contracts.proto

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ message RunDartTestResponse {
3838
}
3939

4040
service NativeAutomator {
41-
rpc initialize(Empty) returns (Empty) {}
4241
rpc configure(ConfigureRequest) returns (Empty) {}
4342

4443
// general

packages/patrol/android/src/main/kotlin/pl/leancode/patrol/Automator.kt

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package pl.leancode.patrol
22

3-
import android.app.Instrumentation
43
import android.app.UiAutomation
5-
import android.content.Context
64
import android.os.SystemClock
75
import android.widget.EditText
86
import androidx.test.platform.app.InstrumentationRegistry
@@ -52,25 +50,15 @@ private fun fromUiObject2(obj: UiObject2): Contracts.NativeView {
5250
class Automator private constructor() {
5351
private var timeoutMillis: Long = 10_000
5452

55-
private lateinit var instrumentation: Instrumentation
56-
private lateinit var configurator: Configurator
57-
private lateinit var uiDevice: UiDevice
58-
private lateinit var targetContext: Context
59-
60-
fun initialize() {
61-
instrumentation = InstrumentationRegistry.getInstrumentation()
62-
targetContext = instrumentation.targetContext
63-
configurator = Configurator.getInstance()
64-
uiDevice = UiDevice.getInstance(instrumentation)
65-
}
66-
6753
fun configure(waitForSelectorTimeout: Long) {
54+
val configurator = Configurator.getInstance()
55+
6856
timeoutMillis = waitForSelectorTimeout
6957
configurator.waitForSelectorTimeout = waitForSelectorTimeout
7058
configurator.waitForIdleTimeout = 5000
7159
configurator.keyInjectionDelay = 50
7260

73-
configurator.uiAutomationFlags = UiAutomation.FLAG_DONT_SUPPRESS_ACCESSIBILITY_SERVICES
61+
Configurator.getInstance().uiAutomationFlags = UiAutomation.FLAG_DONT_SUPPRESS_ACCESSIBILITY_SERVICES
7462

7563
Logger.i("Timeout: $timeoutMillis ms")
7664
Logger.i("Android UiAutomator configuration:")
@@ -83,6 +71,12 @@ class Automator private constructor() {
8371
Logger.i("\tuiAutomationFlags: ${configurator.uiAutomationFlags}")
8472
}
8573

74+
private val instrumentation get() = InstrumentationRegistry.getInstrumentation()
75+
76+
private val uiDevice get() = UiDevice.getInstance(instrumentation)
77+
78+
private val targetContext get() = instrumentation.targetContext
79+
8680
private fun executeShellCommand(cmd: String) {
8781
uiDevice.executeShellCommand(cmd)
8882
delay()

packages/patrol/android/src/main/kotlin/pl/leancode/patrol/AutomatorServer.kt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@ import pl.leancode.patrol.contracts.permissionDialogVisibleResponse
1717
typealias Empty = Contracts.Empty
1818

1919
class AutomatorServer(private val automation: Automator) : NativeAutomatorGrpcKt.NativeAutomatorCoroutineImplBase() {
20-
21-
override suspend fun initialize(request: Empty): Empty {
22-
automation.initialize()
23-
return empty { }
24-
}
25-
2620
override suspend fun configure(request: Contracts.ConfigureRequest): Empty {
2721
automation.configure(waitForSelectorTimeout = request.findTimeoutMillis)
2822
return empty { }
@@ -58,7 +52,7 @@ class AutomatorServer(private val automation: Automator) : NativeAutomatorGrpcKt
5852
return empty { }
5953
}
6054

61-
override suspend fun closeNotifications(request: Empty): Empty {
55+
override suspend fun closeNotifications(request: Contracts.Empty): Contracts.Empty {
6256
automation.closeNotifications()
6357
return empty { }
6458
}
@@ -208,7 +202,7 @@ class AutomatorServer(private val automation: Automator) : NativeAutomatorGrpcKt
208202
return empty { }
209203
}
210204

211-
override suspend fun markPatrolAppServiceReady(request: Empty): Empty {
205+
override suspend fun markPatrolAppServiceReady(request: Contracts.Empty): Contracts.Empty {
212206
PatrolServer.appReady.set(true)
213207
return empty { }
214208
}

packages/patrol/android/src/main/kotlin/pl/leancode/patrol/contracts/ConfigureRequestKt.kt

Lines changed: 2 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)