@@ -4,13 +4,11 @@ import {
44 log ,
55 isWin ,
66 shutdown ,
7- executeCommand ,
8- findFreePort
7+ executeCommand
98} from "./utils" ;
109import * as child_process from "child_process" ;
1110import { INsCapabilities } from "./interfaces/ns-capabilities" ;
1211import { IDeviceManager } from "./interfaces/device-manager" ;
13- import { ServiceContext } from "./service/service-context" ;
1412
1513import {
1614 IDevice ,
@@ -26,10 +24,7 @@ import {
2624export class DeviceManger implements IDeviceManager {
2725 private static _emulators : Map < string , IDevice > = new Map ( ) ;
2826
29- constructor ( port , private _serveiceContext : ServiceContext = undefined ) {
30- if ( ! this . _serveiceContext ) {
31- this . _serveiceContext = ServiceContext . createServer ( port ) ;
32- }
27+ constructor ( ) {
3328 }
3429
3530 public async startDevice ( args : INsCapabilities ) : Promise < IDevice > {
@@ -46,20 +41,6 @@ export class DeviceManger implements IDeviceManager {
4641 return device ;
4742 }
4843
49- // Using serve to manage deivces.
50- if ( args . useDeviceControllerServer ) {
51- const d = await this . _serveiceContext . subscribe ( args . appiumCaps . deviceName , args . appiumCaps . platformName . toLowerCase ( ) , args . appiumCaps . platformVersion , args . appiumCaps . app ) ;
52- delete d [ '__v' ] ;
53- delete d [ '_id' ]
54- if ( ! d || ! ( d as IDevice ) ) {
55- console . error ( "" , d ) ;
56- throw new Error ( "Missing device: " + d ) ;
57- }
58- console . log ( `Device:` , d ) ;
59-
60- return < any > d ;
61- }
62-
6344 const allDevices = ( await DeviceController . getDevices ( { platform : args . appiumCaps . platformName } ) ) ;
6445 if ( ! allDevices || allDevices === null || allDevices . length === 0 ) {
6546 console . log ( "We couldn't find any devices. We will try to proceed to appium! Maybe avd manager is missing" )
@@ -111,27 +92,10 @@ export class DeviceManger implements IDeviceManager {
11192 public async stopDevice ( args : INsCapabilities ) : Promise < any > {
11293 if ( process . env [ "DEVICE_TOKEN" ] ) {
11394 return ;
114- }
115- if ( args . useDeviceControllerServer ) {
116- const d = await this . _serveiceContext . unsubscribe ( args . device . token ) ;
117- if ( ! d ) {
118- console . error ( "" , d ) ;
119- throw new Error ( "Missing device: " + d ) ;
120- }
121-
122- try {
123- await this . _serveiceContext . releasePort ( args . port ) ;
124- if ( args . appiumCaps . wdaLocalPort ) {
125- await this . _serveiceContext . releasePort ( args . appiumCaps . wdaLocalPort ) ;
126- }
127- } catch ( error ) {
128- console . log ( error ) ;
129- }
13095 } else if ( DeviceManger . _emulators . has ( args . runType )
13196 && ! args . reuseDevice
13297 && ! args . isSauceLab
133- && ! args . ignoreDeviceController
134- && ! args . useDeviceControllerServer ) {
98+ && ! args . ignoreDeviceController ) {
13599 const device = DeviceManger . _emulators . get ( args . runType ) ;
136100 await DeviceManger . kill ( device ) ;
137101 }
0 commit comments