@@ -29,16 +29,22 @@ export class AndroidDeviceSocketsLiveSyncService extends DeviceLiveSyncServiceBa
2929 await this . connectLivesyncTool ( projectFilesPath , this . data . projectId ) ;
3030 }
3131
32- public async refreshApplication ( projectData : IProjectData , liveSyncInfo : ILiveSyncResultInfo ) : Promise < void > {
33- const canExecuteFastSync = ! liveSyncInfo . isFullSync && this . canExecuteFastSyncForPaths ( liveSyncInfo . modifiedFilesData , projectData , this . device . deviceInfo . platform ) ;
32+ public async finalizeSync ( liveSyncInfo : ILiveSyncResultInfo ) {
33+ await this . doSync ( liveSyncInfo , false ) ;
34+ }
35+
36+ private async doSync ( liveSyncInfo : ILiveSyncResultInfo , doRefresh = false ) : Promise < IAndroidLivesyncSyncOperationResult > {
37+ let result ;
38+ const operationId = this . livesyncTool . generateOperationIdentifier ( ) ;
39+
40+ result = { operationId, didRefresh : true } ;
3441
3542 if ( liveSyncInfo . modifiedFilesData . length ) {
36- const operationIdentifier = this . livesyncTool . generateOperationIdentifier ( ) ;
3743
38- const doSyncPromise = this . livesyncTool . sendDoSyncOperation ( canExecuteFastSync , null , operationIdentifier ) ;
44+ const doSyncPromise = this . livesyncTool . sendDoSyncOperation ( doRefresh , null , operationId ) ;
3945
4046 const syncInterval : NodeJS . Timer = setInterval ( ( ) => {
41- if ( this . livesyncTool . isOperationInProgress ( operationIdentifier ) ) {
47+ if ( this . livesyncTool . isOperationInProgress ( operationId ) ) {
4248 this . $logger . info ( "Sync operation in progress..." ) ;
4349 }
4450 } , AndroidDeviceSocketsLiveSyncService . STATUS_UPDATE_INTERVAL ) ;
@@ -50,14 +56,22 @@ export class AndroidDeviceSocketsLiveSyncService extends DeviceLiveSyncServiceBa
5056 this . $processService . attachToProcessExitSignals ( this , clearSyncInterval ) ;
5157 doSyncPromise . then ( clearSyncInterval , clearSyncInterval ) ;
5258
53- const refreshResult = await doSyncPromise ;
54-
55- if ( ! canExecuteFastSync || ! refreshResult . didRefresh ) {
56- await this . device . applicationManager . restartApplication ( { appId : liveSyncInfo . deviceAppData . appIdentifier , projectName : projectData . projectName } ) ;
57- }
59+ result = await doSyncPromise ;
5860 }
5961
62+ return result ;
63+ }
64+
65+ public async refreshApplication ( projectData : IProjectData , liveSyncInfo : ILiveSyncResultInfo ) {
66+ const canExecuteFastSync = ! liveSyncInfo . isFullSync && this . canExecuteFastSyncForPaths ( liveSyncInfo . modifiedFilesData , projectData , this . device . deviceInfo . platform ) ;
67+
68+ const syncOperationResult = await this . doSync ( liveSyncInfo , canExecuteFastSync ) ;
69+
6070 this . livesyncTool . end ( ) ;
71+
72+ if ( ! canExecuteFastSync || ! syncOperationResult . didRefresh ) {
73+ await this . device . applicationManager . restartApplication ( { appId : liveSyncInfo . deviceAppData . appIdentifier , projectName : projectData . projectName } ) ;
74+ }
6175 }
6276
6377 public async removeFiles ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] , projectFilesPath : string ) : Promise < void > {
0 commit comments