@@ -69,7 +69,9 @@ class AndroidLiveSyncService implements IDeviceLiveSyncService {
6969 private reloadPage ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] ) : IFuture < void > {
7070 return ( ( ) => {
7171 this . device . adb . executeCommand ( [ "forward" , `tcp:${ AndroidLiveSyncService . BACKEND_PORT . toString ( ) } ` , `localabstract:${ deviceAppData . appIdentifier } -livesync` ] ) . wait ( ) ;
72- this . sendPageReloadMessage ( ) . wait ( ) ;
72+ if ( ! this . sendPageReloadMessage ( ) . wait ( ) ) {
73+ this . restartApplication ( deviceAppData ) . wait ( ) ;
74+ }
7375 } ) . future < void > ( ) ( ) ;
7476 }
7577
@@ -97,15 +99,25 @@ class AndroidLiveSyncService implements IDeviceLiveSyncService {
9799 return `/data/local/tmp/${ appIdentifier } ` ;
98100 }
99101
100- private sendPageReloadMessage ( ) : IFuture < void > {
101- let future = new Future < void > ( ) ;
102+ private sendPageReloadMessage ( ) : IFuture < boolean > {
103+ let future = new Future < boolean > ( ) ;
102104 let socket = new net . Socket ( ) ;
103105 socket . connect ( AndroidLiveSyncService . BACKEND_PORT , '127.0.0.1' , ( ) => {
104106 socket . write ( new Buffer ( [ 0 , 0 , 0 , 1 , 1 ] ) ) ;
105107 } ) ;
106108 socket . on ( "data" , ( data : any ) => {
107109 socket . destroy ( ) ;
108- future . return ( ) ;
110+ future . return ( true ) ;
111+ } ) ;
112+ socket . on ( "error" , ( ) => {
113+ if ( ! future . isResolved ( ) ) {
114+ future . return ( false ) ;
115+ }
116+ } ) ;
117+ socket . on ( "close" , ( ) => {
118+ if ( ! future . isResolved ( ) ) {
119+ future . return ( false ) ;
120+ }
109121 } ) ;
110122 return future ;
111123 }
0 commit comments