File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ declare module '@devicefarmer/adbkit' {
3939 root ( id : string ) : Promise < true > ;
4040 on ( type : 'error' , handler : ( error : Error ) => void ) : void ;
4141 reverse ( id : string , remote : string , local : string ) : Promise < true > ;
42+ connect ( host : string , port ?: number ) : Promise < void > ;
4243 }
4344
4445 export function createClient ( options ?: {
Original file line number Diff line number Diff line change @@ -20,6 +20,18 @@ export function createAdbClient() {
2020 : 'adb'
2121 } ) ;
2222
23+ if ( process . platform === 'win32' ) {
24+ // If ADB is connected (=if list works) then we try to connect to 58526 automatically
25+ // (but asychronously) at start up. This is the local debug port for Windows
26+ // Subsystem for Android:
27+ // https://learn.microsoft.com/en-us/windows/android/wsa/#connect-to-the-windows-subsystem-for-android-for-debugging
28+
29+ client . listDevices ( )
30+ . then ( ( ) => client . connect ( '127.0.0.1' , 58526 ) )
31+ . then ( ( ) => console . log ( 'Connected to WSA via ADB' ) )
32+ . catch ( ( ) => { } ) ; // Just best-efforts, so we ignore any failures here
33+ }
34+
2335 // We listen for errors and report them. This only happens if adbkit completely
2436 // fails to handle or listen to a connection error. We'd rather report that than crash.
2537 client . on ( 'error' , reportError ) ;
You can’t perform that action at this time.
0 commit comments