Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / build / android / pylib / utils / emulator.py
index 6545463..c256eac 100644 (file)
@@ -4,8 +4,6 @@
 
 """Provides an interface to start and stop Android emulator.
 
-Assumes system environment ANDROID_NDK_ROOT has been set.
-
   Emulator: The class provides the methods to launch/shutdown the emulator with
             the android virtual device named 'avd_armeabi' .
 """
@@ -21,6 +19,7 @@ from pylib import android_commands
 from pylib import cmd_helper
 from pylib import constants
 from pylib import pexpect
+from pylib.device import device_utils
 from pylib.utils import time_profile
 
 import errors
@@ -108,7 +107,7 @@ def DeleteAllTempAVDs():
   If the test exits abnormally and some temporary AVDs created when testing may
   be left in the system. Clean these AVDs.
   """
-  avds = android_commands.GetAVDs()
+  avds = device_utils.GetAVDs()
   if not avds:
     return
   for avd_name in avds:
@@ -238,7 +237,7 @@ class Emulator(object):
     self.emulator = os.path.join(android_sdk_root, 'tools', 'emulator')
     self.android = os.path.join(android_sdk_root, 'tools', 'android')
     self.popen = None
-    self.device = None
+    self.device_serial = None
     self.abi = abi
     self.avd_name = avd_name
 
@@ -336,7 +335,7 @@ class Emulator(object):
     if kill_all_emulators:
       _KillAllEmulators()  # just to be sure
     self._AggressiveImageCleanup()
-    (self.device, port) = self._DeviceName()
+    (self.device_serial, port) = self._DeviceName()
     emulator_command = [
         self.emulator,
         # Speed up emulator launch by 40%.  Really.
@@ -395,7 +394,7 @@ class Emulator(object):
     """
     seconds_waited = 0
     number_of_waits = 2  # Make sure we can wfd twice
-    adb_cmd = "adb -s %s %s" % (self.device, 'wait-for-device')
+    adb_cmd = "adb -s %s %s" % (self.device_serial, 'wait-for-device')
     while seconds_waited < self._LAUNCH_TIMEOUT:
       try:
         run_command.RunCommand(adb_cmd,
@@ -406,7 +405,7 @@ class Emulator(object):
           break
       except errors.WaitForResponseTimedOutError:
         seconds_waited += self._WAITFORDEVICE_TIMEOUT
-        adb_cmd = "adb -s %s %s" % (self.device, 'kill-server')
+        adb_cmd = "adb -s %s %s" % (self.device_serial, 'kill-server')
         run_command.RunCommand(adb_cmd)
       self.popen.poll()
       if self.popen.returncode != None:
@@ -417,8 +416,8 @@ class Emulator(object):
     if wait_for_boot:
       # Now that we checked for obvious problems, wait for a boot complete.
       # Waiting for the package manager is sometimes problematic.
-      a = android_commands.AndroidCommands(self.device)
-      a.WaitForSystemBootCompleted(self._WAITFORBOOT_TIMEOUT)
+      d = device_utils.DeviceUtils(self.device_serial)
+      d.old_interface.WaitForSystemBootCompleted(self._WAITFORBOOT_TIMEOUT)
 
   def Shutdown(self):
     """Shuts down the process started by launch."""