@@ -31,7 +31,7 @@ import {
31
31
import { W3C_WEB_ELEMENT_IDENTIFIER } from '@appium/support/build/lib/util' ;
32
32
import { androidPortForward , androidRemovePortForward } from './android' ;
33
33
import { iosPortForward , iosRemovePortForward } from './iOS' ;
34
- import { sleep } from 'asyncbox ' ;
34
+ import type { PortForwardCallback , PortReleaseCallback } from './types ' ;
35
35
36
36
export class AppiumFlutterDriver extends BaseDriver < FlutterDriverConstraints > {
37
37
// @ts -ignore
@@ -228,17 +228,25 @@ export class AppiumFlutterDriver extends BaseDriver<FlutterDriverConstraints> {
228
228
? this . proxydriver . opts . appPackage !
229
229
: this . proxydriver . opts . bundleId ! ;
230
230
231
- let portcallbacks = { } ;
231
+ const portcallbacks : {
232
+ portForwardCallback ?: PortForwardCallback ,
233
+ portReleaseCallback ?: PortReleaseCallback ,
234
+ } = { } ;
232
235
if ( this . proxydriver instanceof AndroidUiautomator2Driver ) {
233
- portcallbacks = {
234
- portForwardCallback : androidPortForward ,
235
- portReleaseCallback : androidRemovePortForward ,
236
- } ;
236
+ portcallbacks . portForwardCallback = async ( _ : string , systemPort : number , devicePort : number ) => await androidPortForward (
237
+ // @ts -ignore ADB instance is ok
238
+ ( this . proxydriver as AndroidUiautomator2Driver ) . adb ,
239
+ systemPort ,
240
+ devicePort
241
+ ) ;
242
+ portcallbacks . portReleaseCallback = async ( _ : string , systemPort : number ) => await androidRemovePortForward (
243
+ // @ts -ignore ADB instance is ok
244
+ ( this . proxydriver as AndroidUiautomator2Driver ) . adb ,
245
+ systemPort
246
+ ) ;
237
247
} else if ( this . proxydriver . isRealDevice ( ) ) {
238
- portcallbacks = {
239
- portForwardCallback : iosPortForward ,
240
- portReleaseCallback : iosRemovePortForward ,
241
- } ;
248
+ portcallbacks . portForwardCallback = iosPortForward ;
249
+ portcallbacks . portReleaseCallback = iosRemovePortForward ;
242
250
}
243
251
const flutterCaps : DriverCaps < FlutterDriverConstraints > = {
244
252
flutterServerLaunchTimeout : this . internalCaps . flutterServerLaunchTimeout || 5000 ,
0 commit comments