@@ -40,6 +40,7 @@ export interface Backend {
4040
4141export interface DeviceBackend {
4242 serial : string ;
43+ status : string ;
4344 close ( ) : Promise < void > ;
4445 init ( ) : Promise < void > ;
4546 runCommand ( command : string ) : Promise < string > ;
@@ -65,7 +66,7 @@ export class Android {
6566 }
6667
6768 async devices ( ) : Promise < AndroidDevice [ ] > {
68- const devices = await this . _backend . devices ( ) ;
69+ const devices = ( await this . _backend . devices ( ) ) . filter ( d => d . status === 'device' ) ;
6970 return await Promise . all ( devices . map ( d => AndroidDevice . create ( this , d ) ) ) ;
7071 }
7172}
@@ -117,7 +118,9 @@ export class AndroidDevice extends EventEmitter {
117118 }
118119
119120 async shell ( command : string ) : Promise < string > {
120- return await this . _backend . runCommand ( `shell:${ command } ` ) ;
121+ const result = await this . _backend . runCommand ( `shell:${ command } ` ) ;
122+ await this . _refreshWebViews ( ) ;
123+ return result ;
121124 }
122125
123126 private async _driver ( ) : Promise < Transport > {
@@ -245,7 +248,7 @@ export class AndroidDevice extends EventEmitter {
245248 const browser = await CRBrowser . connect ( androidBrowser , browserOptions ) ;
246249 const controller = new ProgressController ( ) ;
247250 await controller . run ( async progress => {
248- await browser . _defaultContext ! . _loadDefaultContext ( progress ) ;
251+ await browser . _defaultContext ! . _loadDefaultContextAsIs ( progress ) ;
249252 } ) ;
250253 return browser . _defaultContext ! ;
251254 }
@@ -278,7 +281,7 @@ export class AndroidDevice extends EventEmitter {
278281 const p = match [ 1 ] ;
279282 if ( + p !== pid )
280283 continue ;
281- pkg = proc . substring ( proc . lastIndexOf ( ' ' ) ) ;
284+ pkg = proc . substring ( proc . lastIndexOf ( ' ' ) + 1 ) ;
282285 }
283286 const webView = { pid, pkg } ;
284287 this . _webViews . set ( pid , webView ) ;
0 commit comments