@@ -96,21 +96,21 @@ class AndroidDebugService implements IDebugService {
96
96
97
97
private printDebugPort ( packageName : string ) : IFuture < void > {
98
98
return ( ( ) => {
99
- let res = this . $childProcess . spawnFromEvent ( this . $staticConfig . getAdbFilePath ( ) . wait ( ) , [ "shell" , " am", "broadcast" , "-a" , packageName + "-GetDgbPort" ] , "exit" ) . wait ( ) ;
100
- this . $logger . info ( res . stdout ) ;
99
+ let res = this . device . adb . executeShellCommand ( [ " am", "broadcast" , "-a" , packageName + "-GetDgbPort" ] ) . wait ( ) ;
100
+ this . $logger . info ( res ) ;
101
101
} ) . future < void > ( ) ( ) ;
102
102
}
103
103
104
104
private attachDebugger ( packageName : string ) : void {
105
- let startDebuggerCommand = `am broadcast -a \"${ packageName } -Debug\" --ez enable true` ;
105
+ let startDebuggerCommand = [ "am" , " broadcast" , "-a" , ' \"${packageName}-Debug\"' , " --ez" , " enable" , " true" ] ;
106
106
let port = this . $options . debugPort ;
107
107
108
108
if ( port > 0 ) {
109
- startDebuggerCommand += " --ei debuggerPort " + port ;
109
+ startDebuggerCommand . push ( " --ei" , " debuggerPort" , port . toString ( ) ) ;
110
110
this . device . adb . executeShellCommand ( startDebuggerCommand ) . wait ( ) ;
111
111
} else {
112
- let res = this . $childProcess . spawnFromEvent ( this . $staticConfig . getAdbFilePath ( ) . wait ( ) , [ "shell" , " am", "broadcast" , "-a" , packageName + "-Debug" , "--ez" , "enable" , "true" ] , "exit" ) . wait ( ) ;
113
- let match = res . stdout . match ( / r e s u l t = ( \d ) + / ) ;
112
+ let res = this . device . adb . executeShellCommand ( [ " am", "broadcast" , "-a" , packageName + "-Debug" , "--ez" , "enable" , "true" ] ) . wait ( ) ;
113
+ let match = res . match ( / r e s u l t = ( \d ) + / ) ;
114
114
if ( match ) {
115
115
port = match [ 0 ] . substring ( 7 ) ;
116
116
} else {
@@ -127,7 +127,7 @@ class AndroidDebugService implements IDebugService {
127
127
}
128
128
129
129
private detachDebugger ( packageName : string ) : IFuture < void > {
130
- return this . device . adb . executeShellCommand ( this . device . deviceInfo . identifier , `shell am broadcast -a \" ${ packageName } -Debug\" --ez enable false` ) ;
130
+ return this . device . adb . executeShellCommand ( [ "am" , " broadcast" , "-a" , ` ${ packageName } -Debug` , " --ez" , " enable" , " false" ] ) ;
131
131
}
132
132
133
133
private startAppWithDebugger ( packageFile : string , packageName : string ) : IFuture < void > {
@@ -142,11 +142,11 @@ class AndroidDebugService implements IDebugService {
142
142
let packageDir = util . format ( AndroidDebugService . PACKAGE_EXTERNAL_DIR_TEMPLATE , packageName ) ;
143
143
let envDebugOutFullpath = this . $mobileHelper . buildDevicePath ( packageDir , AndroidDebugService . ENV_DEBUG_OUT_FILENAME ) ;
144
144
145
- this . device . adb . executeShellCommand ( `rm " ${ envDebugOutFullpath } "` ) . wait ( ) ;
146
- this . device . adb . executeShellCommand ( ` mkdir -p " ${ packageDir } "` ) . wait ( ) ;
145
+ this . device . adb . executeShellCommand ( [ "rm" , ` ${ envDebugOutFullpath } ` ] ) . wait ( ) ;
146
+ this . device . adb . executeShellCommand ( [ " mkdir" , "-p" , ` ${ packageDir } ` ] ) . wait ( ) ;
147
147
148
148
let debugBreakPath = this . $mobileHelper . buildDevicePath ( packageDir , "debugbreak" ) ;
149
- this . device . adb . executeShellCommand ( `" cat /dev/null > ${ debugBreakPath } "` ) . wait ( ) ;
149
+ this . device . adb . executeShellCommand ( [ ` cat /dev/null > ${ debugBreakPath } ` ] ) . wait ( ) ;
150
150
151
151
this . device . applicationManager . startApplication ( packageName ) . wait ( ) ;
152
152
@@ -160,7 +160,7 @@ class AndroidDebugService implements IDebugService {
160
160
}
161
161
162
162
private tcpForward ( src : Number , dest : Number ) : IFuture < void > {
163
- return this . device . adb . executeCommand ( ` forward tcp:${ src . toString ( ) } tcp:${ dest . toString ( ) } `) ;
163
+ return this . device . adb . executeCommand ( [ " forward" , ` tcp:${ src . toString ( ) } ` , ` tcp:${ dest . toString ( ) } `] ) ;
164
164
}
165
165
166
166
private startDebuggerClient ( port : Number ) : IFuture < void > {
@@ -190,9 +190,8 @@ class AndroidDebugService implements IDebugService {
190
190
191
191
private checkIfFileExists ( filename : string ) : IFuture < boolean > {
192
192
return ( ( ) => {
193
- let args = [ "shell" , "test" , "-f" , filename , "&&" , "echo 'yes'" , "||" , "echo 'no'" ] ;
194
- let res = this . $childProcess . spawnFromEvent ( this . $staticConfig . getAdbFilePath ( ) . wait ( ) , args , "exit" ) . wait ( ) ;
195
- let exists = res . stdout . indexOf ( 'yes' ) > - 1 ;
193
+ let res = this . device . adb . executeShellCommand ( [ `test -f ${ filename } && echo 'yes' || echo 'no'` ] ) . wait ( ) ;
194
+ let exists = res . indexOf ( 'yes' ) > - 1 ;
196
195
return exists ;
197
196
} ) . future < boolean > ( ) ( ) ;
198
197
}
@@ -204,7 +203,7 @@ class AndroidDebugService implements IDebugService {
204
203
205
204
let packageDir = util . format ( AndroidDebugService . PACKAGE_EXTERNAL_DIR_TEMPLATE , packageName ) ;
206
205
let envDebugInFullpath = packageDir + AndroidDebugService . ENV_DEBUG_IN_FILENAME ;
207
- this . device . adb . executeShellCommand ( `rm " ${ envDebugInFullpath } "` ) . wait ( ) ;
206
+ this . device . adb . executeShellCommand ( [ "rm" , ` ${ envDebugInFullpath } ` ] ) . wait ( ) ;
208
207
209
208
let isRunning = false ;
210
209
for ( let i = 0 ; i < timeout ; i ++ ) {
@@ -215,15 +214,15 @@ class AndroidDebugService implements IDebugService {
215
214
}
216
215
217
216
if ( isRunning ) {
218
- this . device . adb . executeShellCommand ( `" cat /dev/null > ${ envDebugInFullpath } "` ) . wait ( ) ;
217
+ this . device . adb . executeShellCommand ( [ ` cat /dev/null > ${ envDebugInFullpath } ` ] ) . wait ( ) ;
219
218
220
219
for ( let i = 0 ; i < timeout ; i ++ ) {
221
220
helpers . sleep ( 1000 /* ms */ ) ;
222
221
let envDebugOutFullpath = packageDir + AndroidDebugService . ENV_DEBUG_OUT_FILENAME ;
223
222
let exists = this . checkIfFileExists ( envDebugOutFullpath ) . wait ( ) ;
224
223
if ( exists ) {
225
- let res = this . $childProcess . spawnFromEvent ( this . $staticConfig . getAdbFilePath ( ) . wait ( ) , [ "shell" , " cat", envDebugOutFullpath ] , "exit" ) . wait ( ) ;
226
- let match = res . stdout . match ( / P O R T = ( \d ) + / ) ;
224
+ let res = this . device . adb . executeShellCommand ( [ " cat", envDebugOutFullpath ] ) . wait ( ) ;
225
+ let match = res . match ( / P O R T = ( \d ) + / ) ;
227
226
if ( match ) {
228
227
port = parseInt ( match [ 0 ] . substring ( 5 ) , 10 ) ;
229
228
break ;
0 commit comments