Skip to content

Fix debug android --emulator #1474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 12, 2016
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
18 changes: 4 additions & 14 deletions lib/commands/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export class DebugPlatformCommand implements ICommand {
canExecute(args: string[]): IFuture<boolean> {
return ((): boolean => {
this.$devicesService.initialize({ platform: this.debugService.platform, deviceId: this.$options.device }).wait();
if(this.$options.emulator) {
return true;
}

if(this.$devicesService.deviceCount === 0) {
this.$errors.failWithoutHelp("No devices detected. Connect a device and try again.");
} else if (this.$devicesService.deviceCount > 1) {
Expand All @@ -34,16 +38,6 @@ export class DebugIOSCommand extends DebugPlatformCommand {
$options: IOptions) {
super($iOSDebugService, $devicesService, $errors, $options);
}

canExecute(args: string[]): IFuture<boolean> {
return ((): boolean => {
if(this.$options.emulator) {
return true;
}

return super.canExecute(args).wait();
}).future<boolean>()();
}
}
$injector.registerCommand("debug|ios", DebugIOSCommand);

Expand All @@ -54,9 +48,5 @@ export class DebugAndroidCommand extends DebugPlatformCommand {
$options: IOptions) {
super($androidDebugService, $devicesService, $errors, $options);
}

canExecute(args: string[]): IFuture<boolean> {
return super.canExecute(args);
}
}
$injector.registerCommand("debug|android", DebugAndroidCommand);
7 changes: 6 additions & 1 deletion lib/services/android-debug-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class AndroidDebugService implements IDebugService {
private $hostInfo: IHostInfo,
private $errors: IErrors,
private $opener: IOpener,
private $config: IConfiguration) { }
private $config: IConfiguration,
private $androidDeviceDiscovery: Mobile.IDeviceDiscovery) { }

public get platform() { return "android"; }

Expand All @@ -41,6 +42,10 @@ class AndroidDebugService implements IDebugService {
private debugOnEmulator(): IFuture<void> {
return (() => {
this.$platformService.deployOnEmulator(this.platform).wait();
// Assure we've detected the emulator as device
// For example in case deployOnEmulator had stated new emulator instance
// we need some time to detect it. Let's force detection.
this.$androidDeviceDiscovery.startLookingForDevices().wait();
this.debugOnDevice().wait();
}).future<void>()();
}
Expand Down