示例#1
0
 def _copy_image(src_path):
     from qt4a.androiddriver.util import get_file_md5
     if six.PY2 and not isinstance(src_path, unicode): src_path = src_path.decode('utf8')
     file_ext = os.path.splitext(src_path)[-1]
     dst_path = '/sdcard/dcim/%s%s' % (get_file_md5(src_path), file_ext)
     self.push_file(src_path, dst_path)
     return dst_path
示例#2
0
 def play_sound(self, file_path, volume=50):
     '''播放语音
     
     :param file_path: 音频文件路径
     :type  file_path: string
     '''
     from qt4a.androiddriver.util import get_file_md5
     self.set_volume(volume)  # 先设置音量
     file_ext = os.path.splitext(file_path)[-1]
     dst_path = '/data/local/tmp/%s%s' % (get_file_md5(file_path), file_ext)
     self.push_file(file_path, dst_path)
     return self._device_driver.play_sound(dst_path)
示例#3
0
 def install_package(self, pkg_path, overwrite=False):
     '''安装应用
     '''
     from qt4a.androiddriver.util import get_file_md5
     if not os.path.exists(pkg_path):
         raise RuntimeError('APK: %r not exist' % pkg_path)
     
     pkg_size = os.path.getsize(pkg_path)
     pkg_md5 = get_file_md5(pkg_path)
     pkg_name = ADB._get_package_name(pkg_path)
     if self.is_package_installed(pkg_name, pkg_size, pkg_md5):
         logger.info('APP %s [%d]%s is installed' % (pkg_name, pkg_size, pkg_md5))
         return True
     
     self.adb.install_apk(pkg_path, overwrite)
     return True