33 filterGroupImages ,
44 getLocalArch ,
55 isExecExpectedResult ,
6+ params2Cmd ,
67 processKeyValueGroups ,
78 retry ,
89 spawnExec ,
@@ -184,19 +185,10 @@ class Android {
184185 */
185186 async start ( options : Required < Pick < EmulatorOptions , 'avd' > > & Omit < EmulatorOptions , 'avd' > ) {
186187 log ( 'start: %s' , JSON . stringify ( options ) ) ;
187- const opts = [ ] ;
188188 options . verbose = true ;
189- for ( const key in options ) {
190- const val = options [ key as keyof EmulatorOptions ] ;
191- const cliKey = '-' + key . replace ( / [ A - Z ] / g, ( matched ) => `-${ matched . toLocaleLowerCase ( ) } ` ) ;
192- if ( val === true ) {
193- opts . push ( cliKey ) ;
194- } else if ( val ) {
195- opts . push ( cliKey , val ) ;
196- }
197- }
189+ const cmd = params2Cmd ( options ) ;
198190 const res = await spawnWaitFor (
199- `${ this . emulatorBin } ${ opts . join ( ' ' ) } ` ,
191+ `${ this . emulatorBin } ${ cmd } ` ,
200192 / c o n t r o l c o n s o l e l i s t e n i n g o n p o r t ( \d + ) , A D B o n p o r t \d + /
201193 ) ;
202194 return {
@@ -211,7 +203,7 @@ class Android {
211203 */
212204 async waitForDevice ( emulatorId : string ) {
213205 log ( 'waitForDevice: %s' , JSON . stringify ( { emulatorId } ) ) ;
214- await this . adb ( emulatorId , 'wait-for-device' , 300000 ) ;
206+ await this . adb ( emulatorId , 'wait-for-device' ) ;
215207 }
216208
217209 /**
@@ -299,9 +291,10 @@ class Android {
299291 * @param emulatorId id of emulator
300292 * @param apkPath path of apk file
301293 */
302- async install ( emulatorId : string , apkPath : string ) {
294+ async install ( emulatorId : string , apkPath : string , options ?: Record < 'l' | 'r' | 't' | 's' | 'd' | 'g' , boolean > ) {
303295 log ( 'install: %s, %s' , JSON . stringify ( { emulatorId, apkPath } ) ) ;
304- const process = await this . adb ( emulatorId , `install ${ apkPath } ` ) ;
296+ const cmdParams = params2Cmd ( options ) ;
297+ const process = await this . adb ( emulatorId , `install ${ cmdParams } ${ apkPath } ` ) ;
305298 if ( process . output . match ( / S u c c e s s / ) ) return ;
306299 throw new Error ( 'Could not parse output of adb command' ) ;
307300 }
0 commit comments