@@ -619,48 +619,58 @@ await Task.Run(() =>
619619 try
620620 {
621621 string message = "Please wait while setting up screen mirroring..." ;
622- commonProgress . UpdateStepLabel ( title , message , 10 ) ;
623622 try
624623 {
625624 MainScreen . udidScreenDensity [ udid ] = AndroidMethods . GetInstance ( ) . GetScreenDensity ( udid ) ;
626625 }
627626 catch ( Exception )
628627 {
629628 }
630- commonProgress . UpdateStepLabel ( title , message , 20 ) ;
631- AndroidMethods . GetInstance ( ) . UninstallOtherInstrumentationApps ( udid ) ;
632- commonProgress . UpdateStepLabel ( title , message , 30 ) ;
633- bool isUIAutomatorInstalled = AndroidMethods . GetInstance ( ) . isUIAutomatorInstalled ( udid , true , 10000 ) ;
634- Logger . Info ( "isUIAutomatorInstalled : " + isUIAutomatorInstalled ) ;
635- if ( ! isUIAutomatorInstalled )
636- {
637- commonProgress . UpdateStepLabel ( title , message , 40 ) ;
638- AndroidMethods . GetInstance ( ) . InstallUIAutomator ( udid ) ;
639- commonProgress . UpdateStepLabel ( title , message , 45 ) ;
640- }
641- commonProgress . UpdateStepLabel ( title , message , 50 ) ;
629+ commonProgress . UpdateStepLabel ( title , message , 5 ) ;
642630 proxyPort = AndroidMethods . GetInstance ( ) . GetForwardedPort ( udid , 6790 ) ;
643631 if ( proxyPort == - 1 )
644632 {
645- commonProgress . UpdateStepLabel ( title , message , 55 ) ;
633+ commonProgress . UpdateStepLabel ( title , message , 10 ) ;
646634 proxyPort = Common . GetFreePort ( 8221 , 8299 ) ;
647635 AndroidMethods . GetInstance ( ) . StartAndroidProxyServer ( proxyPort , 6790 , udid ) ;
648636 }
649- commonProgress . UpdateStepLabel ( title , message , 60 ) ;
650- bool isRunning = AndroidMethods . GetInstance ( ) . IsUIAutomatorRunning ( udid ) ;
651- if ( ! isRunning )
637+ screenServerPort = AndroidMethods . GetInstance ( ) . GetForwardedPort ( udid , 7810 ) ;
638+ if ( screenServerPort == - 1 )
652639 {
653- commonProgress . UpdateStepLabel ( title , message , 70 ) ;
654- AndroidAsyncMethods . GetInstance ( ) . StartUIAutomatorServer ( udid ) ;
655- Task . Delay ( 1000 ) ;
640+ commonProgress . UpdateStepLabel ( title , message , 15 ) ;
641+ screenServerPort = Common . GetFreePort ( 8221 , 8299 ) ;
642+ AndroidMethods . GetInstance ( ) . StartAndroidProxyServer ( screenServerPort , 7810 , udid ) ;
656643 }
657- commonProgress . UpdateStepLabel ( title , message , 80 ) ;
644+ commonProgress . UpdateStepLabel ( title , message , 20 ) ;
658645 UIAutomatorSessionId = AndroidAPIMethods . GetSessionID ( proxyPort ) ;
659646 if ( UIAutomatorSessionId . Equals ( "nosession" ) )
660647 {
661- commonProgress . UpdateStepLabel ( title , message , 90 ) ;
662- UIAutomatorSessionId = AndroidAPIMethods . CreateSession ( proxyPort ) ;
648+ commonProgress . UpdateStepLabel ( title , message , 30 ) ;
649+ bool isUIAutomatorInstalled = AndroidMethods . GetInstance ( ) . isUIAutomatorInstalled ( udid , true , 10000 ) ;
650+ Logger . Info ( "isUIAutomatorInstalled : " + isUIAutomatorInstalled ) ;
651+ if ( ! isUIAutomatorInstalled )
652+ {
653+ commonProgress . UpdateStepLabel ( title , message , 40 ) ;
654+ AndroidMethods . GetInstance ( ) . InstallUIAutomator ( udid ) ;
655+ commonProgress . UpdateStepLabel ( title , message , 50 ) ;
656+ }
657+ commonProgress . UpdateStepLabel ( title , message , 60 ) ;
658+ bool isRunning = AndroidMethods . GetInstance ( ) . IsUIAutomatorRunning ( udid ) ;
659+ if ( ! isRunning )
660+ {
661+ commonProgress . UpdateStepLabel ( title , message , 70 ) ;
662+ AndroidAsyncMethods . GetInstance ( ) . StartUIAutomatorServer ( udid ) ;
663+ Task . Delay ( 1000 ) ;
664+ }
665+ commonProgress . UpdateStepLabel ( title , message , 80 ) ;
666+ UIAutomatorSessionId = AndroidAPIMethods . GetSessionID ( proxyPort ) ;
667+ if ( UIAutomatorSessionId . Equals ( "nosession" ) )
668+ {
669+ UIAutomatorSessionId = AndroidAPIMethods . CreateSession ( proxyPort ) ;
670+ }
663671 }
672+ commonProgress . UpdateStepLabel ( title , message , 90 ) ;
673+
664674 }
665675 catch ( Exception e )
666676 {
0 commit comments