Skip to content

Commit 57fbdfc

Browse files
Fatme HavaluovaFatme Havaluova
Fatme Havaluova
authored and
Fatme Havaluova
committed
Print warning message when livesyncing to android devices which run-as is not working
1 parent 59859ea commit 57fbdfc

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/services/usb-livesync-service.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@ export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncSer
3636
let platformData = this.$platformsData.getPlatformData(platform.toLowerCase());
3737
let projectFilesPath = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME);
3838

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+
3953
let restartAppOnDeviceAction = (device: Mobile.IDevice, deviceAppData: Mobile.IDeviceAppData, localToDevicePaths?: Mobile.ILocalToDevicePathData[]): IFuture<void> => {
4054
let platformSpecificUsbLiveSyncService = this.resolveUsbLiveSyncService(platform || this.$devicesServices.platform, device);
4155
return platformSpecificUsbLiveSyncService.restartApplication(deviceAppData, localToDevicePaths);
@@ -54,7 +68,7 @@ export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncSer
5468

5569
let watchGlob = path.join(this.$projectData.projectDir, constants.APP_FOLDER_NAME) + "/**/*";
5670

57-
this.sync(platform, this.$projectData.projectId, platformData.appDestinationDirectoryPath, projectFilesPath, this.excludedProjectDirsAndFiles, watchGlob, restartAppOnDeviceAction, notInstalledAppOnDeviceAction, beforeBatchLiveSyncAction).wait();
71+
this.sync(platform, this.$projectData.projectId, platformData.appDestinationDirectoryPath, projectFilesPath, this.excludedProjectDirsAndFiles, watchGlob, restartAppOnDeviceAction, notInstalledAppOnDeviceAction, beforeBatchLiveSyncAction, canLiveSyncAction).wait();
5872
}).future<void>()();
5973
}
6074

0 commit comments

Comments
 (0)