@@ -29,16 +29,22 @@ export class AndroidDeviceSocketsLiveSyncService extends DeviceLiveSyncServiceBa
29
29
await this . connectLivesyncTool ( projectFilesPath , this . data . projectId ) ;
30
30
}
31
31
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 } ;
34
41
35
42
if ( liveSyncInfo . modifiedFilesData . length ) {
36
- const operationIdentifier = this . livesyncTool . generateOperationIdentifier ( ) ;
37
43
38
- const doSyncPromise = this . livesyncTool . sendDoSyncOperation ( canExecuteFastSync , null , operationIdentifier ) ;
44
+ const doSyncPromise = this . livesyncTool . sendDoSyncOperation ( doRefresh , null , operationId ) ;
39
45
40
46
const syncInterval : NodeJS . Timer = setInterval ( ( ) => {
41
- if ( this . livesyncTool . isOperationInProgress ( operationIdentifier ) ) {
47
+ if ( this . livesyncTool . isOperationInProgress ( operationId ) ) {
42
48
this . $logger . info ( "Sync operation in progress..." ) ;
43
49
}
44
50
} , AndroidDeviceSocketsLiveSyncService . STATUS_UPDATE_INTERVAL ) ;
@@ -50,14 +56,22 @@ export class AndroidDeviceSocketsLiveSyncService extends DeviceLiveSyncServiceBa
50
56
this . $processService . attachToProcessExitSignals ( this , clearSyncInterval ) ;
51
57
doSyncPromise . then ( clearSyncInterval , clearSyncInterval ) ;
52
58
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 ;
58
60
}
59
61
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
+
60
70
this . livesyncTool . end ( ) ;
71
+
72
+ if ( ! canExecuteFastSync || ! syncOperationResult . didRefresh ) {
73
+ await this . device . applicationManager . restartApplication ( { appId : liveSyncInfo . deviceAppData . appIdentifier , projectName : projectData . projectName } ) ;
74
+ }
61
75
}
62
76
63
77
public async removeFiles ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] , projectFilesPath : string ) : Promise < void > {
0 commit comments