@@ -31,7 +31,7 @@ import {
3131import { W3C_WEB_ELEMENT_IDENTIFIER } from '@appium/support/build/lib/util' ;
3232import { androidPortForward , androidRemovePortForward } from './android' ;
3333import { iosPortForward , iosRemovePortForward } from './iOS' ;
34- import { sleep } from 'asyncbox ' ;
34+ import type { PortForwardCallback , PortReleaseCallback } from './types ' ;
3535
3636export class AppiumFlutterDriver extends BaseDriver < FlutterDriverConstraints > {
3737 // @ts -ignore
@@ -228,17 +228,25 @@ export class AppiumFlutterDriver extends BaseDriver<FlutterDriverConstraints> {
228228 ? this . proxydriver . opts . appPackage !
229229 : this . proxydriver . opts . bundleId ! ;
230230
231- let portcallbacks = { } ;
231+ const portcallbacks : {
232+ portForwardCallback ?: PortForwardCallback ,
233+ portReleaseCallback ?: PortReleaseCallback ,
234+ } = { } ;
232235 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+ ) ;
237247 } else if ( this . proxydriver . isRealDevice ( ) ) {
238- portcallbacks = {
239- portForwardCallback : iosPortForward ,
240- portReleaseCallback : iosRemovePortForward ,
241- } ;
248+ portcallbacks . portForwardCallback = iosPortForward ;
249+ portcallbacks . portReleaseCallback = iosRemovePortForward ;
242250 }
243251 const flutterCaps : DriverCaps < FlutterDriverConstraints > = {
244252 flutterServerLaunchTimeout : this . internalCaps . flutterServerLaunchTimeout || 5000 ,
0 commit comments