@@ -36,22 +36,8 @@ export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncSer
36
36
let platformData = this . $platformsData . getPlatformData ( platform . toLowerCase ( ) ) ;
37
37
let projectFilesPath = path . join ( platformData . appDestinationDirectoryPath , constants . APP_FOLDER_NAME ) ;
38
38
39
- let canLiveSyncAction = ( device : Mobile . IDevice , appIdentifier : string ) : IFuture < boolean > => {
40
- return ( ( ) => {
41
- if ( platform . toLowerCase ( ) === "android" ) {
42
- let output = ( < Mobile . IAndroidDevice > device ) . adb . executeShellCommand ( `"echo '' | run-as ${ appIdentifier } "` ) . wait ( ) ;
43
- if ( output . indexOf ( `run-as: Package '${ appIdentifier } ' is unknown` ) !== - 1 ) {
44
- this . $logger . warn ( `Unable to livesync on device ${ device . deviceInfo . identifier } . Consider upgrading your device OS.` ) ;
45
- return false ;
46
- }
47
- }
48
-
49
- return true ;
50
- } ) . future < boolean > ( ) ( ) ;
51
- }
52
-
53
39
let restartAppOnDeviceAction = ( device : Mobile . IDevice , deviceAppData : Mobile . IDeviceAppData , localToDevicePaths ?: Mobile . ILocalToDevicePathData [ ] ) : IFuture < void > => {
54
- let platformSpecificUsbLiveSyncService = this . resolveUsbLiveSyncService ( platform || this . $devicesServices . platform , device ) ;
40
+ let platformSpecificUsbLiveSyncService = this . resolveUsbLiveSyncService ( platform || this . $devicesServices . platform , device ) ;
55
41
return platformSpecificUsbLiveSyncService . restartApplication ( deviceAppData , localToDevicePaths ) ;
56
42
}
57
43
@@ -66,9 +52,16 @@ export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncSer
66
52
} ) . future < string > ( ) ( ) ;
67
53
}
68
54
55
+ let beforeLiveSyncAction = ( device : Mobile . IDevice , deviceAppData : Mobile . IDeviceAppData ) : IFuture < void > => {
56
+ let platformSpecificUsbLiveSyncService = this . resolveUsbLiveSyncService ( platform || this . $devicesServices . platform , device ) ;
57
+ if ( platformSpecificUsbLiveSyncService . beforeLiveSyncAction ) {
58
+ return platformSpecificUsbLiveSyncService . beforeLiveSyncAction ( deviceAppData ) ;
59
+ }
60
+ }
61
+
69
62
let watchGlob = path . join ( this . $projectData . projectDir , constants . APP_FOLDER_NAME ) ;
70
63
71
- this . sync ( platform , this . $projectData . projectId , platformData . appDestinationDirectoryPath , projectFilesPath , this . excludedProjectDirsAndFiles , watchGlob , restartAppOnDeviceAction , notInstalledAppOnDeviceAction , beforeBatchLiveSyncAction , canLiveSyncAction ) . wait ( ) ;
64
+ this . sync ( platform , this . $projectData . projectId , projectFilesPath , this . excludedProjectDirsAndFiles , watchGlob , restartAppOnDeviceAction , notInstalledAppOnDeviceAction , beforeLiveSyncAction , beforeBatchLiveSyncAction ) . wait ( ) ;
72
65
} ) . future < void > ( ) ( ) ;
73
66
}
74
67
@@ -114,31 +107,20 @@ export class AndroidUsbLiveSyncService extends androidLiveSyncServiceLib.Android
114
107
let commands = [ this . liveSyncCommands . SyncFilesCommand ( ) ] ;
115
108
this . livesync ( deviceAppData . appIdentifier , deviceAppData . deviceProjectRootPath , commands ) . wait ( ) ;
116
109
} else {
117
- this . device . adb . executeShellCommand ( `chmod 0777 ${ this . $mobileHelper . buildDevicePath ( deviceAppData . deviceProjectRootPath , "app" ) } ` ) . wait ( ) ;
118
-
119
- let commands : string [ ] = [ ] ;
120
-
121
- let devicePathRoot = `/data/data/${ deviceAppData . appIdentifier } /files` ;
122
- _ . each ( localToDevicePaths , localToDevicePath => {
123
- let devicePath = this . $mobileHelper . correctDevicePath ( path . join ( devicePathRoot , localToDevicePath . getRelativeToProjectBasePath ( ) ) ) ;
124
- if ( this . $fs . getFsStats ( localToDevicePath . getLocalPath ( ) ) . wait ( ) . isFile ( ) ) {
125
- commands . push ( `mv "${ localToDevicePath . getDevicePath ( ) } " "${ devicePath } "` ) ;
126
- }
127
- } ) ;
128
-
129
- commands . push ( `rm -rf ${ this . $mobileHelper . buildDevicePath ( devicePathRoot , "code_cache" , "secondary_dexes" , "proxyThumb" ) } ` ) ;
130
- commands . push ( "exit" ) ;
131
-
132
- let commandsFileDevicePath = this . $mobileHelper . buildDevicePath ( deviceAppData . deviceProjectRootPath , AndroidUsbLiveSyncService . LIVESYNC_COMMANDS_FILE_NAME ) ;
133
- this . createCommandsFileOnDevice ( commandsFileDevicePath , commands ) . wait ( ) ;
134
-
135
- let result = this . device . adb . executeShellCommand ( `"cat ${ commandsFileDevicePath } | run-as ${ deviceAppData . appIdentifier } "` ) . wait ( ) ;
136
- if ( result . indexOf ( "Permission denied" ) !== - 1 ) {
137
- this . device . adb . executeShellCommand ( `${ commandsFileDevicePath } ` ) . wait ( ) ;
138
- }
110
+ let devicePathRoot = `/data/data/${ deviceAppData . appIdentifier } /files` ;
111
+ this . device . adb . executeShellCommand ( `rm -rf ${ this . $mobileHelper . buildDevicePath ( devicePathRoot , "code_cache" , "secondary_dexes" , "proxyThumb" ) } ` ) . wait ( ) ;
139
112
}
140
113
141
114
this . device . applicationManager . restartApplication ( deviceAppData . appIdentifier ) . wait ( ) ;
142
115
} ) . future < void > ( ) ( ) ;
143
116
}
117
+
118
+ public beforeLiveSyncAction ( deviceAppData : Mobile . IDeviceAppData ) : IFuture < void > {
119
+ return ( ( ) => {
120
+ let deviceRootPath = `/data/local/tmp/${ deviceAppData . appIdentifier } ` ;
121
+ this . device . adb . executeShellCommand ( `rm -rf ${ this . $mobileHelper . buildDevicePath ( deviceRootPath , "fullsync" ) } ` ) . wait ( ) ;
122
+ this . device . adb . executeShellCommand ( `rm -rf ${ this . $mobileHelper . buildDevicePath ( deviceRootPath , "sync" ) } ` ) . wait ( ) ;
123
+ this . device . adb . executeShellCommand ( `rm -rf ${ this . $mobileHelper . buildDevicePath ( deviceRootPath , "removedsync" ) } ` ) . wait ( ) ;
124
+ } ) . future < void > ( ) ( ) ;
125
+ }
144
126
}
0 commit comments