@@ -96,21 +96,21 @@ class AndroidDebugService implements IDebugService {
9696
9797 private printDebugPort ( packageName : string ) : IFuture < void > {
9898 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 ) ;
101101 } ) . future < void > ( ) ( ) ;
102102 }
103103
104104 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" ] ;
106106 let port = this . $options . debugPort ;
107107
108108 if ( port > 0 ) {
109- startDebuggerCommand += " --ei debuggerPort " + port ;
109+ startDebuggerCommand . push ( " --ei" , " debuggerPort" , port . toString ( ) ) ;
110110 this . device . adb . executeShellCommand ( startDebuggerCommand ) . wait ( ) ;
111111 } 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 ) + / ) ;
114114 if ( match ) {
115115 port = match [ 0 ] . substring ( 7 ) ;
116116 } else {
@@ -127,7 +127,7 @@ class AndroidDebugService implements IDebugService {
127127 }
128128
129129 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" ] ) ;
131131 }
132132
133133 private startAppWithDebugger ( packageFile : string , packageName : string ) : IFuture < void > {
@@ -142,11 +142,11 @@ class AndroidDebugService implements IDebugService {
142142 let packageDir = util . format ( AndroidDebugService . PACKAGE_EXTERNAL_DIR_TEMPLATE , packageName ) ;
143143 let envDebugOutFullpath = this . $mobileHelper . buildDevicePath ( packageDir , AndroidDebugService . ENV_DEBUG_OUT_FILENAME ) ;
144144
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 ( ) ;
147147
148148 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 ( ) ;
150150
151151 this . device . applicationManager . startApplication ( packageName ) . wait ( ) ;
152152
@@ -160,7 +160,7 @@ class AndroidDebugService implements IDebugService {
160160 }
161161
162162 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 ( ) } `] ) ;
164164 }
165165
166166 private startDebuggerClient ( port : Number ) : IFuture < void > {
@@ -190,9 +190,8 @@ class AndroidDebugService implements IDebugService {
190190
191191 private checkIfFileExists ( filename : string ) : IFuture < boolean > {
192192 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 ;
196195 return exists ;
197196 } ) . future < boolean > ( ) ( ) ;
198197 }
@@ -204,7 +203,7 @@ class AndroidDebugService implements IDebugService {
204203
205204 let packageDir = util . format ( AndroidDebugService . PACKAGE_EXTERNAL_DIR_TEMPLATE , packageName ) ;
206205 let envDebugInFullpath = packageDir + AndroidDebugService . ENV_DEBUG_IN_FILENAME ;
207- this . device . adb . executeShellCommand ( `rm " ${ envDebugInFullpath } "` ) . wait ( ) ;
206+ this . device . adb . executeShellCommand ( [ "rm" , ` ${ envDebugInFullpath } ` ] ) . wait ( ) ;
208207
209208 let isRunning = false ;
210209 for ( let i = 0 ; i < timeout ; i ++ ) {
@@ -215,15 +214,15 @@ class AndroidDebugService implements IDebugService {
215214 }
216215
217216 if ( isRunning ) {
218- this . device . adb . executeShellCommand ( `" cat /dev/null > ${ envDebugInFullpath } "` ) . wait ( ) ;
217+ this . device . adb . executeShellCommand ( [ ` cat /dev/null > ${ envDebugInFullpath } ` ] ) . wait ( ) ;
219218
220219 for ( let i = 0 ; i < timeout ; i ++ ) {
221220 helpers . sleep ( 1000 /* ms */ ) ;
222221 let envDebugOutFullpath = packageDir + AndroidDebugService . ENV_DEBUG_OUT_FILENAME ;
223222 let exists = this . checkIfFileExists ( envDebugOutFullpath ) . wait ( ) ;
224223 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 ) + / ) ;
227226 if ( match ) {
228227 port = parseInt ( match [ 0 ] . substring ( 5 ) , 10 ) ;
229228 break ;
0 commit comments