Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit 7554ca7

Browse files
FatmeFatme
Fatme
authored and
Fatme
committed
Merge pull request #394 from telerik/fatme/fix-android-livesync
Print warning message when livesyncing to android devices which run-as is not working
2 parents 180b484 + 6cce17f commit 7554ca7

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

declarations.d.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ interface IUsbLiveSyncServiceBase {
266266
sync(platform: string, appIdentifier: string, localProjectRootPath: string, projectFilesPath: string, excludedProjectDirsAndFiles: string[], watchGlob: any,
267267
restartAppOnDeviceAction: (device: Mobile.IDevice, deviceAppData: Mobile.IDeviceAppData) => IFuture<void>,
268268
notInstalledAppOnDeviceAction: (device: Mobile.IDevice) => IFuture<void>,
269-
beforeBatchLiveSyncAction?: (filePath: string) => IFuture<string>): IFuture<void>;
269+
beforeBatchLiveSyncAction?: (filePath: string) => IFuture<string>,
270+
canLiveSyncAction?: (device: Mobile.IDevice, appIdentifier: string) => IFuture<boolean>): IFuture<void>;
270271
}
271272

272273
interface ISysInfoData {

services/usb-livesync-service-base.ts

+13-6
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
3737
public sync(platform: string, appIdentifier: string, localProjectRootPath: string, projectFilesPath: string, excludedProjectDirsAndFiles: string[], watchGlob: any,
3838
restartAppOnDeviceAction: (device: Mobile.IDevice, deviceAppData: Mobile.IDeviceAppData, localToDevicePaths?: Mobile.ILocalToDevicePathData[]) => IFuture<void>,
3939
notInstalledAppOnDeviceAction: (device: Mobile.IDevice) => IFuture<void>,
40-
beforeBatchLiveSyncAction?: (filePath: string) => IFuture<string>): IFuture<void> {
40+
beforeBatchLiveSyncAction?: (filePath: string) => IFuture<string>,
41+
canLiveSyncAction?: (device: Mobile.IDevice, appIdentifier: string) => IFuture<boolean>): IFuture<void> {
4142
return (() => {
4243
if(!this._initialized) {
4344
this.initialize(platform).wait();
4445
}
4546

4647
let projectFiles = this.$fs.enumerateFilesInDirectorySync(projectFilesPath, (filePath, stat) => !this.isFileExcluded(path.relative(projectFilesPath, filePath), excludedProjectDirsAndFiles, projectFilesPath), { enumerateDirectories: true});
47-
this.syncCore(projectFiles, appIdentifier, localProjectRootPath, restartAppOnDeviceAction, notInstalledAppOnDeviceAction).wait();
48+
this.syncCore(projectFiles, appIdentifier, localProjectRootPath, restartAppOnDeviceAction, notInstalledAppOnDeviceAction, canLiveSyncAction).wait();
4849

4950
if(this.$options.watch) {
5051
let __this = this;
@@ -64,7 +65,8 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
6465

6566
private syncCore(projectFiles: string[], appIdentifier: string, localProjectRootPath: string,
6667
restartAppOnDeviceAction: (device: Mobile.IDevice, deviceAppData: Mobile.IDeviceAppData, localToDevicePaths?: Mobile.ILocalToDevicePathData[]) => IFuture<void>,
67-
notInstalledAppOnDeviceAction: (device: Mobile.IDevice) => IFuture<void>): IFuture<void> {
68+
notInstalledAppOnDeviceAction: (device: Mobile.IDevice) => IFuture<void>,
69+
canLiveSyncAction: (device: Mobile.IDevice, appIdentifier: string) => IFuture<boolean>): IFuture<void> {
6870
return (() => {
6971
let deviceAppData = this.$deviceAppDataFactory.create(appIdentifier, this.$devicesServices.platform);
7072
let localToDevicePaths = _(projectFiles)
@@ -83,13 +85,17 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
8385
return;
8486
}
8587

88+
if(canLiveSyncAction && !canLiveSyncAction(device, appIdentifier).wait()) {
89+
return;
90+
}
91+
8692
this.$logger.info("Transfering project files...");
8793
device.fileSystem.transferFiles(deviceAppData.appIdentifier, localToDevicePaths).wait();
8894
this.$logger.info("Successfully transfered all project files.");
8995

9096
this.$logger.info("Applying changes...");
9197
restartAppOnDeviceAction(device, deviceAppData, localToDevicePaths).wait();
92-
this.$logger.info(`Successfully synced application ${deviceAppData.appIdentifier}.`);
98+
this.$logger.info(`Successfully synced application ${deviceAppData.appIdentifier} on device ${device.deviceInfo.identifier}.`);
9399
}
94100
}).future<void>()();
95101
}
@@ -103,7 +109,8 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
103109
private batchLiveSync(filePath: string, appIdentifier: string, localProjectRootPath: string,
104110
restartAppOnDeviceAction: (device: Mobile.IDevice, deviceAppData: Mobile.IDeviceAppData, localToDevicePaths?: Mobile.ILocalToDevicePathData[]) => IFuture<void>,
105111
notInstalledAppOnDeviceAction: (device: Mobile.IDevice) => IFuture<void>,
106-
beforeBatchLiveSyncAction?: (filePath: string) => IFuture<string>) : void {
112+
beforeBatchLiveSyncAction?: (filePath: string) => IFuture<string>,
113+
canLiveSyncAction?: (device: Mobile.IDevice, appIdentifier: string) => IFuture<boolean>) : void {
107114
if(!this.timer) {
108115
this.timer = setInterval(() => {
109116
let filesToSync = this.syncQueue;
@@ -112,7 +119,7 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
112119
this.$logger.trace("Syncing %s", filesToSync.join(", "));
113120
this.$dispatcher.dispatch( () => {
114121
return (() => {
115-
this.syncCore(filesToSync, appIdentifier, localProjectRootPath, restartAppOnDeviceAction, notInstalledAppOnDeviceAction).wait();
122+
this.syncCore(filesToSync, appIdentifier, localProjectRootPath, restartAppOnDeviceAction, notInstalledAppOnDeviceAction, canLiveSyncAction).wait();
116123
}).future<void>()();
117124
});
118125
}

0 commit comments

Comments
 (0)