Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions lib/services/ios-debug-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS

private async deviceDebugBrk(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
await this.$devicesService.initialize({ platform: this.platform, deviceId: debugData.deviceIdentifier });
const action = async (device: iOSDevice.IOSDevice) => {
const action = async (device: iOSDevice.IOSDevice): Promise<string> => {
if (device.isEmulator) {
return await this.emulatorDebugBrk(debugData, debugOptions);
}
Expand All @@ -170,14 +170,13 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
emulator: debugOptions.emulator,
justlaunch: debugOptions.justlaunch
};
// we intentionally do not wait on this here, because if we did, we'd miss the AppLaunching notification
const startApplicationAction = this.$platformService.startApplication(this.platform, runOptions, debugData.applicationIdentifier);

const result = await this.debugBrkCore(device, debugData, debugOptions);
const promisesResults = await Promise.all<any>([
this.$platformService.startApplication(this.platform, runOptions, debugData.applicationIdentifier),
this.debugBrkCore(device, debugData, debugOptions)
]);

await startApplicationAction;

return result;
return _.last(promisesResults);
};

const deviceActionResult = await this.$devicesService.execute(action, this.getCanExecuteAction(debugData.deviceIdentifier));
Expand Down
25 changes: 20 additions & 5 deletions lib/services/livesync/livesync-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { EOL } from "os";
import { EventEmitter } from "events";
import { hook } from "../../common/helpers";
import { APP_FOLDER_NAME, PACKAGE_JSON_FILE_NAME, LiveSyncTrackActionNames, USER_INTERACTION_NEEDED_EVENT_NAME, DEBUGGER_ATTACHED_EVENT_NAME, DEBUGGER_DETACHED_EVENT_NAME, TrackActionNames } from "../../constants";
import { FileExtensions, DeviceTypes } from "../../common/constants";
import { FileExtensions, DeviceTypes, DeviceDiscoveryEventNames } from "../../common/constants";
import { cache } from "../../common/decorators";

const deviceDescriptorPrimaryKey = "identifier";

const LiveSyncEvents = {
Expand Down Expand Up @@ -473,6 +475,8 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
// Execute the action only on the deviceDescriptors passed to initialSync.
// In case where we add deviceDescriptors to already running application, we've already executed initialSync for them.
await this.addActionToChain(projectData.projectDir, () => this.$devicesService.execute(deviceAction, (device: Mobile.IDevice) => _.some(deviceDescriptors, deviceDescriptor => deviceDescriptor.identifier === device.deviceInfo.identifier)));

this.attachDeviceLostHandler();
}

private getDefaultLatestAppPackageInstalledSettings(): ILatestAppPackageInstalledSettings {
Expand Down Expand Up @@ -632,13 +636,24 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
this.stopLiveSync(projectDir);
});
});

this.$devicesService.on("deviceLost", async (device: Mobile.IDevice) => {
await this.stopLiveSync(projectData.projectDir, [device.deviceInfo.identifier]);
});
}
}

@cache()
private attachDeviceLostHandler(): void {
this.$devicesService.on(DeviceDiscoveryEventNames.DEVICE_LOST, async (device: Mobile.IDevice) => {
this.$logger.trace(`Received ${DeviceDiscoveryEventNames.DEVICE_LOST} event in LiveSync service for ${device.deviceInfo.identifier}. Will stop LiveSync operation for this device.`);

for (const projectDir in this.liveSyncProcessesInfo) {
try {
await this.stopLiveSync(projectDir, [device.deviceInfo.identifier]);
} catch (err) {
this.$logger.warn(`Unable to stop LiveSync operation for ${device.deviceInfo.identifier}.`, err);
}
}
});
}

private async addActionToChain<T>(projectDir: string, action: () => Promise<T>): Promise<T> {
const liveSyncInfo = this.liveSyncProcessesInfo[projectDir];
if (liveSyncInfo) {
Expand Down
16 changes: 12 additions & 4 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,11 @@ export class PlatformService extends EventEmitter implements IPlatformService {
await this.trackActionForPlatform({ action: constants.TrackActionNames.Deploy, platform: device.deviceInfo.platform, isForDevice: !device.isEmulator, deviceOsVersion: device.deviceInfo.version });
};

if (deployOptions.device) {
const device = await this.$devicesService.getDevice(deployOptions.device);
deployOptions.device = device.deviceInfo.identifier;
}

await this.$devicesService.execute(action, this.getCanExecuteAction(platform, deployOptions));
}

Expand All @@ -599,6 +604,12 @@ export class PlatformService extends EventEmitter implements IPlatformService {
};

await this.$devicesService.initialize({ platform: platform, deviceId: runOptions.device });

if (runOptions.device) {
const device = await this.$devicesService.getDevice(runOptions.device);
runOptions.device = device.deviceInfo.identifier;
}

await this.$devicesService.execute(action, this.getCanExecuteAction(platform, runOptions));
}

Expand Down Expand Up @@ -715,10 +726,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
private getCanExecuteAction(platform: string, options: IDeviceEmulator): any {
const canExecute = (currentDevice: Mobile.IDevice): boolean => {
if (options.device && currentDevice && currentDevice.deviceInfo) {
const device = this.$devicesService.getDeviceByDeviceOption();
if (device && device.deviceInfo) {
return currentDevice.deviceInfo.identifier === device.deviceInfo.identifier;
}
return currentDevice.deviceInfo.identifier === options.device;
}

if (this.$mobileHelper.isiOSPlatform(platform) && this.$hostInfo.isDarwin) {
Expand Down
10 changes: 5 additions & 5 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"inquirer": "0.9.0",
"ios-device-lib": "0.4.9",
"ios-mobileprovision-finder": "1.0.10",
"ios-sim-portable": "3.1.1",
"ios-sim-portable": "3.1.2",
"lockfile": "1.0.3",
"lodash": "4.13.1",
"log4js": "1.0.1",
Expand Down