@@ -53,7 +53,9 @@ export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncSer
5353 this . $projectDataService . initialize ( this . $projectData . projectDir ) ;
5454 let frameworkVersion = this . $projectDataService . getValue ( platformData . frameworkPackageName ) . wait ( ) . version ;
5555 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 ( ) ;
5759 if ( shouldUpdate ) {
5860 this . $platformService . updatePlatforms ( [ this . $devicePlatformsConstants . Android . toLowerCase ( ) ] ) . wait ( ) ;
5961 } else {
@@ -114,7 +116,6 @@ export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncSer
114116 let localProjectRootPath = platform . toLowerCase ( ) === "ios" ? platformData . appDestinationDirectoryPath : null ;
115117
116118 let fastLivesyncFileExtensions = [ ".css" , ".xml" ] ;
117- let canExecuteFastLiveSync = ( filePath : string ) => _ . contains ( fastLivesyncFileExtensions , path . extname ( filePath ) ) ;
118119
119120 let fastLiveSync = ( filePath : string ) => {
120121 this . $dispatcher . dispatch ( ( ) => {
@@ -155,7 +156,7 @@ export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncSer
155156 beforeLiveSyncAction : beforeLiveSyncAction ,
156157 beforeBatchLiveSyncAction : beforeBatchLiveSyncAction ,
157158 iOSSimulatorRelativeToProjectBasePathAction : iOSSimulatorRelativeToProjectBasePathAction ,
158- canExecuteFastLiveSync : canExecuteFastLiveSync ,
159+ canExecuteFastLiveSync : ( filePath : string ) => _ . contains ( fastLivesyncFileExtensions , path . extname ( filePath ) ) ,
159160 fastLiveSync : fastLiveSync
160161 } ;
161162
@@ -189,10 +190,7 @@ export class IOSUsbLiveSyncService implements IiOSUsbLiveSyncService {
189190 private $iOSSocketRequestExecutor : IiOSSocketRequestExecutor ,
190191 private $iOSNotification : IiOSNotification ,
191192 private $iOSEmulatorServices : Mobile . IiOSSimulatorService ,
192- private $injector : IInjector ,
193- private $iOSNotificationService : IiOSNotificationService ,
194- private $errors : IErrors ,
195- private $projectData : IProjectData ) { }
193+ private $injector : IInjector ) { }
196194
197195 private get device ( ) : Mobile . IiOSDevice {
198196 return < Mobile . IiOSDevice > this . _device ;
@@ -207,32 +205,31 @@ export class IOSUsbLiveSyncService implements IiOSUsbLiveSyncService {
207205 let timeout = 9000 ;
208206 this . $iOSSocketRequestExecutor . executeAttachRequest ( this . device , timeout ) . wait ( ) ;
209207 let socket = this . device . connectToPort ( IOSUsbLiveSyncService . BACKEND_PORT ) ;
210- this . sendReloadMessage ( socket ) ;
208+ this . sendPageReloadMessage ( socket ) ;
211209 } ) . future < void > ( ) ( ) ;
212210 }
213211
214212 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 ) ) ;
216214 return this . $iOSEmulatorServices . postDarwinNotification ( this . $iOSNotification . attachRequest ) ;
217215 }
218216
219- private sendReloadMessage ( socket : net . Socket ) : void {
217+ private sendPageReloadMessage ( socket : net . Socket ) : void {
220218 try {
221- this . sendReloadMessageCore ( socket ) ;
219+ this . sendPageReloadMessageCore ( socket ) ;
222220 } finally {
223221 socket . destroy ( ) ;
224222 }
225223 }
226224
227- private sendReloadMessageCore ( socket : net . Socket ) : void {
225+ private sendPageReloadMessageCore ( socket : net . Socket ) : void {
228226 let message = `{ "method":"Page.reload","params":{"ignoreCache":false},"id":${ ++ currentPageReloadId } }` ;
229227 let length = Buffer . byteLength ( message , "utf16le" ) ;
230228 let payload = new Buffer ( length + 4 ) ;
231229 payload . writeInt32BE ( length , 0 ) ;
232230 payload . write ( message , 4 , length , "utf16le" ) ;
233231 socket . write ( payload ) ;
234232 }
235-
236233}
237234$injector . register ( "iosUsbLiveSyncServiceLocator" , { factory : IOSUsbLiveSyncService } ) ;
238235
@@ -248,8 +245,7 @@ export class AndroidUsbLiveSyncService extends androidLiveSyncServiceLib.Android
248245
249246 public restartApplication ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] ) : IFuture < void > {
250247 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 ( ) ;
253249
254250 if ( this . $options . companion ) {
255251 let commands = [ this . liveSyncCommands . SyncFilesCommand ( ) ] ;
@@ -267,21 +263,35 @@ export class AndroidUsbLiveSyncService extends androidLiveSyncServiceLib.Android
267263 public beforeLiveSyncAction ( deviceAppData : Mobile . IDeviceAppData ) : IFuture < void > {
268264 return ( ( ) => {
269265 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 ( ) ;
273269 } ) . future < void > ( ) ( ) ;
274270 }
275271
276272 public sendPageReloadMessageToDevice ( deviceAppData : Mobile . IDeviceAppData ) : IFuture < void > {
277273 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- } ) ;
283274 this . device . adb . executeCommand ( [ "forward" , `tcp:${ AndroidUsbLiveSyncService . BACKEND_PORT . toString ( ) } ` , `localabstract:${ deviceAppData . appIdentifier } -livesync` ] ) . wait ( ) ;
275+ this . sendPageReloadMessage ( ) . wait ( ) ;
284276 } ) . future < void > ( ) ( ) ;
285277 }
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+ }
286296}
287297$injector . register ( "androidUsbLiveSyncServiceLocator" , { factory : AndroidUsbLiveSyncService } ) ;
0 commit comments