@@ -207,32 +207,31 @@ export class IOSUsbLiveSyncService implements IiOSUsbLiveSyncService {
207
207
let timeout = 9000 ;
208
208
this . $iOSSocketRequestExecutor . executeAttachRequest ( this . device , timeout ) . wait ( ) ;
209
209
let socket = this . device . connectToPort ( IOSUsbLiveSyncService . BACKEND_PORT ) ;
210
- this . sendReloadMessage ( socket ) ;
210
+ this . sendPageReloadMessage ( socket ) ;
211
211
} ) . future < void > ( ) ( ) ;
212
212
}
213
213
214
214
public sendPageReloadMessageToSimulator ( ) : IFuture < void > {
215
- helpers . connectEventually ( ( ) => net . connect ( IOSUsbLiveSyncService . BACKEND_PORT ) , ( socket : net . Socket ) => this . sendReloadMessage ( socket ) ) ;
215
+ helpers . connectEventually ( ( ) => net . connect ( IOSUsbLiveSyncService . BACKEND_PORT ) , ( socket : net . Socket ) => this . sendPageReloadMessage ( socket ) ) ;
216
216
return this . $iOSEmulatorServices . postDarwinNotification ( this . $iOSNotification . attachRequest ) ;
217
217
}
218
218
219
- private sendReloadMessage ( socket : net . Socket ) : void {
219
+ private sendPageReloadMessage ( socket : net . Socket ) : void {
220
220
try {
221
- this . sendReloadMessageCore ( socket ) ;
221
+ this . sendPageReloadMessageCore ( socket ) ;
222
222
} finally {
223
223
socket . destroy ( ) ;
224
224
}
225
225
}
226
226
227
- private sendReloadMessageCore ( socket : net . Socket ) : void {
227
+ private sendPageReloadMessageCore ( socket : net . Socket ) : void {
228
228
let message = `{ "method":"Page.reload","params":{"ignoreCache":false},"id":${ ++ currentPageReloadId } }` ;
229
229
let length = Buffer . byteLength ( message , "utf16le" ) ;
230
230
let payload = new Buffer ( length + 4 ) ;
231
231
payload . writeInt32BE ( length , 0 ) ;
232
232
payload . write ( message , 4 , length , "utf16le" ) ;
233
233
socket . write ( payload ) ;
234
234
}
235
-
236
235
}
237
236
$injector . register ( "iosUsbLiveSyncServiceLocator" , { factory : IOSUsbLiveSyncService } ) ;
238
237
@@ -248,8 +247,7 @@ export class AndroidUsbLiveSyncService extends androidLiveSyncServiceLib.Android
248
247
249
248
public restartApplication ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] ) : IFuture < void > {
250
249
return ( ( ) => {
251
- this . device . adb . executeShellCommand ( [ "chmod" , "777" , deviceAppData . deviceProjectRootPath ] ) . wait ( ) ;
252
- this . device . adb . executeShellCommand ( [ "chmod" , "777" , `/data/local/tmp/${ deviceAppData . appIdentifier } ` ] ) . wait ( ) ;
250
+ this . device . adb . executeShellCommand ( [ "chmod" , "777" , deviceAppData . deviceProjectRootPath , `/data/local/tmp/${ deviceAppData . appIdentifier } ` ] ) . wait ( ) ;
253
251
254
252
if ( this . $options . companion ) {
255
253
let commands = [ this . liveSyncCommands . SyncFilesCommand ( ) ] ;
@@ -267,21 +265,35 @@ export class AndroidUsbLiveSyncService extends androidLiveSyncServiceLib.Android
267
265
public beforeLiveSyncAction ( deviceAppData : Mobile . IDeviceAppData ) : IFuture < void > {
268
266
return ( ( ) => {
269
267
let deviceRootPath = `/data/local/tmp/${ deviceAppData . appIdentifier } ` ;
270
- this . device . adb . executeShellCommand ( [ "rm" , "-rf" , this . $mobileHelper . buildDevicePath ( deviceRootPath , "fullsync" ) ] ) . wait ( ) ;
271
- this . device . adb . executeShellCommand ( [ "rm" , "-rf" , this . $mobileHelper . buildDevicePath ( deviceRootPath , "sync" ) ] ) . wait ( ) ;
272
- this . device . adb . executeShellCommand ( [ "rm" , "-rf" , this . $mobileHelper . buildDevicePath ( deviceRootPath , "removedsync" ) ] ) . wait ( ) ;
268
+ this . device . adb . executeShellCommand ( [ "rm" , "-rf" , this . $mobileHelper . buildDevicePath ( deviceRootPath , "fullsync" ) ,
269
+ this . $mobileHelper . buildDevicePath ( deviceRootPath , "sync" ) ,
270
+ this . $mobileHelper . buildDevicePath ( deviceRootPath , "removedsync" ) ] ) . wait ( ) ;
273
271
} ) . future < void > ( ) ( ) ;
274
272
}
275
273
276
274
public sendPageReloadMessageToDevice ( deviceAppData : Mobile . IDeviceAppData ) : IFuture < void > {
277
275
return ( ( ) => {
278
- let socket = new net . Socket ( ) ;
279
- socket . connect ( AndroidUsbLiveSyncService . BACKEND_PORT , '127.0.0.1' , ( ) => {
280
- socket . write ( new Buffer ( [ 0 , 0 , 0 , 1 , 1 ] ) ) ;
281
- socket . destroy ( ) ;
282
- } ) ;
283
276
this . device . adb . executeCommand ( [ "forward" , `tcp:${ AndroidUsbLiveSyncService . BACKEND_PORT . toString ( ) } ` , `localabstract:${ deviceAppData . appIdentifier } -livesync` ] ) . wait ( ) ;
277
+ this . sendPageReloadMessage ( ) . wait ( ) ;
284
278
} ) . future < void > ( ) ( ) ;
285
279
}
280
+
281
+ private sendPageReloadMessage ( ) : IFuture < void > {
282
+ let future = new Future < void > ( ) ;
283
+
284
+ let socket = new net . Socket ( ) ;
285
+ socket . connect ( AndroidUsbLiveSyncService . BACKEND_PORT , '127.0.0.1' , ( ) => {
286
+ try {
287
+ socket . write ( new Buffer ( [ 0 , 0 , 0 , 1 , 1 ] ) ) ;
288
+ future . return ( ) ;
289
+ } catch ( e ) {
290
+ future . throw ( e ) ;
291
+ } finally {
292
+ socket . destroy ( ) ;
293
+ }
294
+ } ) ;
295
+
296
+ return future ;
297
+ }
286
298
}
287
299
$injector . register ( "androidUsbLiveSyncServiceLocator" , { factory : AndroidUsbLiveSyncService } ) ;
0 commit comments