Skip to content

Expose emulator api #3733

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 2 commits into from
Jul 19, 2018
Merged

Expose emulator api #3733

merged 2 commits into from
Jul 19, 2018

Conversation

Fatme
Copy link
Contributor

@Fatme Fatme commented Jul 6, 2018

Related to this PR: telerik/mobile-cli-lib#1101

PR Checklist

This PR deletes all legacy, unneeded and duplicated code that is used for working with iOS and Android emulators.

This PR adds the functionalities below:

  • tns devices android --available-devices - shows all available Android genymotion and Android avd emulators (previously only avd emulators were shown)
  • tns devices --available-devices - works correctly and shows all available iOS simulators, Android genymotion and Android avd emulators. (previously does not work)
  • tns run android --device <imageIdentifier> - it is already possible to run on device with specified imageIdentifier (previously it can run only on emulators specified by identifier or name)

This PR exposes emulator api from devicesService. The api consists from the following two methods:

  1. getAvailableEmulators(opts?: {platform?: string}) -> Returns all available and running iOS and Android emulators. The method accepts platform parameter, so the emulators can be filtered by platform. The output from the method is in the following format:
{
    ios: {
        devices: Mobile.IDeviceInfo[],
        errors: string[]
    },
    android: {
        devices: Mobile.IDeviceInfo[],
        errors: string[]
   }
}

Each available android emulator (NOTE: not running emulator) has the properties below:

{
   identifier: null,
   displayName: the name of the emulator,
   model: the same as the displayName,
   version: The android version of emulator,
   vendor: can be Avd or Genymotion,
   status: not running,
   errorHelp: additional information for errors that prevents working with this device,
   isTablet: false,
   type: Emulator,
   imageIdentifier: for genymotion emulators is the id of virtual machine and for avd is the name of .ini file
}

Each running android emulator has the properties below:

{
   identifier: the emulator identifier,
   displayName: the name of the emulator,
   model: the value of 'ro.product.model' property,
   vendor: the value of 'ro.product.brand' property,
   status: running,
   errorHelp: additional information for errors that prevents working with this device,
   isTablet: when device's 'ro.build.characteristics' property contains "tablet" word or when the 'ro.build.version.release' is 3.x,
   type: Device
   imageIdentifier: for genymotion emulators is the id of virtual machine and for avd is the name of .ini file
}
  1. startEmulator(options) - Starts the specified emulator. The emulator can be specified by imageIdentifier, by name or by emulator object. For android it is possible to pass --timeout option. This option describes the timeout in miliseconds that {N} CLI will wait emulator boot to complete. It might take too long time on some machines to start native android emulator, so this option is useful in such cases.

@@ -86,6 +86,9 @@ interface IDebugOptions {
* Defines if should print all availableDevices
*/
availableDevices?: boolean;

sdk?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing XML comments

@@ -121,6 +121,11 @@ function createTestInjector(projectPath: string, projectName: string, xcode?: IX
testInjector.register("httpClient", {});
testInjector.register("platformEnvironmentRequirements", {});
testInjector.register("plistParser", {});
testInjector.register("androidEmulatorServices", {});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we register Android specific services in iOS project service?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this tests relies on real DevicesService -

testInjector.register("devicesService", DevicesService);

On the other hand devicesService injects androidEmulatorServices so we need it here.

@Natalia-Hristova Natalia-Hristova added this to the 4.2.0 milestone Jul 6, 2018
@dtopuzov
Copy link
Contributor

dtopuzov commented Jul 9, 2018

run ci

1 similar comment
@dtopuzov
Copy link
Contributor

dtopuzov commented Jul 9, 2018

run ci

Copy link
Contributor

@rosen-vladimirov rosen-vladimirov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new API does not have documentation. Please follow the guidelines described here

@Fatme Fatme force-pushed the fatme/emulator-api branch 2 times, most recently from 09679bc to ad2fbc3 Compare July 16, 2018 06:06
@Natalia-Hristova
Copy link

run ci

1 similar comment
@Natalia-Hristova
Copy link

run ci

@Fatme Fatme force-pushed the fatme/emulator-api branch 2 times, most recently from 0cc77c2 to 89173dd Compare July 18, 2018 14:46
@Natalia-Hristova
Copy link

run ci

@Fatme Fatme force-pushed the fatme/emulator-api branch from 89173dd to 0a02a0f Compare July 19, 2018 05:46
@dtopuzov
Copy link
Contributor

run ci

@Fatme Fatme force-pushed the fatme/emulator-api branch 3 times, most recently from 0ff064d to b1b49cf Compare July 19, 2018 14:37
@Fatme Fatme force-pushed the fatme/emulator-api branch from b1b49cf to da6955b Compare July 19, 2018 15:41
PublicAPI.md Outdated
@@ -1198,6 +1201,45 @@ tns.sysInfo.getSystemWarnings()
.catch(err => console.error(`Error while trying to get system warnings: ${err}`));
```

## devicesService
The `devicesService` module allows interaction with devices and emualtors. You can get a list of the available emualators or start a specific emulator.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

emualtors -> emulators

@Fatme Fatme force-pushed the fatme/emulator-api branch from da6955b to 1875c88 Compare July 19, 2018 16:27
@Fatme Fatme force-pushed the fatme/emulator-api branch from 1875c88 to 27b4c22 Compare July 19, 2018 16:34
@Fatme Fatme merged commit f73ec8e into master Jul 19, 2018
@Fatme Fatme deleted the fatme/emulator-api branch July 19, 2018 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants