@@ -145,60 +145,54 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
145145 throw new Error ( `Invalid platform ${ platform } . Supported platforms are: ${ this . $mobileHelper . platformNames . join ( ", " ) } ` ) ;
146146 }
147147
148- private async ensureLatestAppPackageIsInstalledOnDevice ( device : Mobile . IDevice ,
149- preparedPlatforms : string [ ] ,
150- rebuiltInformation : ILiveSyncBuildInfo [ ] ,
151- projectData : IProjectData ,
152- deviceBuildInfoDescriptor : ILiveSyncDeviceInfo ,
153- settings : ILatestAppPackageInstalledSettings ,
154- modifiedFiles ?: string [ ] ) : Promise < void > {
155- const platform = device . deviceInfo . platform ;
156- if ( preparedPlatforms . indexOf ( platform ) === - 1 ) {
157- preparedPlatforms . push ( platform ) ;
148+ private async ensureLatestAppPackageIsInstalledOnDevice ( options : IEnsureLatestAppPackageIsInstalledOnDeviceOptions ) : Promise < void > {
149+ const platform = options . device . deviceInfo . platform ;
150+ if ( options . preparedPlatforms . indexOf ( platform ) === - 1 ) {
151+ options . preparedPlatforms . push ( platform ) ;
158152 // TODO: Pass provision and sdk as a fifth argument here
159153 await this . $platformService . preparePlatform ( platform , {
160154 bundle : false ,
161155 release : false ,
162- } , null , projectData , < any > { } , modifiedFiles ) ;
156+ } , null , options . projectData , < any > { } , options . modifiedFiles ) ;
163157 }
164158
165- const rebuildInfo = _ . find ( rebuiltInformation , info => info . isEmulator === device . isEmulator && info . platform === platform ) ;
159+ const rebuildInfo = _ . find ( options . rebuiltInformation , info => info . isEmulator === options . device . isEmulator && info . platform === platform ) ;
166160
167161 if ( rebuildInfo ) {
168162 // Case where we have three devices attached, a change that requires build is found,
169163 // we'll rebuild the app only for the first device, but we should install new package on all three devices.
170- await this . $platformService . installApplication ( device , { release : false } , projectData , rebuildInfo . pathToBuildItem , deviceBuildInfoDescriptor . outputPath ) ;
164+ await this . $platformService . installApplication ( options . device , { release : false } , options . projectData , rebuildInfo . pathToBuildItem , options . deviceBuildInfoDescriptor . outputPath ) ;
171165 return ;
172166 }
173167
174168 // TODO: Pass provision and sdk as a fifth argument here
175- const shouldBuild = await this . $platformService . shouldBuild ( platform , projectData , < any > { buildForDevice : ! device . isEmulator } , deviceBuildInfoDescriptor . outputPath ) ;
169+ const shouldBuild = await this . $platformService . shouldBuild ( platform , options . projectData , < any > { buildForDevice : ! options . device . isEmulator , clean : options . liveSyncData && options . liveSyncData . clean } , options . deviceBuildInfoDescriptor . outputPath ) ;
176170 let pathToBuildItem = null ;
177171 let action = LiveSyncTrackActionNames . LIVESYNC_OPERATION ;
178172 if ( shouldBuild ) {
179- pathToBuildItem = await deviceBuildInfoDescriptor . buildAction ( ) ;
173+ pathToBuildItem = await options . deviceBuildInfoDescriptor . buildAction ( ) ;
180174 // Is it possible to return shouldBuild for two devices? What about android device and android emulator?
181- rebuiltInformation . push ( { isEmulator : device . isEmulator , platform, pathToBuildItem } ) ;
175+ options . rebuiltInformation . push ( { isEmulator : options . device . isEmulator , platform, pathToBuildItem } ) ;
182176 action = LiveSyncTrackActionNames . LIVESYNC_OPERATION_BUILD ;
183177 }
184178
185- if ( ! settings [ platform ] [ device . deviceInfo . type ] ) {
186- let isForDevice = ! device . isEmulator ;
187- settings [ platform ] [ device . deviceInfo . type ] = true ;
179+ if ( ! options . settings [ platform ] [ options . device . deviceInfo . type ] ) {
180+ let isForDevice = ! options . device . isEmulator ;
181+ options . settings [ platform ] [ options . device . deviceInfo . type ] = true ;
188182 if ( this . $mobileHelper . isAndroidPlatform ( platform ) ) {
189- settings [ platform ] [ DeviceTypes . Emulator ] = true ;
190- settings [ platform ] [ DeviceTypes . Device ] = true ;
183+ options . settings [ platform ] [ DeviceTypes . Emulator ] = true ;
184+ options . settings [ platform ] [ DeviceTypes . Device ] = true ;
191185 isForDevice = null ;
192186 }
193187
194188 await this . $platformService . trackActionForPlatform ( { action, platform, isForDevice } ) ;
195189 }
196190
197- await this . $platformService . trackActionForPlatform ( { action : LiveSyncTrackActionNames . DEVICE_INFO , platform, isForDevice : ! device . isEmulator , deviceOsVersion : device . deviceInfo . version } ) ;
191+ await this . $platformService . trackActionForPlatform ( { action : LiveSyncTrackActionNames . DEVICE_INFO , platform, isForDevice : ! options . device . isEmulator , deviceOsVersion : options . device . deviceInfo . version } ) ;
198192
199- const shouldInstall = await this . $platformService . shouldInstall ( device , projectData , deviceBuildInfoDescriptor . outputPath ) ;
193+ const shouldInstall = await this . $platformService . shouldInstall ( options . device , options . projectData , options . deviceBuildInfoDescriptor . outputPath ) ;
200194 if ( shouldInstall ) {
201- await this . $platformService . installApplication ( device , { release : false } , projectData , pathToBuildItem , deviceBuildInfoDescriptor . outputPath ) ;
195+ await this . $platformService . installApplication ( options . device , { release : false } , options . projectData , pathToBuildItem , options . deviceBuildInfoDescriptor . outputPath ) ;
202196 }
203197 }
204198
@@ -217,9 +211,17 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
217211 } ) ;
218212
219213 const platform = device . deviceInfo . platform ;
220- const deviceDescriptor = _ . find ( deviceDescriptors , dd => dd . identifier === device . deviceInfo . identifier ) ;
221-
222- await this . ensureLatestAppPackageIsInstalledOnDevice ( device , preparedPlatforms , rebuiltInformation , projectData , deviceDescriptor , settings ) ;
214+ const deviceBuildInfoDescriptor = _ . find ( deviceDescriptors , dd => dd . identifier === device . deviceInfo . identifier ) ;
215+
216+ await this . ensureLatestAppPackageIsInstalledOnDevice ( {
217+ device,
218+ preparedPlatforms,
219+ rebuiltInformation,
220+ projectData,
221+ deviceBuildInfoDescriptor,
222+ liveSyncData,
223+ settings
224+ } ) ;
223225
224226 const liveSyncResultInfo = await this . getLiveSyncService ( platform ) . fullSync ( {
225227 projectData, device,
@@ -305,9 +307,17 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
305307
306308 await this . $devicesService . execute ( async ( device : Mobile . IDevice ) => {
307309 const liveSyncProcessInfo = this . liveSyncProcessesInfo [ projectData . projectDir ] ;
308- const deviceDescriptor = _ . find ( liveSyncProcessInfo . deviceDescriptors , dd => dd . identifier === device . deviceInfo . identifier ) ;
310+ const deviceBuildInfoDescriptor = _ . find ( liveSyncProcessInfo . deviceDescriptors , dd => dd . identifier === device . deviceInfo . identifier ) ;
309311
310- await this . ensureLatestAppPackageIsInstalledOnDevice ( device , preparedPlatforms , rebuiltInformation , projectData , deviceDescriptor , latestAppPackageInstalledSettings , allModifiedFiles ) ;
312+ await this . ensureLatestAppPackageIsInstalledOnDevice ( {
313+ device,
314+ preparedPlatforms,
315+ rebuiltInformation,
316+ projectData,
317+ deviceBuildInfoDescriptor,
318+ settings : latestAppPackageInstalledSettings ,
319+ modifiedFiles : allModifiedFiles
320+ } ) ;
311321
312322 const service = this . getLiveSyncService ( device . deviceInfo . platform ) ;
313323 const settings : ILiveSyncWatchInfo = {
0 commit comments