Skip to content

Commit 0f403d2

Browse files
Merge pull request #3717 from NativeScript/vladimirov/improve-dev-detection
feat: Speed up device detection
2 parents ff90b0f + 6793191 commit 0f403d2

File tree

6 files changed

+6
-15
lines changed

6 files changed

+6
-15
lines changed

lib/commands/debug.ts

-4
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ export class DebugPlatformCommand implements ICommand {
3535
return;
3636
}
3737

38-
await this.$devicesService.detectCurrentlyAttachedDevices({ shouldReturnImmediateResult: false, platform: this.platform });
39-
4038
await this.$liveSyncCommandHelper.executeLiveSyncOperation([selectedDeviceForDebug], this.platform, {
4139
deviceDebugMap: {
4240
[selectedDeviceForDebug.deviceInfo.identifier]: true
@@ -52,8 +50,6 @@ export class DebugPlatformCommand implements ICommand {
5250
this.$errors.fail(DebugCommandErrors.UNABLE_TO_USE_FOR_DEVICE_AND_EMULATOR);
5351
}
5452

55-
await this.$devicesService.detectCurrentlyAttachedDevices({ platform: this.platform, shouldReturnImmediateResult: false });
56-
5753
if (this.$options.device) {
5854
const device = await this.$devicesService.getDevice(this.$options.device);
5955
return device;

lib/declarations.d.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,6 @@ interface IPlatformTemplate {
405405
platformTemplate: string;
406406
}
407407

408-
interface IEmulator {
409-
emulator: boolean;
410-
}
411408

412409
interface IClean {
413410
clean: boolean;
@@ -449,7 +446,7 @@ interface IPort {
449446
port: Number;
450447
}
451448

452-
interface IOptions extends ICommonOptions, IBundleString, IPlatformTemplate, IEmulator, IClean, IProvision, ITeamIdentifier, IAndroidReleaseOptions, INpmInstallConfigurationOptions, IPort, IEnvOptions {
449+
interface IOptions extends ICommonOptions, IBundleString, IPlatformTemplate, IHasEmulatorOption, IClean, IProvision, ITeamIdentifier, IAndroidReleaseOptions, INpmInstallConfigurationOptions, IPort, IEnvOptions {
453450
all: boolean;
454451
client: boolean;
455452
compileSdk: number;
@@ -482,7 +479,7 @@ interface IAppFilesUpdaterOptions extends IBundle, IRelease, IOptionalWatchAllFi
482479

483480
interface IPlatformBuildData extends IAppFilesUpdaterOptions, IBuildConfig, IEnvOptions { }
484481

485-
interface IDeviceEmulator extends IEmulator, IDeviceIdentifier { }
482+
interface IDeviceEmulator extends IHasEmulatorOption, IDeviceIdentifier { }
486483

487484
interface IRunPlatformOptions extends IJustLaunch, IDeviceEmulator { }
488485

lib/helpers/livesync-command-helper.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ export class LiveSyncCommandHelper implements ILiveSyncCommandHelper {
2121
}
2222

2323
public async executeCommandLiveSync(platform?: string, additionalOptions?: ILiveSyncCommandHelperAdditionalOptions) {
24+
const emulator = this.$options.emulator;
2425
await this.$devicesService.initialize({
2526
deviceId: this.$options.device,
26-
platform: platform,
27-
emulator: this.$options.emulator,
27+
platform,
28+
emulator,
2829
skipDeviceDetectionInterval: true,
2930
skipInferPlatform: !platform
3031
});
3132

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

lib/services/test-execution-service.ts

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class TestExecutionService implements ITestExecutionService {
4444
deviceId: this.$options.device,
4545
emulator: this.$options.emulator
4646
});
47-
await this.$devicesService.detectCurrentlyAttachedDevices();
4847
const projectFilesPath = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME);
4948

5049
const configOptions: IKarmaConfigOptions = JSON.parse(launcherConfig);

test/debug.ts

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ function createTestInjector(): IInjector {
3636
});
3737
testInjector.register('devicesService', {
3838
initialize: async () => { /* Intentionally left blank */ },
39-
detectCurrentlyAttachedDevices: async () => { /* Intentionally left blank */ },
4039
getDeviceInstances: (): any[] => { return []; },
4140
execute: async (): Promise<any> => ({})
4241
});

0 commit comments

Comments
 (0)