|
1 | 1 | export class DebugPlatformCommand implements ICommand {
|
2 | 2 | constructor(private debugService: IDebugService,
|
3 | 3 | private $devicesService: Mobile.IDevicesService,
|
4 |
| - private $usbLiveSyncService: ILiveSyncService, |
| 4 | + private $injector: IInjector, |
5 | 5 | private $logger: ILogger,
|
| 6 | + private $childProcess: IChildProcess, |
| 7 | + private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, |
| 8 | + private $config: IConfiguration, |
6 | 9 | protected $options: IOptions) { }
|
7 | 10 |
|
8 | 11 | execute(args: string[]): IFuture<void> {
|
9 |
| - if (!this.$options.rebuild) { |
10 |
| - this.$options.debug = true; |
11 |
| - return this.$usbLiveSyncService.liveSync(this.$devicesService.platform); |
| 12 | + if (!this.$options.rebuild && !this.$options.start) { |
| 13 | + this.$config.debugLivesync = true; |
| 14 | + let usbLiveSyncService: ILiveSyncService = this.$injector.resolve("usbLiveSyncService"); |
| 15 | + let liveSyncServiceBase: any = this.$injector.resolve("liveSyncServiceBase"); |
| 16 | + let liveSyncProvider: ILiveSyncProvider = this.$injector.resolve("liveSyncProvider"); |
| 17 | + |
| 18 | + liveSyncServiceBase.on("sync", (device: Mobile.IDevice, data: ILiveSyncData) => { |
| 19 | + let platformLiveSyncService: IPlatformLiveSyncService = this.$injector.resolve(liveSyncProvider.platformSpecificLiveSyncServices[data.platform.toLowerCase()], { _device: device }); |
| 20 | + let projectData: IProjectData = this.$injector.resolve("projectData"); |
| 21 | + let appId = device.isEmulator ? projectData.projectName : data.appIdentifier; |
| 22 | + if (data.platform === this.$devicePlatformsConstants.iOS) { |
| 23 | + platformLiveSyncService.debugService.debugStop().wait(); |
| 24 | + } |
| 25 | + device.applicationManager.stopApplication(appId).wait(); |
| 26 | + platformLiveSyncService.debugService.debug().wait(); |
| 27 | + }); |
| 28 | + |
| 29 | + liveSyncServiceBase.on("syncAfterInstall", (device: Mobile.IDevice, data: ILiveSyncData) => { |
| 30 | + let platformLiveSyncService: IPlatformLiveSyncService = this.$injector.resolve(liveSyncProvider.platformSpecificLiveSyncServices[data.platform.toLowerCase()], { _device: device }); |
| 31 | + platformLiveSyncService.debugService.debug().wait(); |
| 32 | + }); |
| 33 | + |
| 34 | + return usbLiveSyncService.liveSync(this.$devicesService.platform); |
12 | 35 | }
|
13 | 36 | return this.debugService.debug();
|
14 | 37 | }
|
|
38 | 61 | export class DebugIOSCommand extends DebugPlatformCommand {
|
39 | 62 | constructor($iOSDebugService: IDebugService,
|
40 | 63 | $devicesService: Mobile.IDevicesService,
|
41 |
| - $usbLiveSyncService: ILiveSyncService, |
| 64 | + $injector: IInjector, |
42 | 65 | $logger: ILogger,
|
| 66 | + $childProcess: IChildProcess, |
| 67 | + $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, |
| 68 | + $config: IConfiguration, |
43 | 69 | $options: IOptions) {
|
44 |
| - super($iOSDebugService, $devicesService, $usbLiveSyncService, $logger, $options); |
| 70 | + super($iOSDebugService, $devicesService, $injector, $logger, $childProcess, $devicePlatformsConstants, $config, $options); |
45 | 71 | }
|
46 | 72 | }
|
47 | 73 | $injector.registerCommand("debug|ios", DebugIOSCommand);
|
48 | 74 |
|
49 | 75 | export class DebugAndroidCommand extends DebugPlatformCommand {
|
50 | 76 | constructor($androidDebugService: IDebugService,
|
51 | 77 | $devicesService: Mobile.IDevicesService,
|
52 |
| - $usbLiveSyncService: ILiveSyncService, |
| 78 | + $injector: IInjector, |
53 | 79 | $logger: ILogger,
|
| 80 | + $childProcess: IChildProcess, |
| 81 | + $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, |
| 82 | + $config: IConfiguration, |
54 | 83 | $options: IOptions) {
|
55 |
| - super($androidDebugService, $devicesService, $usbLiveSyncService, $logger, $options); |
| 84 | + super($androidDebugService, $devicesService, $injector, $logger, $childProcess, $devicePlatformsConstants, $config, $options); |
56 | 85 | }
|
57 | 86 | }
|
58 | 87 | $injector.registerCommand("debug|android", DebugAndroidCommand);
|
0 commit comments