@@ -25,7 +25,6 @@ class LiveSyncServiceBase implements ILiveSyncServiceBase {
25
25
private $projectFilesProvider : IProjectFilesProvider ,
26
26
private $liveSyncProvider : ILiveSyncProvider ,
27
27
private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
28
- private $hostInfo : IHostInfo ,
29
28
private $dispatcher : IFutureDispatcher ) {
30
29
this . fileHashes = Object . create ( null ) ;
31
30
}
@@ -176,53 +175,45 @@ class LiveSyncServiceBase implements ILiveSyncServiceBase {
176
175
return ( ( ) => {
177
176
let shouldRefreshApplication = true ;
178
177
let deviceAppData = this . $deviceAppDataFactory . create ( appIdentifier , this . $mobileHelper . normalizePlatformName ( platform ) , device , liveSyncOptions ) ;
179
- if ( deviceAppData . isLiveSyncSupported ( ) . wait ( ) ) {
180
- let platformLiveSyncService = this . resolvePlatformLiveSyncService ( platform , device ) ;
178
+ let platformLiveSyncService = this . resolvePlatformLiveSyncService ( platform , device ) ;
181
179
182
- if ( platformLiveSyncService . beforeLiveSyncAction ) {
183
- platformLiveSyncService . beforeLiveSyncAction ( deviceAppData ) . wait ( ) ;
184
- }
180
+ if ( platformLiveSyncService . beforeLiveSyncAction ) {
181
+ platformLiveSyncService . beforeLiveSyncAction ( deviceAppData ) . wait ( ) ;
182
+ }
185
183
186
- // Not installed application
187
- device . applicationManager . checkForApplicationUpdates ( ) . wait ( ) ;
184
+ // Not installed application
185
+ device . applicationManager . checkForApplicationUpdates ( ) . wait ( ) ;
188
186
189
- let wasInstalled = true ;
190
- if ( ! device . applicationManager . isApplicationInstalled ( appIdentifier ) . wait ( ) && ! this . $options . companion ) {
191
- this . $logger . warn ( `The application with id "${ appIdentifier } " is not installed on device with identifier ${ device . deviceInfo . identifier } .` ) ;
192
- if ( ! packageFilePath ) {
193
- packageFilePath = this . $liveSyncProvider . buildForDevice ( device ) . wait ( ) ;
194
- }
195
- device . applicationManager . installApplication ( packageFilePath ) . wait ( ) ;
187
+ let wasInstalled = true ;
188
+ if ( ! device . applicationManager . isApplicationInstalled ( appIdentifier ) . wait ( ) ) {
189
+ this . $logger . warn ( `The application with id "${ appIdentifier } " is not installed on device with identifier ${ device . deviceInfo . identifier } .` ) ;
190
+ if ( ! packageFilePath ) {
191
+ packageFilePath = this . $liveSyncProvider . buildForDevice ( device ) . wait ( ) ;
192
+ }
193
+ device . applicationManager . installApplication ( packageFilePath ) . wait ( ) ;
196
194
197
- if ( platformLiveSyncService . afterInstallApplicationAction ) {
198
- let localToDevicePaths = this . $projectFilesManager . createLocalToDevicePaths ( deviceAppData , projectFilesPath , filesToSync , data . excludedProjectDirsAndFiles , liveSyncOptions ) ;
199
- shouldRefreshApplication = platformLiveSyncService . afterInstallApplicationAction ( deviceAppData , localToDevicePaths ) . wait ( ) ;
200
- } else {
201
- shouldRefreshApplication = false ;
202
- }
195
+ let localToDevicePaths = this . $projectFilesManager . createLocalToDevicePaths ( deviceAppData , projectFilesPath , filesToSync , data . excludedProjectDirsAndFiles , liveSyncOptions ) ;
196
+ shouldRefreshApplication = platformLiveSyncService . afterInstallApplicationAction ( deviceAppData , localToDevicePaths ) . wait ( ) ;
203
197
204
- if ( device . applicationManager . canStartApplication ( ) && ! shouldRefreshApplication ) {
205
- device . applicationManager . startApplication ( appIdentifier ) . wait ( ) ;
206
- }
207
- wasInstalled = false ;
198
+ if ( device . applicationManager . canStartApplication ( ) && ! shouldRefreshApplication ) {
199
+ device . applicationManager . startApplication ( appIdentifier ) . wait ( ) ;
208
200
}
201
+ wasInstalled = false ;
202
+ }
209
203
210
- // Restart application or reload page
211
- if ( shouldRefreshApplication ) {
212
- // Transfer or remove files on device
213
- let localToDevicePaths = this . $projectFilesManager . createLocalToDevicePaths ( deviceAppData , projectFilesPath , filesToSync , data . excludedProjectDirsAndFiles , liveSyncOptions ) ;
214
- if ( deviceFilesAction ) {
215
- deviceFilesAction ( device , localToDevicePaths ) . wait ( ) ;
216
- } else {
217
- this . transferFiles ( deviceAppData , localToDevicePaths , projectFilesPath , ! filesToSync ) . wait ( ) ;
218
- }
219
-
220
- this . $logger . info ( "Applying changes..." ) ;
221
- platformLiveSyncService . refreshApplication ( deviceAppData , localToDevicePaths , data . forceExecuteFullSync || ! wasInstalled ) . wait ( ) ;
222
- this . $logger . info ( `Successfully synced application ${ data . appIdentifier } on device ${ device . deviceInfo . identifier } .` ) ;
204
+ // Restart application or reload page
205
+ if ( shouldRefreshApplication ) {
206
+ // Transfer or remove files on device
207
+ let localToDevicePaths = this . $projectFilesManager . createLocalToDevicePaths ( deviceAppData , projectFilesPath , filesToSync , data . excludedProjectDirsAndFiles , liveSyncOptions ) ;
208
+ if ( deviceFilesAction ) {
209
+ deviceFilesAction ( device , localToDevicePaths ) . wait ( ) ;
210
+ } else {
211
+ this . transferFiles ( deviceAppData , localToDevicePaths , projectFilesPath , ! filesToSync ) . wait ( ) ;
223
212
}
224
- } else {
225
- this . $logger . warn ( `LiveSync is not supported for application: ${ deviceAppData . appIdentifier } on device with identifier ${ device . deviceInfo . identifier } .` ) ;
213
+
214
+ this . $logger . info ( "Applying changes..." ) ;
215
+ platformLiveSyncService . refreshApplication ( deviceAppData , localToDevicePaths , data . forceExecuteFullSync || ! wasInstalled ) . wait ( ) ;
216
+ this . $logger . info ( `Successfully synced application ${ data . appIdentifier } on device ${ device . deviceInfo . identifier } .` ) ;
226
217
}
227
218
} ) . future < void > ( ) ( ) ;
228
219
} ;
@@ -235,7 +226,7 @@ class LiveSyncServiceBase implements ILiveSyncServiceBase {
235
226
for ( let dataItem of data ) {
236
227
let appIdentifier = dataItem . appIdentifier ;
237
228
let platform = dataItem . platform ;
238
- let canExecute = this . getCanExecuteAction ( platform , appIdentifier , dataItem . canExecute ) ;
229
+ let canExecute = this . getCanExecuteAction ( platform , appIdentifier ) ;
239
230
let action = this . getSyncAction ( dataItem , filesToSync , deviceFilesAction , { isForCompanionApp : this . $options . companion , additionalConfigurations : dataItem . additionalConfigurations , configuration : dataItem . configuration , isForDeletedFiles : false } ) ;
240
231
this . $devicesService . execute ( action , canExecute ) . wait ( ) ;
241
232
}
@@ -275,16 +266,16 @@ class LiveSyncServiceBase implements ILiveSyncServiceBase {
275
266
return this . $injector . resolve ( this . $liveSyncProvider . platformSpecificLiveSyncServices [ platform . toLowerCase ( ) ] , { _device : device } ) ;
276
267
}
277
268
278
- public getCanExecuteAction ( platform : string , appIdentifier : string , canExecute : ( dev : Mobile . IDevice ) => boolean ) : ( dev : Mobile . IDevice ) => boolean {
279
- canExecute = canExecute || ( ( dev : Mobile . IDevice ) => dev . deviceInfo . platform . toLowerCase ( ) === platform . toLowerCase ( ) ) ;
280
- let finalCanExecute = canExecute ;
269
+ public getCanExecuteAction ( platform : string , appIdentifier : string ) : ( dev : Mobile . IDevice ) => boolean {
270
+ let isTheSamePlatformAction = ( ( device : Mobile . IDevice ) => device . deviceInfo . platform . toLowerCase ( ) === platform . toLowerCase ( ) ) ;
281
271
if ( this . $options . device ) {
282
- return ( device : Mobile . IDevice ) : boolean => canExecute ( device ) && device . deviceInfo . identifier === this . $devicesService . getDeviceByDeviceOption ( ) . deviceInfo . identifier ;
272
+ return ( device : Mobile . IDevice ) : boolean => isTheSamePlatformAction ( device )
273
+ && device . deviceInfo . identifier === this . $devicesService . getDeviceByDeviceOption ( ) . deviceInfo . identifier ;
283
274
}
284
275
285
276
if ( this . $mobileHelper . isiOSPlatform ( platform ) ) {
286
277
if ( this . $options . emulator ) {
287
- finalCanExecute = ( device : Mobile . IDevice ) : boolean => canExecute ( device ) && this . $devicesService . isiOSSimulator ( device ) ;
278
+ return ( device : Mobile . IDevice ) : boolean => isTheSamePlatformAction ( device ) && this . $devicesService . isiOSSimulator ( device ) ;
288
279
} else {
289
280
let devices = this . $devicesService . getDevicesForPlatform ( platform ) ;
290
281
let simulator = _ . find ( devices , d => this . $devicesService . isiOSSimulator ( d ) ) ;
@@ -295,14 +286,14 @@ class LiveSyncServiceBase implements ILiveSyncServiceBase {
295
286
let isApplicationInstalledOnAllDevices = _ . intersection . apply ( null , iOSDevices . map ( device => device . applicationManager . isApplicationInstalled ( appIdentifier ) . wait ( ) ) ) ;
296
287
// In case the application is not installed on both device and simulator, syncs only on device.
297
288
if ( ! isApplicationInstalledOnSimulator && ! isApplicationInstalledOnAllDevices ) {
298
- finalCanExecute = ( device : Mobile . IDevice ) : boolean => canExecute ( device ) && this . $devicesService . isiOSDevice ( device ) ;
289
+ return ( device : Mobile . IDevice ) : boolean => isTheSamePlatformAction ( device ) && this . $devicesService . isiOSDevice ( device ) ;
299
290
}
300
291
}
301
292
}
302
293
}
303
294
}
304
295
305
- return finalCanExecute ;
296
+ return isTheSamePlatformAction ;
306
297
}
307
298
}
308
299
$injector . register ( 'liveSyncServiceBase' , LiveSyncServiceBase ) ;
0 commit comments