Skip to content

feat: Speed up device detection #3717

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
Jul 15, 2018
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
4 changes: 0 additions & 4 deletions lib/commands/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ export class DebugPlatformCommand implements ICommand {
return;
}

await this.$devicesService.detectCurrentlyAttachedDevices({ shouldReturnImmediateResult: false, platform: this.platform });

await this.$liveSyncCommandHelper.executeLiveSyncOperation([selectedDeviceForDebug], this.platform, {
deviceDebugMap: {
[selectedDeviceForDebug.deviceInfo.identifier]: true
Expand All @@ -52,8 +50,6 @@ export class DebugPlatformCommand implements ICommand {
this.$errors.fail(DebugCommandErrors.UNABLE_TO_USE_FOR_DEVICE_AND_EMULATOR);
}

await this.$devicesService.detectCurrentlyAttachedDevices({ platform: this.platform, shouldReturnImmediateResult: false });

if (this.$options.device) {
const device = await this.$devicesService.getDevice(this.$options.device);
return device;
Expand Down
7 changes: 2 additions & 5 deletions lib/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,6 @@ interface IPlatformTemplate {
platformTemplate: string;
}

interface IEmulator {
emulator: boolean;
}

interface IClean {
clean: boolean;
Expand Down Expand Up @@ -449,7 +446,7 @@ interface IPort {
port: Number;
}

interface IOptions extends ICommonOptions, IBundleString, IPlatformTemplate, IEmulator, IClean, IProvision, ITeamIdentifier, IAndroidReleaseOptions, INpmInstallConfigurationOptions, IPort, IEnvOptions {
interface IOptions extends ICommonOptions, IBundleString, IPlatformTemplate, IHasEmulatorOption, IClean, IProvision, ITeamIdentifier, IAndroidReleaseOptions, INpmInstallConfigurationOptions, IPort, IEnvOptions {
all: boolean;
client: boolean;
compileSdk: number;
Expand Down Expand Up @@ -482,7 +479,7 @@ interface IAppFilesUpdaterOptions extends IBundle, IRelease, IOptionalWatchAllFi

interface IPlatformBuildData extends IAppFilesUpdaterOptions, IBuildConfig, IEnvOptions { }

interface IDeviceEmulator extends IEmulator, IDeviceIdentifier { }
interface IDeviceEmulator extends IHasEmulatorOption, IDeviceIdentifier { }

interface IRunPlatformOptions extends IJustLaunch, IDeviceEmulator { }

Expand Down
6 changes: 3 additions & 3 deletions lib/helpers/livesync-command-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ export class LiveSyncCommandHelper implements ILiveSyncCommandHelper {
}

public async executeCommandLiveSync(platform?: string, additionalOptions?: ILiveSyncCommandHelperAdditionalOptions) {
const emulator = this.$options.emulator;
await this.$devicesService.initialize({
deviceId: this.$options.device,
platform: platform,
emulator: this.$options.emulator,
platform,
emulator,
skipDeviceDetectionInterval: true,
skipInferPlatform: !platform
});

await this.$devicesService.detectCurrentlyAttachedDevices({ shouldReturnImmediateResult: false, platform: platform });
const devices = this.$devicesService.getDeviceInstances()
.filter(d => !platform || d.deviceInfo.platform.toLowerCase() === platform.toLowerCase());

Expand Down
1 change: 0 additions & 1 deletion lib/services/test-execution-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class TestExecutionService implements ITestExecutionService {
deviceId: this.$options.device,
emulator: this.$options.emulator
});
await this.$devicesService.detectCurrentlyAttachedDevices();
const projectFilesPath = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME);

const configOptions: IKarmaConfigOptions = JSON.parse(launcherConfig);
Expand Down
1 change: 0 additions & 1 deletion test/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ function createTestInjector(): IInjector {
});
testInjector.register('devicesService', {
initialize: async () => { /* Intentionally left blank */ },
detectCurrentlyAttachedDevices: async () => { /* Intentionally left blank */ },
getDeviceInstances: (): any[] => { return []; },
execute: async (): Promise<any> => ({})
});
Expand Down