@@ -69,7 +69,9 @@ class AndroidLiveSyncService implements IDeviceLiveSyncService {
69
69
private reloadPage ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] ) : IFuture < void > {
70
70
return ( ( ) => {
71
71
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
+ }
73
75
} ) . future < void > ( ) ( ) ;
74
76
}
75
77
@@ -97,15 +99,25 @@ class AndroidLiveSyncService implements IDeviceLiveSyncService {
97
99
return `/data/local/tmp/${ appIdentifier } ` ;
98
100
}
99
101
100
- private sendPageReloadMessage ( ) : IFuture < void > {
101
- let future = new Future < void > ( ) ;
102
+ private sendPageReloadMessage ( ) : IFuture < boolean > {
103
+ let future = new Future < boolean > ( ) ;
102
104
let socket = new net . Socket ( ) ;
103
105
socket . connect ( AndroidLiveSyncService . BACKEND_PORT , '127.0.0.1' , ( ) => {
104
106
socket . write ( new Buffer ( [ 0 , 0 , 0 , 1 , 1 ] ) ) ;
105
107
} ) ;
106
108
socket . on ( "data" , ( data : any ) => {
107
109
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
+ }
109
121
} ) ;
110
122
return future ;
111
123
}
0 commit comments