@@ -53,7 +53,9 @@ export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncSer
53
53
this . $projectDataService . initialize ( this . $projectData . projectDir ) ;
54
54
let frameworkVersion = this . $projectDataService . getValue ( platformData . frameworkPackageName ) . wait ( ) . version ;
55
55
if ( semver . lt ( frameworkVersion , "1.2.1" ) ) {
56
- let shouldUpdate = this . $prompter . confirm ( " You need Android Runtime 1.2.1 or later for LiveSync to work properly. Do you want to update your runtime now?" ) . wait ( ) ;
56
+ let shouldUpdate = this . $prompter . confirm (
57
+ "You need Android Runtime 1.2.1 or later for LiveSync to work properly. Do you want to update your runtime now?"
58
+ ) . wait ( ) ;
57
59
if ( shouldUpdate ) {
58
60
this . $platformService . updatePlatforms ( [ this . $devicePlatformsConstants . Android . toLowerCase ( ) ] ) . wait ( ) ;
59
61
} else {
@@ -114,7 +116,6 @@ export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncSer
114
116
let localProjectRootPath = platform . toLowerCase ( ) === "ios" ? platformData . appDestinationDirectoryPath : null ;
115
117
116
118
let fastLivesyncFileExtensions = [ ".css" , ".xml" ] ;
117
- let canExecuteFastLiveSync = ( filePath : string ) => _ . contains ( fastLivesyncFileExtensions , path . extname ( filePath ) ) ;
118
119
119
120
let fastLiveSync = ( filePath : string ) => {
120
121
this . $dispatcher . dispatch ( ( ) => {
@@ -155,7 +156,7 @@ export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncSer
155
156
beforeLiveSyncAction : beforeLiveSyncAction ,
156
157
beforeBatchLiveSyncAction : beforeBatchLiveSyncAction ,
157
158
iOSSimulatorRelativeToProjectBasePathAction : iOSSimulatorRelativeToProjectBasePathAction ,
158
- canExecuteFastLiveSync : canExecuteFastLiveSync ,
159
+ canExecuteFastLiveSync : ( filePath : string ) => _ . contains ( fastLivesyncFileExtensions , path . extname ( filePath ) ) ,
159
160
fastLiveSync : fastLiveSync
160
161
} ;
161
162
@@ -189,10 +190,7 @@ export class IOSUsbLiveSyncService implements IiOSUsbLiveSyncService {
189
190
private $iOSSocketRequestExecutor : IiOSSocketRequestExecutor ,
190
191
private $iOSNotification : IiOSNotification ,
191
192
private $iOSEmulatorServices : Mobile . IiOSSimulatorService ,
192
- private $injector : IInjector ,
193
- private $iOSNotificationService : IiOSNotificationService ,
194
- private $errors : IErrors ,
195
- private $projectData : IProjectData ) { }
193
+ private $injector : IInjector ) { }
196
194
197
195
private get device ( ) : Mobile . IiOSDevice {
198
196
return < Mobile . IiOSDevice > this . _device ;
@@ -207,32 +205,31 @@ export class IOSUsbLiveSyncService implements IiOSUsbLiveSyncService {
207
205
let timeout = 9000 ;
208
206
this . $iOSSocketRequestExecutor . executeAttachRequest ( this . device , timeout ) . wait ( ) ;
209
207
let socket = this . device . connectToPort ( IOSUsbLiveSyncService . BACKEND_PORT ) ;
210
- this . sendReloadMessage ( socket ) ;
208
+ this . sendPageReloadMessage ( socket ) ;
211
209
} ) . future < void > ( ) ( ) ;
212
210
}
213
211
214
212
public sendPageReloadMessageToSimulator ( ) : IFuture < void > {
215
- helpers . connectEventually ( ( ) => net . connect ( IOSUsbLiveSyncService . BACKEND_PORT ) , ( socket : net . Socket ) => this . sendReloadMessage ( socket ) ) ;
213
+ helpers . connectEventually ( ( ) => net . connect ( IOSUsbLiveSyncService . BACKEND_PORT ) , ( socket : net . Socket ) => this . sendPageReloadMessage ( socket ) ) ;
216
214
return this . $iOSEmulatorServices . postDarwinNotification ( this . $iOSNotification . attachRequest ) ;
217
215
}
218
216
219
- private sendReloadMessage ( socket : net . Socket ) : void {
217
+ private sendPageReloadMessage ( socket : net . Socket ) : void {
220
218
try {
221
- this . sendReloadMessageCore ( socket ) ;
219
+ this . sendPageReloadMessageCore ( socket ) ;
222
220
} finally {
223
221
socket . destroy ( ) ;
224
222
}
225
223
}
226
224
227
- private sendReloadMessageCore ( socket : net . Socket ) : void {
225
+ private sendPageReloadMessageCore ( socket : net . Socket ) : void {
228
226
let message = `{ "method":"Page.reload","params":{"ignoreCache":false},"id":${ ++ currentPageReloadId } }` ;
229
227
let length = Buffer . byteLength ( message , "utf16le" ) ;
230
228
let payload = new Buffer ( length + 4 ) ;
231
229
payload . writeInt32BE ( length , 0 ) ;
232
230
payload . write ( message , 4 , length , "utf16le" ) ;
233
231
socket . write ( payload ) ;
234
232
}
235
-
236
233
}
237
234
$injector . register ( "iosUsbLiveSyncServiceLocator" , { factory : IOSUsbLiveSyncService } ) ;
238
235
@@ -248,8 +245,7 @@ export class AndroidUsbLiveSyncService extends androidLiveSyncServiceLib.Android
248
245
249
246
public restartApplication ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] ) : IFuture < void > {
250
247
return ( ( ) => {
251
- this . device . adb . executeShellCommand ( [ "chmod" , "777" , deviceAppData . deviceProjectRootPath ] ) . wait ( ) ;
252
- this . device . adb . executeShellCommand ( [ "chmod" , "777" , `/data/local/tmp/${ deviceAppData . appIdentifier } ` ] ) . wait ( ) ;
248
+ this . device . adb . executeShellCommand ( [ "chmod" , "777" , deviceAppData . deviceProjectRootPath , `/data/local/tmp/${ deviceAppData . appIdentifier } ` ] ) . wait ( ) ;
253
249
254
250
if ( this . $options . companion ) {
255
251
let commands = [ this . liveSyncCommands . SyncFilesCommand ( ) ] ;
@@ -267,21 +263,35 @@ export class AndroidUsbLiveSyncService extends androidLiveSyncServiceLib.Android
267
263
public beforeLiveSyncAction ( deviceAppData : Mobile . IDeviceAppData ) : IFuture < void > {
268
264
return ( ( ) => {
269
265
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 ( ) ;
266
+ this . device . adb . executeShellCommand ( [ "rm" , "-rf" , this . $mobileHelper . buildDevicePath ( deviceRootPath , "fullsync" ) ,
267
+ this . $mobileHelper . buildDevicePath ( deviceRootPath , "sync" ) ,
268
+ this . $mobileHelper . buildDevicePath ( deviceRootPath , "removedsync" ) ] ) . wait ( ) ;
273
269
} ) . future < void > ( ) ( ) ;
274
270
}
275
271
276
272
public sendPageReloadMessageToDevice ( deviceAppData : Mobile . IDeviceAppData ) : IFuture < void > {
277
273
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
274
this . device . adb . executeCommand ( [ "forward" , `tcp:${ AndroidUsbLiveSyncService . BACKEND_PORT . toString ( ) } ` , `localabstract:${ deviceAppData . appIdentifier } -livesync` ] ) . wait ( ) ;
275
+ this . sendPageReloadMessage ( ) . wait ( ) ;
284
276
} ) . future < void > ( ) ( ) ;
285
277
}
278
+
279
+ private sendPageReloadMessage ( ) : IFuture < void > {
280
+ let future = new Future < void > ( ) ;
281
+
282
+ let socket = new net . Socket ( ) ;
283
+ socket . connect ( AndroidUsbLiveSyncService . BACKEND_PORT , '127.0.0.1' , ( ) => {
284
+ try {
285
+ socket . write ( new Buffer ( [ 0 , 0 , 0 , 1 , 1 ] ) ) ;
286
+ future . return ( ) ;
287
+ } catch ( e ) {
288
+ future . throw ( e ) ;
289
+ } finally {
290
+ socket . destroy ( ) ;
291
+ }
292
+ } ) ;
293
+
294
+ return future ;
295
+ }
286
296
}
287
297
$injector . register ( "androidUsbLiveSyncServiceLocator" , { factory : AndroidUsbLiveSyncService } ) ;
0 commit comments