def _RemoveDirectoryOnDevice(self, directory):
     """ Delete a directory on the device. """
     try:
         android_utils.RunADB(self._serial,
                              ['shell', 'rm', '-r', directory])
     except Exception:
         pass
     if self.DevicePathExists(directory):
         raise Exception('Failed to remove %s' % directory)
 def Install(self):
     """ Install the Skia executables. """
     if self._has_root:
         android_utils.RunADB(self._serial, ['root'])
         android_utils.RunADB(self._serial, ['remount'])
         # As an experiment, don't change CPU scaling mode.
         #android_utils.SetCPUScalingMode(self._serial, 'performance')
         try:
             android_utils.ADBKill(self._serial, 'skia')
         except Exception:
             # If we fail to kill the process, try rebooting the device, and wait for
             # it to come back up.
             shell_utils.run(
                 [android_utils.PATH_TO_ADB, '-s', self._serial, 'reboot'])
             time.sleep(60)
         android_utils.StopShell(self._serial)
     else:
         android_utils.ADBKill(self._serial, 'com.skia', kill_app=True)
 def CopyDirectoryContentsToHost(self, device_dir, host_dir):
     """ Copy the contents of a device-side directory to a clean directory on the
 host side.
 """
     self.CreateCleanHostDirectory(host_dir)
     android_utils.RunADB(self._serial, ['pull', device_dir, host_dir])
 def PushFileToDevice(self, src, dst):
     """ Overrides build_step.PushFileToDevice() """
     android_utils.RunADB(self._serial, ['push', src, dst])
 def _CreateDirectoryOnDevice(self, directory):
     """ Create a directory on the device. """
     android_utils.RunADB(self._serial, ['shell', 'mkdir', '-p', directory])