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' {
39
39
root ( id : string ) : Promise < true > ;
40
40
on ( type : 'error' , handler : ( error : Error ) => void ) : void ;
41
41
reverse ( id : string , remote : string , local : string ) : Promise < true > ;
42
+ connect ( host : string , port ?: number ) : Promise < void > ;
42
43
}
43
44
44
45
export function createClient ( options ?: {
Original file line number Diff line number Diff line change @@ -20,6 +20,18 @@ export function createAdbClient() {
20
20
: 'adb'
21
21
} ) ;
22
22
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
+
23
35
// We listen for errors and report them. This only happens if adbkit completely
24
36
// fails to handle or listen to a connection error. We'd rather report that than crash.
25
37
client . on ( 'error' , reportError ) ;
You can’t perform that action at this time.
0 commit comments