Coder Social home page Coder Social logo

uiautomator2's Introduction

uiautomator2

PyPI PyPI codecov

QQ交流群: 815453846 Discord: https://discord.gg/PbJhnZJKDd

有段时间没有维护这个项目了(可能有两年了),但是最近工作需要又重新研究一下Android原生自动化,当然又调研了Appium,对比下来一看,发现uiautomator2这个项目的运行速度是真的好快,从检测元素到点击,都是毫秒级的,代码也比较好理解。真是没想到以前竟然写出了这么神奇的项目,这么好的项目怎么能让它落灰呢,得好好整一整,一些垃圾代码清理清理。所以项目版本从2.x.x升级到了3.x.x

还在用2.x.x版本的用户,可以先看一下2to3 再决定是否要升级3.x.x (我个人还是非常建议升级的)

2到3毕竟是大版本升级,很多的函数删掉了。首先删掉的就是atx-agent,其次还有一堆atx-agent相关的函数。废弃的功能比如init.

各种依赖库的版本号

  • PyPI
  • PyPI
  • GitHub tag (latest SemVer)
  • GitHub tag (latest SemVer)

UiAutomator是Google提供的用来做安卓自动化测试的一个Java库,基于Accessibility服务。功能很强,可以对第三方App进行测试,获取屏幕上任意一个APP的任意一个控件属性,并对其进行任意操作,但有两个缺点:1. 测试脚本只能使用Java语言 2. 测试脚本要打包成jar或者apk包上传到设备上才能运行。

我们希望测试逻辑能够用Python编写,能够在电脑上运行的时候就控制手机。这里要非常感谢 Xiaocong He (@xiaocong),他将这个想法实现了出来(见xiaocong/uiautomator),原理是在手机上运行了一个http rpc服务,将uiautomator中的功能开放出来,然后再将这些http接口封装成Python库。 因为xiaocong/uiautomator这个库,已经很久不见更新。所以我们直接fork了一个版本,为了方便做区分我们就在后面加了个2 openatx/uiautomator2,对应的Android包源码我也fork了一份,openatx/android-uiautomator-server

除了对原有的库的bug进行了修复,还增加了很多新的Feature。主要有以下部分:

  • 设备和开发机可以脱离数据线,通过WiFi互联(基于atx-agent
  • 集成了openstf/minicap达到实时屏幕投频,以及实时截图
  • 集成了openstf/minitouch达到精确实时控制设备
  • 修复了xiaocong/uiautomator经常性退出的问题
  • 代码进行了重构和精简,方便维护
  • 实现了一个设备管理平台(也支持iOS) atxserver2 (注:目前不怎么维护了)
  • 扩充了toast获取和展示的功能(需要手动开启ATX的悬浮窗权限) 貌似有bug用不了

这里要先说明下,因为经常有很多人问 openatx/uiautomator2 并不支持iOS测试,需要iOS自动化测试,可以转到这个库 openatx/facebook-wda

PS: 这个库 https://github.com/NeteaseGame/ATX 目前已经不维护了,请尽快更换。

这里有一份快速参考,适合已经入门的人 QUICK REFERENCE GUIDE,欢迎多提意见。

Requirements

  • Android版本 4.4+
  • Python 3.8+

QUICK START

先准备一台(不要两台)开启了开发者选项的安卓手机,连接上电脑,确保执行adb devices可以看到连接上的设备。

运行pip3 install -U uiautomator2 安装uiautomator2

命令行运行python打开python交互窗口。然后将下面的命令输入到窗口中。

import uiautomator2 as u2

d = u2.connect() # connect to device
print(d.info)

这时看到类似下面的输出,就可以正式开始用我们这个库了。因为这个库功能太多,后面还有很多的内容,需要慢慢去看 ....

{'currentPackageName': 'net.oneplus.launcher', 'displayHeight': 1920, 'displayRotation': 0, 'displaySizeDpX': 411, 'displaySizeDpY': 731, 'displayWidth': 1080, 'productName': 'OnePlus5', '
screenOn': True, 'sdkInt': 27, 'naturalOrientation': True}

另外为了保持稳定,还需要开启小黄车的悬浮窗权限。参考文章 py-uiautomator2通过悬浮窗让服务长时间可用

一般情况下都会成功,不过也可能会有意外。可以加QQ群反馈问题(群号在最上面),群里有很多大佬可以帮你解决问题。

Sponsors

Thank you to all our sponsors! ✨🍰✨

金牌赞助商(Gold Sponsor)

Empty

Article Recommended

优秀文章推荐 (欢迎QQ群里at我反馈)

相关项目

  • 基于adb协议与Android进行交互的库 adbutils
  • uiauto.dev 用于查看UI层级结构,类似于uiautomatorviewer(用于替代之前写的weditor),用于查看UI层级结构
  • 设备管理平台,设备多了就会用到 atxserver2 (寻找项目维护人员)
  • atx-agent 运行在设备上的驻守程序,go开发,用于保活设备上相关的服务
  • weditor 类似于uiautomatorviewer,专门为本项目开发的辅助编辑器(这个暂不维护了

Installation

Connect to a device

Command line

Global settings

App management

cheme)**

**[UI automation](#basic-api-usages)**
- **[Shell commands](#shell-commands)**
- **[Session](#session)**
- **[Retrieve the device info](#retrieve-the-device-info)**
- **[Key Events](#key-events)**
- **[Gesture interaction with the device](#gesture-interaction-with-the-device)**
- **[Screen-related](#screen-related)**
- **[Selector](#selector)**
- **[Watcher](#watcher)**
- **[Global settings](#global-settings)**
- **[Input method](#input-method)**
- **[Toast](#toast)**
- **[XPath](#xpath)**
- **[Screenrecord](#screenrecord)**
- **[Image match](#image-match) Removed**


**[Contributors](#contributors)**

**[LICENSE](#license)**


# Installation
1. Install uiautomator2

  ```bash
  pip install -U uiautomator2
  ```
  
  测试是否安装成功 `uiautomator2 --help`
  
2. UI Inspector

  ```bash
  pip install uiautodev
  # 启动
  uiauto.dev
  ```

  浏览器打开 https://uiauto.dev 查看当前设备的界面结构。

  **uiauto.dev**

  [uiauto.dev](https://github.com/codeskyblue/uiauto.dev) 是一个独立与uiautomator2之外的一个项目,用于查看图层结构的。属于旧版项目[weditor的重构版本](https://github.com/openatx/weditor),后续也许会收费(价格肯定物超所值),来支持当前这个项目继续维护下去。感兴趣的可以加群讨论(也包含提需求) QQ群 536481989

# Connect to a device
use serialno to connect device eg. `123456f` (seen from `adb devices`)

```python
import uiautomator2 as u2

d = u2.connect('123456f') # alias for u2.connect_usb('123456f')
print(d.info)

Serial can be passed through env-var ANDROID_SERIAL

# export ANDROID_SERIAL=123456f
d = u2.connect()

Command line

其中的$device_ip代表设备的ip地址

如需指定设备需要传入--serialpython3 -m uiautomator2 --serial bff1234 <SubCommand>, SubCommand为子命令(screenshot, current 等)

1.0.3 Added: python3 -m uiautomator2 equals to uiautomator2

  • screenshot: 截图

    $ uiautomator2 screenshot screenshot.jpg
  • current: 获取当前包名和activity

    $ uiautomator2 current
    {
        "package": "com.android.browser",
        "activity": "com.uc.browser.InnerUCMobile",
        "pid": 28478
    }
  • uninstall: Uninstall app

    $ uiautomator2 uninstall <package-name> # 卸载一个包
    $ uiautomator2 uninstall <package-name-1> <package-name-2> # 卸载多个包
    $ uiautomator2 uninstall --all # 全部卸载
  • stop: Stop app

    $ uiautomator2 stop com.example.app # 停止一个app
    $ uiautomator2 stop --all # 停止所有的app
  • doctor:

    $ uiautomator2 doctor
    [I 2024-04-25 19:53:36,288 __main__:101 pid:15596] uiautomator2 is OK

API Documents

New command timeout (Removed)

When python quit, the UiAutomation service also quit.

Debug HTTP requests

打印出代码背后的HTTP请求信息

>>> d.debug = True
>>> d.info
12:32:47.182 $ curl -X POST -d '{"jsonrpc": "2.0", "id": "b80d3a488580be1f3e9cb3e926175310", "method": "deviceInfo", "params": {}}' 'http://127.0.0.1:54179/jsonrpc/0'
12:32:47.225 Response >>>
{"jsonrpc":"2.0","id":"b80d3a488580be1f3e9cb3e926175310","result":{"currentPackageName":"com.android.mms","displayHeight":1920,"displayRotation":0,"displaySizeDpX":360,"displaySizeDpY":640,"displayWidth":1080,"productName"
:"odin","screenOn":true,"sdkInt":25,"naturalOrientation":true}}
<<< END

Implicit wait

设置元素查找等待时间(默认20s)

d.implicitly_wait(10.0) # 也可以通过d.settings['wait_timeout'] = 10.0 修改
d(text="Settings").click() # if Settings button not show in 10s, UiObjectNotFoundError will raised

print("wait timeout", d.implicitly_wait()) # get default implicit wait

This function will have influence on click, long_click, drag_to, get_text, set_text, clear_text, etc.

App management

This part showcases how to perform app management

Install an app

We only support installing an APK from a URL

d.app_install('http://some-domain.com/some.apk')

Launch an app

# 默认的这种方法是先通过atx-agent解析apk包的mainActivity,然后调用am start -n $package/$activity启动
d.app_start("com.example.hello_world")

# 使用 monkey -p com.example.hello_world -c android.intent.category.LAUNCHER 1 启动
# 这种方法有个副作用,它自动会将手机的旋转锁定给关掉
d.app_start("com.example.hello_world", use_monkey=True) # start with package name

# 通过指定main activity的方式启动应用,等价于调用am start -n com.example.hello_world/.MainActivity
d.app_start("com.example.hello_world", ".MainActivity")

Stop an app

# equivalent to `am force-stop`, thus you could lose data
d.app_stop("com.example.hello_world") 
# equivalent to `pm clear`
d.app_clear('com.example.hello_world')

Stop all running apps

# stop all
d.app_stop_all()
# stop all app except for com.examples.demo
d.app_stop_all(excludes=['com.examples.demo'])

Get app info

d.app_info("com.examples.demo")
# expect output
#{
#    "mainActivity": "com.github.uiautomator.MainActivity",
#    "label": "ATX",
#    "versionName": "1.1.7",
#    "versionCode": 1001007,
#    "size":1760809
#}

# save app icon
img = d.app_icon("com.examples.demo")
img.save("icon.png")

List all running apps

d.app_list_running()
# expect output
# ["com.xxxx.xxxx", "com.github.uiautomator", "xxxx"]

Wait until app running

pid = d.app_wait("com.example.android") # 等待应用运行, return pid(int)
if not pid:
    print("com.example.android is not running")
else:
    print("com.example.android pid is %d" % pid)

d.app_wait("com.example.android", front=True) # 等待应用前台运行
d.app_wait("com.example.android", timeout=20.0) # 最长等待时间20s(默认)

Added in version 1.2.0

Push and pull files

  • push a file to the device

    # push to a folder
    d.push("foo.txt", "/sdcard/")
    # push and rename
    d.push("foo.txt", "/sdcard/bar.txt")
    # push fileobj
    with open("foo.txt", 'rb') as f:
        d.push(f, "/sdcard/")
    # push and change file access mode
    d.push("foo.sh", "/data/local/tmp/", mode=0o755)
  • pull a file from the device

    d.pull("/sdcard/tmp.txt", "tmp.txt")
    
    # FileNotFoundError will raise if the file is not found on the device
    d.pull("/sdcard/some-file-not-exists.txt", "tmp.txt")

Other app operations

# grant all the permissions
d.app_auto_grant_permissions("io.appium.android.apis")

# open scheme
d.open_url("appname://appnamehost")
# same as
# adb shell am start -a android.intent.action.VIEW -d "appname://appnamehost"

Basic API Usages

This part showcases how to perform common device operations:

Shell commands

  • Run a short-lived shell command with a timeout protection. (Default timeout 60s)

    Note: timeout support require atx-agent >=0.3.3

    adb_shell function is deprecated. Use shell instead.

    Simple usage

    output, exit_code = d.shell("pwd", timeout=60) # timeout 60s (Default)
    # output: "/\n", exit_code: 0
    # Similar to command: adb shell pwd
    
    # Since `shell` function return type is `namedtuple("ShellResponse", ("output", "exit_code"))`
    # so we can do some tricks
    output = d.shell("pwd").output
    exit_code = d.shell("pwd").exit_code

    The first argument can be list. for example

    output, exit_code = d.shell(["ls", "-l"])
    # output: "/....", exit_code: 0

    This returns a string for stdout merged with stderr. If the command is a blocking command, shell will also block until the command is completed or the timeout kicks in. No partial output will be received during the execution of the command. This API is not suitable for long-running commands. The shell command given runs in a similar environment of adb shell, which has a Linux permission level of adb or shell (higher than an app permission).

  • Run a long-running shell command (Removed)

Session

Session represent an app lifecycle. Can be used to start app, detect app crash.

  • Launch and close app

    sess = d.session("com.netease.cloudmusic") # start 网易云音乐
    sess.close() # 停止网易云音乐
    sess.restart() # 冷启动网易云音乐
  • Use python with to launch and close app

    with d.session("com.netease.cloudmusic") as sess:
        sess(text="Play").click()
  • Attach to the running app

    # launch app if not running, skip launch if already running
    sess = d.session("com.netease.cloudmusic", attach=True)
  • Detect app crash

    # When app is still running
    sess(text="Music").click() # operation goes normal
    
    # If app crash or quit
    sess(text="Music").click() # raise SessionBrokenError
    # other function calls under session will raise SessionBrokenError too
    # check if session is ok.
    # Warning: function name may change in the future
    sess.running() # True or False

Retrieve the device info

Get basic information

d.info

Below is a possible output:

{'currentPackageName': 'com.android.systemui',
 'displayHeight': 1560,
 'displayRotation': 0,
 'displaySizeDpX': 360,
 'displaySizeDpY': 780,
 'displayWidth': 720,
 'naturalOrientation': True,
 'productName': 'ELE-AL00',
 'screenOn': True,
 'sdkInt': 29}

Get window size

print(d.window_size())
# device upright output example: (1080, 1920)
# device horizontal output example: (1920, 1080)

Get current app info. For some android devices, the output could be empty (see Output example 3)

print(d.app_current())
# Output example 1: {'activity': '.Client', 'package': 'com.netease.example', 'pid': 23710}
# Output example 2: {'activity': '.Client', 'package': 'com.netease.example'}
# Output example 3: {'activity': None, 'package': None}

Wait activity

d.wait_activity(".ApiDemos", timeout=10) # default timeout 10.0 seconds
# Output: true of false

Get device serial number

print(d.serial)
# output example: 74aAEDR428Z9

Get WLAN ip

print(d.wlan_ip)
# output example: 10.0.0.1 or None

Get detailed device info d.device_info

device_info

print(d.device_info)

Below is a possible output:

{'arch': 'arm64-v8a',
 'brand': 'google',
 'model': 'sdk_gphone64_arm64',
 'sdk': 34,
 'serial': 'EMULATOR34X1X19X0',
 'version': 14}

Clipboard

Get of set clipboard content

设置粘贴板内容或获取内容

  • clipboard/set_clipboard

    d.clipboard = 'hello-world'
    # or
    d.set_clipboard('hello-world', 'label')

Get clipboard content

get clipboard requires IME(com.github.uiautomator/.AdbKeyboard) call d.set_input_ime() before using it.

```python

# get clipboard content
print(d.clipboard)
```

Key Events

  • Turn on/off screen

    d.screen_on() # turn on the screen
    d.screen_off() # turn off the screen
  • Get current screen status

    d.info.get('screenOn') # require Android >= 4.4
  • Press hard/soft key

    d.press("home") # press the home key, with key name
    d.press("back") # press the back key, with key name
    d.press(0x07, 0x02) # press keycode 0x07('0') with META ALT(0x02)
  • These key names are currently supported:

    • home
    • back
    • left
    • right
    • up
    • down
    • center
    • menu
    • search
    • enter
    • delete ( or del)
    • recent (recent apps)
    • volume_up
    • volume_down
    • volume_mute
    • camera
    • power

You can find all key code definitions at Android KeyEvnet

  • Unlock screen

    d.unlock()
    # This is equivalent to
    # 1. press("power")
    # 2. swipe from left-bottom to right-top

Gesture interaction with the device

  • Click on the screen

    d.click(x, y)
  • Double click

    d.double_click(x, y)
    d.double_click(x, y, 0.1) # default duration between two click is 0.1s
  • Long click on the screen

    d.long_click(x, y)
    d.long_click(x, y, 0.5) # long click 0.5s (default)
  • Swipe

    d.swipe(sx, sy, ex, ey)
    d.swipe(sx, sy, ex, ey, 0.5) # swipe for 0.5s(default)
  • SwipeExt 扩展功能

    d.swipe_ext("right") # 手指右滑,4选1 "left", "right", "up", "down"
    d.swipe_ext("right", scale=0.9) # 默认0.9, 滑动距离为屏幕宽度的90%
    d.swipe_ext("right", box=(0, 0, 100, 100)) # 在 (0,0) -> (100, 100) 这个区域做滑动
    
    # 实践发现上滑或下滑的时候,从中点开始滑动成功率会高一些
    d.swipe_ext("up", scale=0.8) # 代码会vkk
    
    # 还可以使用Direction作为参数
    from uiautomator2 import Direction
    
    d.swipe_ext(Direction.FORWARD) # 页面下翻, 等价于 d.swipe_ext("up"), 只是更好理解
    d.swipe_ext(Direction.BACKWARD) # 页面上翻
    d.swipe_ext(Direction.HORIZ_FORWARD) # 页面水平右翻
    d.swipe_ext(Direction.HORIZ_BACKWARD) # 页面水平左翻
  • Drag

    d.drag(sx, sy, ex, ey)
    d.drag(sx, sy, ex, ey, 0.5) # swipe for 0.5s(default)
  • Swipe points

    # swipe from point(x0, y0) to point(x1, y1) then to point(x2, y2)
    # time will speed 0.2s bwtween two points
    d.swipe_points([(x0, y0), (x1, y1), (x2, y2)], 0.2))

    多用于九宫格解锁,提前获取到每个点的相对坐标(这里支持百分比), 更详细的使用参考这个帖子 使用u2实现九宫图案解锁

  • Touch and drap (Beta)

    这个接口属于比较底层的原始接口,感觉并不完善,不过凑合能用。注:这个地方并不支持百分比

    d.touch.down(10, 10) # 模拟按下
    time.sleep(.01) # down 和 move 之间的延迟,自己控制
    d.touch.move(15, 15) # 模拟移动
    d.touch.up(10, 10) # 模拟抬起

Note: click, swipe, drag operations support percentage position values. Example:

d.long_click(0.5, 0.5) means long click center of screen

Screen-related

  • Retrieve/Set device orientation

    The possible orientations:

    • natural or n
    • left or l
    • right or r
    • upsidedown or u (can not be set)
    # retrieve orientation. the output could be "natural" or "left" or "right" or "upsidedown"
    orientation = d.orientation
    
    # WARNING: not pass testing in my TT-M1
    # set orientation and freeze rotation.
    # notes: setting "upsidedown" requires Android>=4.3.
    d.set_orientation('l') # or "left"
    d.set_orientation("l") # or "left"
    d.set_orientation("r") # or "right"
    d.set_orientation("n") # or "natural"
  • Freeze/Un-freeze rotation

    # freeze rotation
    d.freeze_rotation()
    # un-freeze rotation
    d.freeze_rotation(False)
  • Take screenshot

    # take screenshot and save to a file on the computer, require Android>=4.2.
    d.screenshot("home.jpg")
    
    # get PIL.Image formatted images. Naturally, you need pillow installed first
    image = d.screenshot() # default format="pillow"
    image.save("home.jpg") # or home.png. Currently, only png and jpg are supported
    
    # get opencv formatted images. Naturally, you need numpy and cv2 installed first
    import cv2
    image = d.screenshot(format='opencv')
    cv2.imwrite('home.jpg', image)
    
    # get raw jpeg data
    imagebin = d.screenshot(format='raw')
    open("some.jpg", "wb").write(imagebin)
  • Dump UI hierarchy

    # get the UI hierarchy dump content
    xml = d.dump_hierarchy()
    
    # compressed=True: include not import nodes
    # pretty: format xml
    # max_depth: limit xml depth, default 50
    xml = d.dump_hierarchy(compressed=False, pretty=False, max_depth=50)
  • Open notification or quick settings

    d.open_notification()
    d.open_quick_settings()

Selector

Selector is a handy mechanism to identify a specific UI object in the current window.

# Select the object with text 'Clock' and its className is 'android.widget.TextView'
d(text='Clock', className='android.widget.TextView')

Selector supports below parameters. Refer to UiSelector Java doc for detailed information.

  • text, textContains, textMatches, textStartsWith
  • className, classNameMatches
  • description, descriptionContains, descriptionMatches, descriptionStartsWith
  • checkable, checked, clickable, longClickable
  • scrollable, enabled,focusable, focused, selected
  • packageName, packageNameMatches
  • resourceId, resourceIdMatches
  • index, instance

Children and siblings

  • children

    # get the children or grandchildren
    d(className="android.widget.ListView").child(text="Bluetooth")
  • siblings

    # get siblings
    d(text="Google").sibling(className="android.widget.ImageView")
  • children by text or description or instance

    # get the child matching the condition className="android.widget.LinearLayout"
    # and also its children or grandchildren with text "Bluetooth"
    d(className="android.widget.ListView", resourceId="android:id/list") \
     .child_by_text("Bluetooth", className="android.widget.LinearLayout")
    
    # get children by allowing scroll search
    d(className="android.widget.ListView", resourceId="android:id/list") \
     .child_by_text(
        "Bluetooth",
        allow_scroll_search=True,
        className="android.widget.LinearLayout"
      )
    • child_by_description is to find children whose grandchildren have the specified description, other parameters being similar to child_by_text.

    • child_by_instance is to find children with has a child UI element anywhere within its sub hierarchy that is at the instance specified. It is performed on visible views without scrolling.

    See below links for detailed information:

    • UiScrollable, getChildByDescription, getChildByText, getChildByInstance
    • UiCollection, getChildByDescription, getChildByText, getChildByInstance

    Above methods support chained invoking, e.g. for below hierarchy

    <node index="0" text="" resource-id="android:id/list" class="android.widget.ListView" ...>
      <node index="0" text="WIRELESS & NETWORKS" resource-id="" class="android.widget.TextView" .../>
      <node index="1" text="" resource-id="" class="android.widget.LinearLayout" ...>
        <node index="1" text="" resource-id="" class="android.widget.RelativeLayout" ...>
          <node index="0" text="Wi‑Fi" resource-id="android:id/title" class="android.widget.TextView" .../>
        </node>
        <node index="2" text="ON" resource-id="com.android.settings:id/switchWidget" class="android.widget.Switch" .../>
      </node>
      ...
    </node>

    settings

    To click the switch widget right to the TextView 'Wi‑Fi', we need to select the switch widgets first. However, according to the UI hierarchy, more than one switch widgets exist and have almost the same properties. Selecting by className will not work. Alternatively, the below selecting strategy would help:

    d(className="android.widget.ListView", resourceId="android:id/list") \
      .child_by_text("Wi‑Fi", className="android.widget.LinearLayout") \
      .child(className="android.widget.Switch") \
      .click()
  • relative positioning

    Also we can use the relative positioning methods to get the view: left, right, top, bottom.

    • d(A).left(B), selects B on the left side of A.
    • d(A).right(B), selects B on the right side of A.
    • d(A).up(B), selects B above A.
    • d(A).down(B), selects B under A.

    So for above cases, we can alternatively select it with:

    ## select "switch" on the right side of "Wi‑Fi"
    d(text="Wi‑Fi").right(className="android.widget.Switch").click()
  • Multiple instances

    Sometimes the screen may contain multiple views with the same properties, e.g. text, then you will have to use the "instance" property in the selector to pick one of qualifying instances, like below:

    d(text="Add new", instance=0)  # which means the first instance with text "Add new"

    In addition, uiautomator2 provides a list-like API (similar to jQuery):

    # get the count of views with text "Add new" on current screen
    d(text="Add new").count
    
    # same as count property
    len(d(text="Add new"))
    
    # get the instance via index
    d(text="Add new")[0]
    d(text="Add new")[1]
    ...
    
    # iterator
    for view in d(text="Add new"):
        view.info  # ...

    Notes: when using selectors in a code block that walk through the result list, you must ensure that the UI elements on the screen keep unchanged. Otherwise, when Element-Not-Found error could occur when iterating through the list.

Get the selected ui object status and its information

  • Check if the specific UI object exists

    d(text="Settings").exists # True if exists, else False
    d.exists(text="Settings") # alias of above property.
    
    # advanced usage
    d(text="Settings").exists(timeout=3) # wait Settings appear in 3s, same as .wait(3)
  • Retrieve the info of the specific UI object

    d(text="Settings").info

    Below is a possible output:

    { u'contentDescription': u'',
    u'checked': False,
    u'scrollable': False,
    u'text': u'Settings',
    u'packageName': u'com.android.launcher',
    u'selected': False,
    u'enabled': True,
    u'bounds': {u'top': 385,
                u'right': 360,
                u'bottom': 585,
                u'left': 200},
    u'className': u'android.widget.TextView',
    u'focused': False,
    u'focusable': True,
    u'clickable': True,
    u'chileCount': 0,
    u'longClickable': True,
    u'visibleBounds': {u'top': 385,
                        u'right': 360,
                        u'bottom': 585,
                        u'left': 200},
    u'checkable': False
    }
    
  • Get/Set/Clear text of an editable field (e.g., EditText widgets)

    d(text="Settings").get_text()  # get widget text
    d(text="Settings").set_text("My text...")  # set the text
    d(text="Settings").clear_text()  # clear the text
  • Get Widget center point

    x, y = d(text="Settings").center()
    # x, y = d(text="Settings").center(offset=(0, 0)) # left-top x, y
  • Take screenshot of widget

    im = d(text="Settings").screenshot()
    im.save("settings.jpg")

Perform the click action on the selected UI object

  • Perform click on the specific object

    # click on the center of the specific ui object
    d(text="Settings").click()
    
    # wait element to appear for at most 10 seconds and then click
    d(text="Settings").click(timeout=10)
    
    # click with offset(x_offset, y_offset)
    # click_x = x_offset * width + x_left_top
    # click_y = y_offset * height + y_left_top
    d(text="Settings").click(offset=(0.5, 0.5)) # Default center
    d(text="Settings").click(offset=(0, 0)) # click left-top
    d(text="Settings").click(offset=(1, 1)) # click right-bottom
    
    # click when exists in 10s, default timeout 0s
    clicked = d(text='Skip').click_exists(timeout=10.0)
    
    # click until element gone, return bool
    is_gone = d(text="Skip").click_gone(maxretry=10, interval=1.0) # maxretry default 10, interval default 1.0
  • Perform long click on the specific UI object

    # long click on the center of the specific UI object
    d(text="Settings").long_click()

Gesture actions for the specific UI object

  • Drag the UI object towards another point or another UI object

    # notes : drag can not be used for Android<4.3.
    # drag the UI object to a screen point (x, y), in 0.5 second
    d(text="Settings").drag_to(x, y, duration=0.5)
    # drag the UI object to (the center position of) another UI object, in 0.25 second
    d(text="Settings").drag_to(text="Clock", duration=0.25)
  • Swipe from the center of the UI object to its edge

    Swipe supports 4 directions:

    • left
    • right
    • top
    • bottom
    d(text="Settings").swipe("right")
    d(text="Settings").swipe("left", steps=10)
    d(text="Settings").swipe("up", steps=20) # 1 steps is about 5ms, so 20 steps is about 0.1s
    d(text="Settings").swipe("down", steps=20)
  • Two-point gesture from one point to another

    d(text="Settings").gesture((sx1, sy1), (sx2, sy2), (ex1, ey1), (ex2, ey2))
  • Two-point gesture on the specific UI object

    Supports two gestures:

    • In, from edge to center
    • Out, from center to edge
    # notes : pinch can not be set until Android 4.3.
    # from edge to center. here is "In" not "in"
    d(text="Settings").pinch_in(percent=100, steps=10)
    # from center to edge
    d(text="Settings").pinch_out()
  • Wait until the specific UI appears or disappears

    # wait until the ui object appears
    d(text="Settings").wait(timeout=3.0) # return bool
    # wait until the ui object gone
    d(text="Settings").wait_gone(timeout=1.0)

    The default timeout is 20s. see global settings for more details

  • Perform fling on the specific ui object(scrollable)

    Possible properties:

    • horiz or vert
    • forward or backward or toBeginning or toEnd
    # fling forward(default) vertically(default) 
    d(scrollable=True).fling()
    # fling forward horizontally
    d(scrollable=True).fling.horiz.forward()
    # fling backward vertically
    d(scrollable=True).fling.vert.backward()
    # fling to beginning horizontally
    d(scrollable=True).fling.horiz.toBeginning(max_swipes=1000)
    # fling to end vertically
    d(scrollable=True).fling.toEnd()
  • Perform scroll on the specific ui object(scrollable)

    Possible properties:

    • horiz or vert
    • forward or backward or toBeginning or toEnd, or to
    # scroll forward(default) vertically(default)
    d(scrollable=True).scroll(steps=10)
    # scroll forward horizontally
    d(scrollable=True).scroll.horiz.forward(steps=100)
    # scroll backward vertically
    d(scrollable=True).scroll.vert.backward()
    # scroll to beginning horizontally
    d(scrollable=True).scroll.horiz.toBeginning(steps=100, max_swipes=1000)
    # scroll to end vertically
    d(scrollable=True).scroll.toEnd()
    # scroll forward vertically until specific ui object appears
    d(scrollable=True).scroll.to(text="Security")

WatchContext

目前的这个watch_context是用threading启动的,每2s检查一次 目前还只有click这一种触发操作

with d.watch_context() as ctx:
    # 当同时出现 (立即下载 或 立即更新)和 取消 按钮的时候,点击取消
    ctx.when("^立即(下载|更新)").when("取消").click() 
    ctx.when("同意").click()
    ctx.when("确定").click()
    # 上面三行代码是立即执行完的,不会有什么等待
    
    ctx.wait_stable() # 开启弹窗监控,并等待界面稳定(两个弹窗检查周期内没有弹窗代表稳定)

    # 使用call函数来触发函数回调
    # call 支持两个参数,d和el,不区分参数位置,可以不传参,如果传参变量名不能写错
    # eg: 当有元素匹配仲夏之夜,点击返回按钮
    ctx.when("仲夏之夜").call(lambda d: d.press("back"))
    ctx.when("确定").call(lambda el: el.click())

    # 其他操作

# 为了方便也可以使用代码中默认的弹窗监控逻辑
# 下面是目前内置的默认逻辑,可以加群at群主,增加新的逻辑,或者直接提pr
    # when("继续使用").click()
    # when("移入管控").when("取消").click()
    # when("^立即(下载|更新)").when("取消").click()
    # when("同意").click()
    # when("^(好的|确定)").click()
with d.watch_context(builtin=True) as ctx:
    # 在已有的基础上增加
    ctx.when("@tb:id/jview_view").when('//*[@content-desc="图片"]').click()

    # 其他脚本逻辑

另外一种写法

ctx = d.watch_context()
ctx.when("设置").click()
ctx.wait_stable() # 等待界面不在有弹窗了

ctx.close()

Watcher

更推荐用WatchContext 写法更简洁一些

You can register watchers to perform some actions when a selector does not find a match.

2.0.0之前使用的是 uiautomator-jar库中提供的[Watcher]((http://developer.android.com/tools/help/uiautomator/UiWatcher.html)方法,但在实践中发现一旦uiautomator连接失败重启了,所有的watcher配置都是丢失,这肯定是无法接受的。

所以目前采用了后台运行了一个线程的方法(依赖threading库),然后每隔一段时间dump一次hierarchy,匹配到元素之后执行相应的操作。

用法举例

注册监控

# 常用写法,注册匿名监控
d.watcher.when("安装").click()

# 注册名为ANR的监控,当出现ANR和Force Close时,点击Force Close
d.watcher("ANR").when(xpath="ANR").when("Force Close").click()

# 其他回调例子
d.watcher.when("抢红包").press("back")
d.watcher.when("//*[@text = 'Out of memory']").call(lambda d: d.shell('am force-stop com.im.qq'))

# 回调说明
def click_callback(d: u2.Device):
    d.xpath("确定").click() # 在回调中调用不会再次触发watcher

d.xpath("继续").click() # 使用d.xpath检查元素的时候,会触发watcher(目前最多触发5次)

# 开始后台监控
d.watcher.start()

监控操作

# 移除ANR的监控
d.watcher.remove("ANR")

# 移除所有的监控
d.watcher.remove()

# 开始后台监控
d.watcher.start()
d.watcher.start(2.0) # 默认监控间隔2.0s

# 强制运行所有监控
d.watcher.run()

# 停止监控
d.watcher.stop()

# 停止并移除所有的监控,常用于初始化
d.watcher.reset()

另外文档还是有很多没有写,推荐直接去看源码watcher.py

Global settings

u2.HTTP_TIMEOUT = 60 # 默认值60s, http默认请求超时时间

其他的配置,目前已大部分集中到 d.settings 中,根据后期的需求配置可能会有增减。

print(d.settings)
{'operation_delay': (0, 0),
 'operation_delay_methods': ['click', 'swipe'],
 'wait_timeout': 20.0}

# 配置点击前延时0.5s,点击后延时1s
d.settings['operation_delay'] = (.5, 1)

# 修改延迟生效的方法
# 其中 double_click, long_click 都对应click
d.settings['operation_delay_methods'] = ['click', 'swipe', 'drag', 'press']
d.settings['wait_timeout'] = 20.0 # 默认控件等待时间(原生操作,xpath插件的等待时间)

d.settings['max_depth'] = 50 # 默认50,限制dump_hierarchy返回的元素层级

对于随着版本升级,设置过期的配置时,会提示Deprecated,但是不会抛异常。

>>> d.settings['click_before_delay'] = 1  
[W 200514 14:55:59 settings:72] d.settings[click_before_delay] deprecated: Use operation_delay instead

uiautomator恢复方式设置

细心的你可能发现,实际上手机安装了两个APK,一个在前台可见(小黄车)。一个包名为com.github.uiautomator.test在后台不可见。这两个apk使用同一个证书签名的。 不可见的应用实际上是一个测试包,包含有所有的测试代码,核心的测试服务也是通过其启动的。 但是运行的时候,系统却需要那个小黄车一直在运行(在后台运行也可以)。一旦小黄车应用被杀,后台运行的测试服务也很快的会被杀掉。就算什么也不做,应用应用在后台,也会很快被系统回收掉。(这里希望高手指点一下,如何才能不依赖小黄车应用,感觉理论上是可以的,但是目前我还不会)。

让小黄车在后台运行有两种方式,一种启动应用后,放到后台(默认)。另外通过am startservice启动一个后台服务也行。

通过 d.settings["uiautomator_runtest_app_background"] = True 可以调整该行为。True代表启动应用,False代表启动服务。

UiAutomator中的超时设置(隐藏方法)

>> d.jsonrpc.getConfigurator() 
{'actionAcknowledgmentTimeout': 500,
 'keyInjectionDelay': 0,
 'scrollAcknowledgmentTimeout': 200,
 'waitForIdleTimeout': 0,
 'waitForSelectorTimeout': 0}

>> d.jsonrpc.setConfigurator({"waitForIdleTimeout": 100})
{'actionAcknowledgmentTimeout': 500,
 'keyInjectionDelay': 0,
 'scrollAcknowledgmentTimeout': 200,
 'waitForIdleTimeout': 100,
 'waitForSelectorTimeout': 0}

为了防止客户端程序响应超时,waitForIdleTimeoutwaitForSelectorTimeout目前已改为0

Refs: Google uiautomator Configurator

Input method

这种方法通常用于不知道控件的情况下的输入。第一步需要切换输入法,然后发送adb广播命令,具体使用方法如下

d.send_keys("你好123abcEFG") # adb广播输入
d.send_keys("你好123abcEFG", clear=True) # adb广播输入

d.clear_text() # 清除输入框所有内容

d.send_action() # 根据输入框的需求,自动执行回车、搜索等指令, Added in version 3.1
# 也可以指定发送的输入法action, eg: d.send_action("search") 支持 go, search, send, next, done, previous
print(d.current_ime()) # 获取当前输入法ID

更多参考: IME_ACTION_CODE

Toast

print(d.last_toast) # get last toast, if not toast return None
d.clear_toast()

Fixed in version 3.2.0

XPath

Java uiautoamtor中默认是不支持xpath的,所以这里属于扩展的一个功能。速度不是这么的快。

For example: 其中一个节点的内容

<android.widget.TextView
  index="2"
  text="05:19"
  resource-id="com.netease.cloudmusic:id/qf"
  package="com.netease.cloudmusic"
  content-desc=""
  checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false"
  scrollable="false" long-clickable="false" password="false" selected="false" visible-to-user="true"
  bounds="[957,1602][1020,1636]" />

xpath定位和使用方法

有些属性的名字有修改需要注意

description -> content-desc
resourceId -> resource-id

常见用法

# wait exists 10s
d.xpath("//android.widget.TextView").wait(10.0)
# find and click
d.xpath("//*[@content-desc='分享']").click()
# check exists
if d.xpath("//android.widget.TextView[contains(@text, 'Se')]").exists:
    print("exists")
# get all text-view text, attrib and center point
for elem in d.xpath("//android.widget.TextView").all():
    print("Text:", elem.text)
    # Dictionary eg: 
    # {'index': '1', 'text': '999+', 'resource-id': 'com.netease.cloudmusic:id/qb', 'package': 'com.netease.cloudmusic', 'content-desc': '', 'checkable': 'false', 'checked': 'false', 'clickable': 'false', 'enabled': 'true', 'focusable': 'false', 'focused': 'false','scrollable': 'false', 'long-clickable': 'false', 'password': 'false', 'selected': 'false', 'visible-to-user': 'true', 'bounds': '[661,1444][718,1478]'}
    print("Attrib:", elem.attrib)
    # Coordinate eg: (100, 200)
    print("Position:", elem.center())

点击查看其他XPath常见用法

Screenrecord (Deprecated)

视频录制(废弃),使用scrcpy来代替吧

这里没有使用手机中自带的screenrecord命令,是通过获取手机图片合成视频的方法,所以需要安装一些其他的依赖,如imageio, imageio-ffmpeg, numpy等 因为有些依赖比较大,推荐使用镜像安装。直接运行下面的命令即可。

pip3 install -U "uiautomator2[image]" -i https://pypi.doubanio.com/simple

使用方法

d.screenrecord('output.mp4')

time.sleep(10)
# or do something else

d.screenrecord.stop() # 停止录制后,output.mp4文件才能打开

录制的时候也可以指定fps(当前是20),这个值是率低于minicap输出图片的速度,感觉已经很好了,不建议你修改。

Enable uiautomator2 logger

from uiautomator2 import enable_pretty_logging
enable_pretty_logging()

Or

logger = logging.getLogger("uiautomator2")
# setup logger

Stop UiAutomator

Python程序退出了,UiAutomation就退出了。 不过也可以通过接口的方法停止服务

d.stop_uiautomator()

Google UiAutomator 2.0和1.x的区别

https://www.cnblogs.com/insist8089/p/6898181.html

  • 新增接口:UiObject2、Until、By、BySelector
  • 引入方式:2.0中,com.android.uiautomator.core.* 引入方式被废弃。改为android.support.test.uiautomator
  • 构建系统:Maven 和/或 Ant(1.x);Gradle(2.0)
  • 产生的测试包的形式:从zip /jar(1.x) 到 apk(2.0)
  • 在本地环境以adb命令运行UIAutomator测试,启动方式的差别:
    adb shell uiautomator runtest UiTest.jar -c package.name.ClassName(1.x) adb shell am instrument -e class com.example.app.MyTest com.example.app.test/android.support.test.runner.AndroidJUnitRunner(2.0)
  • 能否使用Android服务及接口? 1.x不能;2.0能。
  • og输出? 使用System.out.print输出流回显至执行端(1.x); 输出至Logcat(2.0)
  • 执行?测试用例无需继承于任何父类,方法名不限,使用注解 Annotation进行(2.0); 需要继承UiAutomatorTestCase,测试方法需要以test开头(1.x)

依赖项目

Contributors

Other contributors

其他优秀的项目

排名有先后,欢迎补充

LICENSE

MIT

uiautomator2's People

Contributors

arthurlib avatar caofengbin avatar codeskyblue avatar diaojunxian avatar donglaip avatar edsion1107 avatar fengzhiyuanyi avatar finfou avatar gamesguru avatar jihun-im avatar lewis32 avatar liangqinwei avatar maguowei avatar mingyuan-xia avatar mqhuan avatar onesecurity avatar pengchenglin avatar qnner avatar rainy008 avatar smartmanoj avatar swind avatar twoyang0917 avatar uncleheart avatar vancheung avatar vgavro avatar wdschn avatar yaming116 avatar yinkh avatar zeros2619 avatar zhihongliuus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uiautomator2's Issues

设备调试完成后,几天后再连,连不上

requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.20.73', port=7912): Max retries exceeded with url: /ping (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd29b33ce50>: Failed to establish a new connection: [Errno 111] Connection refused',))
检查手机ip及应用,都有开启。为何连不上呢?

miui9设备端crash

手机型号为MI 6,MIUI 9.2系统,Android版本7.1.1,报错信息如下:

>>> import uiautomator2 as ui2
>>> d = ui2.connect('192.168.0.104')
>>> d.info
/home/smartguo/lib/anaconda3/lib/python3.6/site-packages/uiautomator2/__init__.py:325: RuntimeWarning: uiautomator2 is down, restart.
  warnings.warn("uiautomator2 is down, restart.", RuntimeWarning, stacklevel=1)
Traceback (most recent call last):
  File "/home/smartguo/lib/anaconda3/lib/python3.6/site-packages/uiautomator2/__init__.py", line 323, in jsonrpc_retry_call
    return self.jsonrpc_call(*args, **kwargs)
  File "/home/.../anaconda3/lib/python3.6/site-packages/uiautomator2/__init__.py", line 351, in jsonrpc_call
    raise GatewayError(res, "gateway error, time used %.1fs" % (time.time() - request_start))
uiautomator2.GatewayError: uiautomator2.GatewayError(gateway error, time used 0.1s)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/.../anaconda3/lib/python3.6/site-packages/uiautomator2/__init__.py", line 771, in __getattr__
    return getattr(self._default_session, attr)
  File "/home/..../anaconda3/lib/python3.6/site-packages/uiautomator2/__init__.py", line 1152, in info
    return self.jsonrpc.deviceInfo()
  File "/home/.../anaconda3/lib/python3.6/site-packages/uiautomator2/__init__.py", line 316, in __call__
    return self.server.jsonrpc_retry_call(jsonrpc_url, self.method, params, http_timeout)
  File "/home/smartguo/lib/anaconda3/lib/python3.6/site-packages/uiautomator2/__init__.py", line 327, in jsonrpc_retry_call
    self.healthcheck(unlock=False)
  File "/home/.../anaconda3/lib/python3.6/site-packages/uiautomator2/__init__.py", line 430, in healthcheck
    raise RuntimeError("Uiautomator started failed.")
RuntimeError: Uiautomator started failed.

安装如何获取安装信息?

app_install只返回了包名,没有返回类似 安装J:\apks\jzx\jzx_agent_103652_yyb_ysdk_dalan_177_1.9.2_20180118_16885.apk
pkg: /data/local/tmp/jzx_agent_103652_yyb_ysdk_dalan_177_1.9.2_20180118_16885.apk

Success
假如包有问题,不清楚为什么安装失败。

Uiautomator started failed

可以launch app,执行d.healthcheck() 出错
raise RuntimeError("Uiautomator started failed.")
RuntimeError: Uiautomator started failed.
其他click调用也都是出现这样错误

return self.server.jsonrpc_call(self.method, params, http_timeout)
File "c:\users\pt001\uiautomator2\uiautomator2_init_.py", line 255, in jsonrpc_call
raise UiaError(self._server_jsonrpc_url, data, res.status_code, res.text, "HTTP Return code is not 200", res.text)
uiautomator2.UiaError: ('http://192.168.8.196:7912/jsonrpc/0', b'{"jsonrpc": "2.0", "id": "edc204b38751966bd204eb69b067bd6f", "method": "deviceInfo", "params": {}}', 502, '', 'HTTP Return code is not 200', '')

监视器

监视器写好了,没反应。。
是不是要加上d.watchers.run(),还是说写好监视器,他就会直接运行,

2.0定位速度問題

把python uiautomator測試腳本改成� 2.0
原先為安卓6.0,如以下語法這樣原先1.0大概1~2秒定位
d(text="下一頁").click()
但安卓升級成7.0後
uiautomator也換成2.0定位時間居然會到5~6秒甚至更久,請問是什麼問題呢?

android 7.1.1 设备上无法点击中文文本(vivo X20)

操作:
d(text=u"数码家电").click()
错误信息:

Traceback (most recent call last):
File "C:\Python\Python35\lib\site-packages\weditor_main_.py", line 297, in post
ret = eval(code, {'d': d})
File "", line 1, in
File "C:\Python\Python35\lib\site-packages\uiautomator2_init_.py", line 1194, in inner
return fn(self, *args, **kwargs)
File "C:\Python\Python35\lib\site-packages\uiautomator2_init_.py", line 1237, in click
self.session.click(x, y)
File "C:\Python\Python35\lib\site-packages\uiautomator2_init_.py", line 972, in click
ret = self.jsonrpc.click(x, y)
File "C:\Python\Python35\lib\site-packages\uiautomator2_init_.py", line 322, in call
return self.server.jsonrpc_retry_call(jsonrpc_url, self.method, params, http_timeout)
File "C:\Python\Python35\lib\site-packages\uiautomator2_init_.py", line 329, in jsonrpc_retry_call
return self.jsonrpc_call(*args, **kwargs)
File "C:\Python\Python35\lib\site-packages\uiautomator2_init_.py", line 373, in jsonrpc_call
raise err
uiautomator2.JsonRpcError: -32001 Server error: java.lang.SecurityException
[Finished in 1.085s]

long_click长按,会有两次点击操作

sess(text=u"哈哈哈 哎呦呦").long_click()
sess(text=u"删除回复").click()

本来长按一个回复内容,弹出框,想点击“删除回复”。
但是实际效果:弹出框也弹了,但是又有一个点击操作,点击了回复内容,
使得页面跳到另外一个页面了。
sess(text=u"删除回复").click()就点击不到了。

目前不足的是?

目前还有那些不足, 我测试一下, 速度很快。 想知道还有那些不足.

感谢强大, 项目维护者.

初始化的时候安装minicap.so碰到ssl error 怎么破呢

samueldeiMac:jingpin vip$ python -m uiautomator2 init
2018-02-27 21:52:35,393 - main.py:250 - INFO - Device(3207da40) initialing ...
2018-02-27 21:52:35,746 - main.py:106 - DEBUG - install minicap.so
2018-02-27 21:52:35,747 - main.py:108 - INFO - https://github.com/codeskyblue/stf-binaries/raw/master/node_modules/minicap-prebuilt/prebuilt/armeabi-v7a/lib/android-23/minicap.so
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"main", fname, loader, pkg_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/Library/Python/2.7/site-packages/uiautomator2/main.py", line 310, in
main()
File "/Library/Python/2.7/site-packages/uiautomator2/main.py", line 306, in main
fire.Fire(MyFire)
File "/Library/Python/2.7/site-packages/fire/core.py", line 127, in Fire
component_trace = _Fire(component, args, context, name)
File "/Library/Python/2.7/site-packages/fire/core.py", line 366, in _Fire
component, remaining_args)
File "/Library/Python/2.7/site-packages/fire/core.py", line 542, in _CallCallable
result = fn(*varargs, **kwargs)
File "/Library/Python/2.7/site-packages/uiautomator2/main.py", line 253, in init
ins.install_minicap()
File "/Library/Python/2.7/site-packages/uiautomator2/main.py", line 109, in install_minicap
path = cache_download(url)
File "/Library/Python/2.7/site-packages/uiautomator2/main.py", line 70, in cache_download
r = requests.get(url, stream=True)
File "/Library/Python/2.7/site-packages/requests/api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "/Library/Python/2.7/site-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/Library/Python/2.7/site-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/Library/Python/2.7/site-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/Library/Python/2.7/site-packages/requests/adapters.py", line 506, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /codeskyblue/stf-binaries/raw/master/node_modules/minicap-prebuilt/prebuilt/armeabi-v7a/lib/android-23/minicap.so (Caused by SSLError(SSLError(1, u'[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590)'),))

关于Android 4.2.2 d.info

http://192.168.168.116:7912/version
可以回显0.0.6版本

不能打印d.info

能启动和关闭app

d.press('back')
File "/home/jet/wtm/uiautomator2/uiautomator2/init.py", line 485, in press
return self.jsonrpc.pressKey(key)
File "/home/jet/wtm/uiautomator2/uiautomator2/init.py", line 151, in call
return self.server.jsonrpc_call(self.method, params)
File "/home/jet/wtm/uiautomator2/uiautomator2/init.py", line 175, in jsonrpc_call
raise UiaError(self._server_jsonrpc_url, data, res.status_code, res.text, "HTTP Return code is not 200", res.text)
uiautomator2.UiaError: ('http://192.168.168.116:7912/jsonrpc/0', '{"params": ["back"], "jsonrpc": "2.0", "id": "3c437a0a91cb550457002078bf9a6eed", "method": "pressKey"}', 502, u'', 'HTTP Return code is not 200', u'')

python -m uiautomator2 init 初始化总是这样,是怎么回事?

2018-02-27 17:23:27,394 - main.py:243 - INFO - Device(EUSSNRQK8DLJCMFA) init
ialing ...
Traceback (most recent call last):
File "C:\Users\zybang\AppData\Local\Programs\Python\Python36\lib\runpy.py", li
ne 193, in run_module_as_main
"main", mod_spec)
File "C:\Users\zybang\AppData\Local\Programs\Python\Python36\lib\runpy.py", li
ne 85, in run_code
exec(code, run_globals)
File "C:\Users\zybang\AppData\Local\Programs\Python\Python36\lib\site-packages
\uiautomator2_main
.py", line 305, in
main()
File "C:\Users\zybang\AppData\Local\Programs\Python\Python36\lib\site-packages
\uiautomator2_main
.py", line 301, in main
fire.Fire(MyFire)
File "C:\Users\zybang\AppData\Local\Programs\Python\Python36\lib\site-packages
\fire\core.py", line 127, in Fire
component_trace = Fire(component, args, context, name)
File "C:\Users\zybang\AppData\Local\Programs\Python\Python36\lib\site-packages
\fire\core.py", line 366, in Fire
component, remaining_args)
File "C:\Users\zybang\AppData\Local\Programs\Python\Python36\lib\site-packages
\fire\core.py", line 542, in CallCallable
result = fn(*varargs, **kwargs)
File "C:\Users\zybang\AppData\Local\Programs\Python\Python36\lib\site-packages
\uiautomator2_main
.py", line 246, in init
ins.install_minicap()
File "C:\Users\zybang\AppData\Local\Programs\Python\Python36\lib\site-packages
\uiautomator2_main
.py", line 108, in install_minicap
path = cache_download(url)
File "C:\Users\zybang\AppData\Local\Programs\Python\Python36\lib\site-packages
\uiautomator2_main
.py", line 73, in cache_download
raise Exception("status code", r.status_code)
Exception: ('status code', 404)

连接设备失败有做处理吗?

import uiautomator2 as u2
d = u2.connect('192.168.21.160')

我看代码返回的d是一个object,但是我不知道连接成功还是失败

打印信息错误

链接上了设备但是运行print (d.press('home')的时候报错

Traceback (most recent call last):
  File "C:\Users\Glority\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 601, in urlopen
    chunked=chunked)
  File "C:\Users\Glority\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 387, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "C:\Users\Glority\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 383, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Users\Glority\Anaconda3\lib\http\client.py", line 1331, in getresponse
    response.begin()
  File "C:\Users\Glority\Anaconda3\lib\http\client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "C:\Users\Glority\Anaconda3\lib\http\client.py", line 258, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "C:\Users\Glority\Anaconda3\lib\socket.py", line 586, in readinto
    return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Glority\Anaconda3\lib\site-packages\requests\adapters.py", line 440, in send
    timeout=timeout
  File "C:\Users\Glority\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 639, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "C:\Users\Glority\Anaconda3\lib\site-packages\urllib3\util\retry.py", line 357, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "C:\Users\Glority\Anaconda3\lib\site-packages\urllib3\packages\six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\Glority\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 601, in urlopen
    chunked=chunked)
  File "C:\Users\Glority\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 387, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "C:\Users\Glority\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 383, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Users\Glority\Anaconda3\lib\http\client.py", line 1331, in getresponse
    response.begin()
  File "C:\Users\Glority\Anaconda3\lib\http\client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "C:\Users\Glority\Anaconda3\lib\http\client.py", line 258, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "C:\Users\Glority\Anaconda3\lib\socket.py", line 586, in readinto
    return self._sock.recv_into(b)
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Glority\Anaconda3\lib\site-packages\uiautomator2\__init__.py", line 791, in press
    return self.jsonrpc.pressKey(key)
  File "C:\Users\Glority\Anaconda3\lib\site-packages\uiautomator2\__init__.py", line 211, in __call__
    return self.server.jsonrpc_call(self.method, params, http_timeout)
  File "C:\Users\Glority\Anaconda3\lib\site-packages\uiautomator2\__init__.py", line 230, in jsonrpc_call
    data=data)
  File "C:\Users\Glority\Anaconda3\lib\site-packages\requests\sessions.py", line 555, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "C:\Users\Glority\Anaconda3\lib\site-packages\uiautomator2\__init__.py", line 154, in request
    resp = super(TimeoutRequestsSession, self).request(method, url, **kwargs)
  File "C:\Users\Glority\Anaconda3\lib\site-packages\requests\sessions.py", line 508, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\Glority\Anaconda3\lib\site-packages\requests\sessions.py", line 618, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\Glority\Anaconda3\lib\site-packages\requests\adapters.py", line 490, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

但是我这边并没有链接啊,我应该强制关掉哪个链接=。=

Genymotion上send_keys函数不支持的解决方法

首先通过getprop获取到设备的manufacturer

ro.product.manufacturer]: [Genymotion]
[ro.product.model]: [Google Nexus 6 - 7.0.0 - API 24 - 1440x2560]
[ro.product.model.geny-def]: [Genymotion 'Phone' version]
[ro.product.name]: [vbox86p]
[ro.product.name.geny-def]: [vbox86p]

如果是genymotion,输入改成

if manufacturer == 'Genymotion' and self(focused=True, className="android.widget.EditText").exists:
    self(focused=True, className="android.widget.EditText").send_keys(text)

初始化后,打印不出设备信息,红米和oppo都尝试过了

/usr/local/lib/python2.7/dist-packages/uiautomator2/__init__.py:331: RuntimeWarning: uiautomator2 is down, restart.
  warnings.warn("uiautomator2 is down, restart.", RuntimeWarning, stacklevel=1)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-4-a5c55faeb6c2> in <module>()
----> 1 print (d.info)

/usr/local/lib/python2.7/dist-packages/uiautomator2/__init__.pyc in __getattr__(self, attr)
    823 
    824     def __getattr__(self, attr):
--> 825         return getattr(self._default_session, attr)
    826 
    827     def __call__(self, **kwargs):

/usr/local/lib/python2.7/dist-packages/uiautomator2/__init__.pyc in info(self)
   1204     @property
   1205     def info(self):
-> 1206         return self.jsonrpc.deviceInfo()
   1207 
   1208     def __call__(self, **kwargs):

/usr/local/lib/python2.7/dist-packages/uiautomator2/__init__.pyc in __call__(self, *args, **kwargs)
    320                 http_timeout = kwargs.pop('http_timeout', HTTP_TIMEOUT)
    321                 params = args if args else kwargs
--> 322                 return self.server.jsonrpc_retry_call(jsonrpc_url, self.method, params, http_timeout)
    323 
    324         return JSONRpcWrapper(self)

/usr/local/lib/python2.7/dist-packages/uiautomator2/__init__.pyc in jsonrpc_retry_call(self, *args, **kwargs)
    331             warnings.warn("uiautomator2 is down, restart.", RuntimeWarning, stacklevel=1)
    332             # for XiaoMi, want to recover uiautomator2 must start app:com.github.uiautomator
--> 333             self.healthcheck(unlock=False)
    334             return self.jsonrpc_call(*args, **kwargs)
    335 

/usr/local/lib/python2.7/dist-packages/uiautomator2/__init__.pyc in healthcheck(self, unlock)
    458                     return True
    459             time.sleep(.5)
--> 460         raise RuntimeError("Uiautomator started failed.")
    461 
    462     def app_install(self, url, installing_callback=None):

RuntimeError: Uiautomator started failed.

可以同时支持两台机器吗?

我连上两台手机,执行init之后,返回的一个是本机ip,一个是127.0.0.1,本机ip可以连上用,但是127.0.0.1不能再python中使用。。

手机和电脑在不同的地方

现在有个问题是服务器部署在阿里云上,手机不能通过数据线链接。这种情况要怎么处理?
atx-server已经检测到这台手机,但是点进去之后是一片空白
Uploading 700E7D80-AA90-49F4-A20C-9C99188E3293.png…

关于wait()错误

关于wait()错误:
adb logcat

10-27 17:17:45.125 D/UIAutomatorStub(29836): URI: /jsonrpc/0, Method: POST, params, {NanoHttpd.QUERY_STRING=null}, files: {postData={"params": [{"childOrSiblingSelector": [], "text": "\u5e73\u53f0", "mask": 1, "childOrSibling": []}, 30000], "jsonrpc": "2.0", "id": "2fc32e25165358a0467b6658622d90fd", "method": "waitForExists"}}
10-27 17:17:45.145 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:45.145 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:45.146 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:45.147 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:45.687 I/ThermalEngine( 331): Sensor:batt_temp:334 mC
10-27 17:17:46.051 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:46.053 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:46.054 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:46.055 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:46.213 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:46.215 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:46.215 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:46.216 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:46.669 D/wpa_supplicant( 8787): wlan0: Control interface command 'SIGNAL_POLL'
10-27 17:17:46.686 D/wpa_supplicant( 8787): CTRL-DEBUG: global_ctrl_sock-sendto: sock=11 sndbuf=163840 outq=0 send_len=48
10-27 17:17:46.688 I/ThermalEngine( 331): Sensor:batt_temp:334 mC
10-27 17:17:47.139 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:47.140 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:47.140 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:47.140 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:47.296 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:47.297 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:47.298 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:47.299 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:47.689 I/ThermalEngine( 331): Sensor:batt_temp:334 mC
10-27 17:17:48.219 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:48.219 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:48.220 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:48.220 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:48.379 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:48.380 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:48.380 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:48.381 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:48.691 I/ThermalEngine( 331): Sensor:batt_temp:333 mC
10-27 17:17:49.218 D/UTAnalytics:LogStoreMgr(25456): pid:25456 [store],
10-27 17:17:49.235 D/UTAnalytics:UTSqliteLogStore(25456): pid:25456 sql:SELECT * FROM log ORDER BY time ASC LIMIT 350,
10-27 17:17:49.241 D/UTAnalytics:LogStoreMgr(25456): pid:25456 [get],[],
10-27 17:17:49.246 D/UTAnalytics:UploadEngine(25456): pid:25456 UTDC.bBackground:false,AppInfoUtil.isForeground(UTDC.getContext()) ,true,
10-27 17:17:49.248 D/UTAnalytics:UploadTask(25456): pid:25456 mPeriod:30000,
10-27 17:17:49.286 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:49.286 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:49.287 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:49.287 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:49.468 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:49.469 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:49.470 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:49.470 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:49.692 I/ThermalEngine( 331): Sensor:batt_temp:333 mC
10-27 17:17:49.696 D/wpa_supplicant( 8787): wlan0: Control interface command 'SIGNAL_POLL'
10-27 17:17:49.711 D/wpa_supplicant( 8787): CTRL-DEBUG: global_ctrl_sock-sendto: sock=11 sndbuf=163840 outq=0 send_len=48
10-27 17:17:50.354 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:50.354 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:50.354 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:50.355 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:50.535 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:50.536 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:50.537 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:50.537 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:50.693 I/ThermalEngine( 331): Sensor:batt_temp:333 mC
10-27 17:17:51.448 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:51.448 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:51.449 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:51.449 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:51.604 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:51.604 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:51.605 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:51.605 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:51.694 I/ThermalEngine( 331): Sensor:batt_temp:334 mC
10-27 17:17:52.550 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:52.551 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:52.551 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:52.551 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:52.692 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:52.693 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:52.694 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:52.694 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:52.696 I/ThermalEngine( 331): Sensor:batt_temp:333 mC
10-27 17:17:52.717 D/wpa_supplicant( 8787): wlan0: Control interface command 'SIGNAL_POLL'
10-27 17:17:52.732 D/wpa_supplicant( 8787): CTRL-DEBUG: global_ctrl_sock-sendto: sock=11 sndbuf=163840 outq=0 send_len=48
10-27 17:17:52.742 W/PushService( 2922): 2017-10-27 17:17:52,741 - [WARN::PushService] - [Thread:49] JOB: check the ping-pong.1509095862740
10-27 17:17:53.634 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:53.635 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:53.635 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:53.635 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:53.697 I/ThermalEngine( 331): Sensor:batt_temp:333 mC
10-27 17:17:53.764 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:53.764 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:53.765 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:53.765 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:54.699 I/ThermalEngine( 331): Sensor:batt_temp:333 mC
10-27 17:17:54.711 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:54.712 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:54.712 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:54.713 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:54.843 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:54.844 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:54.845 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:54.845 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:55.010 E/LocSvc_libulp( 1621): I/int ulp_msg_process_system_update(UlpSystemEvent): systemEvent:5
10-27 17:17:55.010 E/LocSvc_libulp( 1621): I/int ulp_msg_process_start_req(), at ulp state = 1
10-27 17:17:55.010 E/LocSvc_api_v02( 1621): I/---> locClientSendReq line 2020 QMI_LOC_GET_BEST_AVAILABLE_POSITION_REQ_V02
10-27 17:17:55.014 E/LocSvc_ApiV02( 1621): I/<--- void globalRespCb(locClientHandleType, uint32_t, locClientRespIndUnionType, void*) line 115 QMI_LOC_GET_BEST_AVAILABLE_POSITION_REQ_V02
10-27 17:17:55.014 E/LocSvc_libulp( 1621): I/int ulp_brain_process_zpp_position_report(loc_sess_status, LocPosTechMask, UlpLocation*), report ZPP position to providers,report_position = 1
10-27 17:17:55.015 E/IzatSvc_PassiveLocListener( 1621): E/Exiting with error virtual void izat_manager::IzatPassiveLocationListener::onLocationChanged(const izat_manager::IzatLocation*, izat_manager::IzatLocationStatus) line 113 "1"
10-27 17:17:55.285 D/UTAnalytics:CommitTask(25456): pid:25456 check&commit event:65501,
10-27 17:17:55.285 D/UTAnalytics:CommitTask(25456): pid:25456 next:65501,
10-27 17:17:55.285 D/UTAnalytics:CommitTask(25456): pid:25456 check&commit event:65502,
10-27 17:17:55.285 D/UTAnalytics:CommitTask(25456): pid:25456 next:65502,
10-27 17:17:55.285 D/UTAnalytics:CommitTask(25456): pid:25456 check&commit event:65503,
10-27 17:17:55.286 D/UTAnalytics:CommitTask(25456): pid:25456 next:65503,
10-27 17:17:55.700 I/ThermalEngine( 331): Sensor:batt_temp:333 mC
10-27 17:17:55.737 D/wpa_supplicant( 8787): wlan0: Control interface command 'SIGNAL_POLL'
10-27 17:17:55.752 D/wpa_supplicant( 8787): CTRL-DEBUG: global_ctrl_sock-sendto: sock=11 sndbuf=163840 outq=0 send_len=48
10-27 17:17:56.222 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:56.223 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:56.224 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:56.225 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:56.249 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:56.249 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:56.250 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:56.250 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:56.701 I/ThermalEngine( 331): Sensor:batt_temp:333 mC
10-27 17:17:57.310 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:57.312 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:57.313 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:57.313 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:57.331 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:57.331 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:57.332 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:57.332 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:57.703 I/ThermalEngine( 331): Sensor:batt_temp:333 mC
10-27 17:17:58.414 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:58.415 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:58.415 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:58.416 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:58.432 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:58.433 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:58.434 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:58.434 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:58.704 I/ThermalEngine( 331): Sensor:batt_temp:333 mC
10-27 17:17:58.760 D/wpa_supplicant( 8787): wlan0: Control interface command 'SIGNAL_POLL'
10-27 17:17:58.778 D/wpa_supplicant( 8787): CTRL-DEBUG: global_ctrl_sock-sendto: sock=11 sndbuf=163840 outq=0 send_len=48
10-27 17:17:59.519 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:59.520 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:59.521 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:59.521 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:59.552 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:17:59.552 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:17:59.554 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:17:59.554 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:17:59.709 I/ThermalEngine( 331): Sensor:batt_temp:333 mC
10-27 17:18:00.025 I/ProcessStatsService( 1621): Prepared write state in 22ms
10-27 17:18:00.053 I/ProcessStatsService( 1621): Pruning old procstats: /data/system/procstats/state-2017-10-26-10-09-46.bin
10-27 17:18:00.111 W/WtProcessController( 3384): do not trim { PackageName :com.tencent.mm Pid: 25360 Uid: 10131 Start by: activity Score:100 Old score:100 state:0 mBackgroundTimeInMillis:0 WakelockCount:0 wakelogsize:0 ActivityDestroied:false Activity size: 1 PackageInfo:{WhetstonePackageInfo#PacakgeName:com.tencent.mm uid:10131 uiMemoryThresold:0 nonUiMemoryThresold:0 Flag:4160,0x1040 [,TRIMHEAPS,FLAG_DEAL_SCHEDULE] Type:64[,AUTO_START] } tasknum:1439}
10-27 17:18:00.134 W/WtProcessController( 3384): do not trim { PackageName :com.tencent.mm Pid: 25572 Uid: 10131 Start by: service Score:100 Old score:100 state:0 mBackgroundTimeInMillis:0 WakelockCount:0 wakelogsize:0 ActivityDestroied:false Activity size: 0 PackageInfo:{WhetstonePackageInfo#PacakgeName:com.tencent.mm uid:10131 uiMemoryThresold:0 nonUiMemoryThresold:0 Flag:4160,0x1040 [,TRIMHEAPS,FLAG_DEAL_SCHEDULE] Type:64[,AUTO_START] } tasknum:-1}
10-27 17:18:00.136 E/NetlinkEvent( 286): NetlinkEvent::FindParam(): Parameter 'TIME_NS' not found
10-27 17:18:00.136 E/NetlinkEvent( 286): NetlinkEvent::FindParam(): Parameter 'UID' not found
10-27 17:18:00.641 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:00.641 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:00.642 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:00.642 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:00.658 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:00.659 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:00.659 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:00.660 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:00.710 I/ThermalEngine( 331): Sensor:batt_temp:333 mC
10-27 17:18:01.715 I/ThermalEngine( 331): Sensor:batt_temp:333 mC
10-27 17:18:01.724 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:01.725 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:01.725 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:01.726 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:01.746 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:01.746 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:01.747 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:01.747 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:01.784 D/wpa_supplicant( 8787): wlan0: Control interface command 'SIGNAL_POLL'
10-27 17:18:01.799 D/wpa_supplicant( 8787): CTRL-DEBUG: global_ctrl_sock-sendto: sock=11 sndbuf=163840 outq=0 send_len=48
10-27 17:18:02.716 I/ThermalEngine( 331): Sensor:batt_temp:332 mC
10-27 17:18:02.832 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:02.832 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:02.833 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:02.833 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:02.849 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:02.850 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:02.850 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:02.851 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:03.718 I/ThermalEngine( 331): Sensor:batt_temp:333 mC
10-27 17:18:04.250 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:04.251 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:04.251 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:04.252 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:04.271 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:04.272 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:04.273 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:04.273 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:04.720 I/ThermalEngine( 331): Sensor:batt_temp:332 mC
10-27 17:18:04.808 D/wpa_supplicant( 8787): wlan0: Control interface command 'SIGNAL_POLL'
10-27 17:18:04.825 D/wpa_supplicant( 8787): CTRL-DEBUG: global_ctrl_sock-sendto: sock=11 sndbuf=163840 outq=0 send_len=48
10-27 17:18:05.335 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:05.336 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:05.336 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:05.337 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:05.357 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:05.357 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:05.357 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:05.358 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:05.721 I/ThermalEngine( 331): Sensor:batt_temp:332 mC
10-27 17:18:06.429 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:06.430 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:06.430 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:06.430 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:06.446 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:06.447 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:06.448 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:06.449 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:06.723 I/ThermalEngine( 331): Sensor:batt_temp:332 mC
10-27 17:18:07.525 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:07.526 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:07.528 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:07.529 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:07.547 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:07.547 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:07.548 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:07.548 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:07.724 I/ThermalEngine( 331): Sensor:batt_temp:332 mC
10-27 17:18:07.832 D/wpa_supplicant( 8787): wlan0: Control interface command 'SIGNAL_POLL'
10-27 17:18:07.848 D/wpa_supplicant( 8787): CTRL-DEBUG: global_ctrl_sock-sendto: sock=11 sndbuf=163840 outq=0 send_len=48
10-27 17:18:08.610 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:08.611 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:08.612 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:08.612 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:08.632 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:08.632 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:08.633 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:08.633 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:08.725 I/ThermalEngine( 331): Sensor:batt_temp:332 mC
10-27 17:18:09.702 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:09.702 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:09.703 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:09.703 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:09.721 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:09.722 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:09.722 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:09.723 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:09.727 I/ThermalEngine( 331): Sensor:batt_temp:333 mC
10-27 17:18:10.728 I/ThermalEngine( 331): Sensor:batt_temp:332 mC
10-27 17:18:10.807 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:10.808 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:10.808 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:10.809 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:10.831 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:10.832 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:10.833 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:10.834 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:10.854 D/wpa_supplicant( 8787): wlan0: Control interface command 'SIGNAL_POLL'
10-27 17:18:10.869 D/wpa_supplicant( 8787): CTRL-DEBUG: global_ctrl_sock-sendto: sock=11 sndbuf=163840 outq=0 send_len=48
10-27 17:18:11.729 I/ThermalEngine( 331): Sensor:batt_temp:332 mC
10-27 17:18:12.298 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:12.299 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:12.300 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:12.300 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:12.316 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:12.316 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:12.317 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:12.318 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:12.393 E/NetlinkEvent( 286): NetlinkEvent::FindParam(): Parameter 'TIME_NS' not found
10-27 17:18:12.393 E/NetlinkEvent( 286): NetlinkEvent::FindParam(): Parameter 'UID' not found
10-27 17:18:12.730 I/ThermalEngine( 331): Sensor:batt_temp:333 mC
10-27 17:18:13.366 I/NetworkDiagnostics_CheckStateManager( 3239): onSignalStrengthChanged: mSignalStrength=5
10-27 17:18:13.370 D/StatusBar.NetworkController( 2816): onSignalStrengthsChanged received on slotId :0signalStrength=SignalStrength: 15 0 -120 -160 -120 -1 -1 99 2147483647 2147483647 2147483647 2147483647 2147483647 gsm|lte level=5 cdmdlevel=0 evdolevel=0
10-27 17:18:13.382 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:13.383 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:13.383 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:13.383 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:13.627 D/AndroidRuntime(26685): >>>>>> START com.android.internal.os.RuntimeInit uid 2000 <<<<<<
10-27 17:18:13.636 D/AndroidRuntime(26685): CheckJNI is OFF
10-27 17:18:13.724 D/ICU (26685): No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
10-27 17:18:13.732 I/ThermalEngine( 331): Sensor:batt_temp:332 mC
10-27 17:18:13.815 I/Radio-JNI(26685): register_android_hardware_Radio DONE
10-27 17:18:13.875 D/wpa_supplicant( 8787): wlan0: Control interface command 'SIGNAL_POLL'
10-27 17:18:13.875 D/AndroidRuntime(26685): Calling main entry com.android.commands.monkey.Monkey
10-27 17:18:13.890 D/wpa_supplicant( 8787): CTRL-DEBUG: global_ctrl_sock-sendto: sock=11 sndbuf=163840 outq=0 send_len=48
10-27 17:18:13.945 W/BroadcastQueue( 1621): Skipping deliver [background] BroadcastRecord{8a12e2a u-1 android.net.conn.CONNECTIVITY_CHANGE} to ReceiverList{72da41b 26685 (unknown name)/2000/u-1 remote:e682ccc}: process crashing
10-27 17:18:13.981 I/Timeline(26685): Timeline: Activity_launch_request time:182597765
10-27 17:18:13.991 I/ActivityManager( 1621): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.tencent.mm/.ui.LauncherUI} from uid 2000 on display 0
10-27 17:18:13.996 I/WtEventController( 3384): dispatchSysInfoEvent AM_NEW_INTENT componentName:com.tencent.mm/.ui.LauncherUI
10-27 17:18:14.008 I/SyncSecurityInjector( 1621): filterOutXiaomiAccount: system request, abort.
10-27 17:18:14.012 D/SystemUI.toggleContainer( 2816): updateToggleImage start for 3 status:true last:false isOpen:true
10-27 17:18:14.020 I/SyncSecurityInjector( 1621): filterOutXiaomiAccount: system request, abort.
10-27 17:18:14.023 D/SystemUI.toggleContainer( 2816): skip updateToggleImage for 3 status:false last:true isOpen:false
10-27 17:18:14.047 I/art (26685): System.exit called, status: 0
10-27 17:18:14.047 I/AndroidRuntime(26685): VM exiting with result code 0.
10-27 17:18:14.208 D/SystemUI.toggleContainer( 2816): updateToggleImage for 3 status:false last:true isOpen:true
10-27 17:18:14.394 D/SystemUI.toggleContainer( 2816): updateToggleImage again for 3 status:false last:true isOpen:true
10-27 17:18:14.395 D/SystemUI.toggleContainer( 2816): updateToggleImage start for 3 status:false last:true isOpen:false
10-27 17:18:14.488 W/AD-PLUGIN-AppInstallActivateManager(25315): unRegisterSplashPackageUpdatedListener
10-27 17:18:14.591 D/SystemUI.toggleContainer( 2816): updateToggleImage for 3 status:false last:false isOpen:false
10-27 17:18:14.596 I/XiaomiFirewall( 3239): firewall pkgName:com.tencent.mm, result:0x0
10-27 17:18:14.733 I/ThermalEngine( 331): Sensor:batt_temp:332 mC
10-27 17:18:14.751 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:14.751 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:14.752 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:14.753 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:15.734 I/ThermalEngine( 331): Sensor:batt_temp:332 mC
10-27 17:18:15.899 D/StatusBar.NetworkController( 2816): onSignalStrengthsChanged received on slotId :0signalStrength=SignalStrength: 15 0 -120 -160 -120 -1 -1 99 2147483647 2147483647 2147483647 2147483647 2147483647 gsm|lte level=5 cdmdlevel=0 evdolevel=0
10-27 17:18:15.899 I/NetworkDiagnostics_CheckStateManager( 3239): onSignalStrengthChanged: mSignalStrength=5
10-27 17:18:16.309 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:16.310 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:16.311 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:16.312 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:16.735 I/ThermalEngine( 331): Sensor:batt_temp:332 mC
10-27 17:18:16.895 D/wpa_supplicant( 8787): wlan0: Control interface command 'SIGNAL_POLL'
10-27 17:18:16.909 D/wpa_supplicant( 8787): CTRL-DEBUG: global_ctrl_sock-sendto: sock=11 sndbuf=163840 outq=0 send_len=48
10-27 17:18:17.212 D/UIAutomatorStub(29836): URI: /jsonrpc/0, Method: POST, params, {NanoHttpd.QUERY_STRING=null}, files: {postData={"params": [{"childOrSiblingSelector": [], "text": "\u786e\u5b9a", "mask": 1, "childOrSibling": []}, 1000], "jsonrpc": "2.0", "id": "1547aec26aac90360e2bc6c33d96e435", "method": "waitForExists"}}
10-27 17:18:17.232 W/ResourceType(25360): No known package when getting name for resource number 0xff000001
10-27 17:18:17.233 W/ResourceType(25360): No known package when getting name for resource number 0xff000002
10-27 17:18:17.233 W/ResourceType(25360): No known package when getting name for resource number 0xff000003
10-27 17:18:17.234 W/ResourceType(25360): No known package when getting name for resource number 0xff000004
10-27 17:18:17.601 D/AndroidRuntime(26719): >>>>>> START com.android.internal.os.RuntimeInit uid 2000 <<<<<<
10-27 17:18:17.611 D/AndroidRuntime(26719): CheckJNI is OFF
10-27 17:18:17.700 D/ICU (26719): No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
10-27 17:18:17.736 I/ThermalEngine( 331): Sensor:batt_temp:333 mC

uiautomator.apk意外被杀掉

锤子M1。运行游戏的时候uiautomator apk被杀

相关logcat日志

12-04 18:31:26.158  1371  1404 D UidCpuTracker: mCleanBadBgApp add and mSuspectedUids.remove: 10287
12-04 18:31:26.209  1371  1405 I ActivityManager: Killing 1151:com.github.uiautomator/u0a287 (adj 0): busy background ap
p
12-04 18:31:26.210  1371  1405 I Process : killProcessQuiet pid=1151
12-04 18:31:26.210  1371  1405 I Process : java.lang.RuntimeException
12-04 18:31:26.210  1371  1405 I Process :      at android.os.Process.killProcessQuiet(Process.java:1161)
12-04 18:31:26.210  1371  1405 I Process :      at com.android.server.am.ProcessRecord.kill(ProcessRecord.java:592)
12-04 18:31:26.210  1371  1405 I Process :      at com.android.server.am.ActivityManagerService.removeProcessLocked(Acti
vityManagerService.java:7002)
12-04 18:31:26.210  1371  1405 I Process :      at com.android.server.am.UidCpuTrackerRunner$3.run(UidCpuRunner.java:933
)
12-04 18:31:26.210  1371  1405 I Process :      at android.os.Handler.handleCallback(Handler.java:739)
12-04 18:31:26.210  1371  1405 I Process :      at android.os.Handler.dispatchMessage(Handler.java:95)
12-04 18:31:26.210  1371  1405 I Process :      at android.os.Looper.loop(Looper.java:148)
12-04 18:31:26.210  1371  1405 I Process :      at android.os.HandlerThread.run(HandlerThread.java:61)
12-04 18:31:26.210  1371  1405 I Process :      at com.android.server.ServiceThread.run(ServiceThread.java:46)
12-04 18:31:26.227  1371  2255 W WindowManager: Attempted to remove non-existing token: android.os.Binder@c83af2b
12-04 18:31:26.228  1371  2255 W AccessibilityManagerService: Skipping accessibilty service com.cootek.smartinputv5.smar
tisan/com.cootek.smartinput5.TouchPalAccessibilityService: it does not require the permission android.permission.BIND_AC
CESSIBILITY_SERVICE
12-04 18:31:26.231  1371  1405 D ActivityManager: cleanUpApplicationRecord -- 1151
12-04 18:31:26.232  1371  1405 W ActivityManager: Crash of app com.github.uiautomator running instrumentation ComponentI
nfo{com.github.uiautomator.test/android.support.test.runner.AndroidJUnitRunner}
12-04 18:31:26.236  1371  1405 I ActivityManager:  appId 10287 get for package com.github.uiautomator
12-04 18:31:26.237  1371  1405 I ActivityManager: Force stopping com.github.uiautomator appid=10287 user=0: finished ins
t
12-04 18:31:26.238  1371  1405 I UidCpuTracker: remove busy background app=ProcessRecord{9b2df88 0:com.github.uiautomato
r/u0a287}
12-04 18:31:26.239  1371  2938 W ActivityManager: Spurious death for ProcessRecord{9b2df88 0:com.github.uiautomator/u0a2
87}, curProc for 1151: null

win10 执行python -m uiautomator2 init失败

1.pip install --pre uiautomator2已执行成功
2.连接设备谷歌nexus Android 8.1
3.日志如下:
D:\uiautomator2>python -m uiautomator2 init
2018-01-08 17:05:28,703 - main.py:236 - INFO - Device(84B5T15A10013698) initialing ...
D:\python\lib\site-packages\urllib3\util\ssl_.py:339: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
SNIMissingWarning
D:\python\lib\site-packages\urllib3\util\ssl_.py:137: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarning
D:\python\lib\site-packages\urllib3\util\ssl_.py:137: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarning
�[Kminicap.so |################################| 23.0 KiB / 23.0 KiB
�[?25h2018-01-08 17:05:31,944 - main.py:115 - INFO - install minicap
D:\python\lib\site-packages\urllib3\util\ssl_.py:137: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarning
D:\python\lib\site-packages\urllib3\util\ssl_.py:137: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarning
�[Kminicap |################################| 566.5 KiB / 566.5 KiB
�[?25h2018-01-08 17:05:54,605 - main.py:122 - INFO - install minitouch
D:\python\lib\site-packages\urllib3\util\ssl_.py:137: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarning
D:\python\lib\site-packages\urllib3\util\ssl_.py:137: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarning
�[Kminitouch |################################| 33.8 KiB / 33.8 KiB
�[?25h2018-01-08 17:06:03,450 - main.py:143 - INFO - app-uiautomator.apk(1.0.6) installing ...
D:\python\lib\site-packages\urllib3\util\ssl_.py:137: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarning
D:\python\lib\site-packages\urllib3\util\ssl_.py:137: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarning
�[Kapp-uiautomator.apk | | 16.0 KiB / 1.6 MiB�[Kapp-uiautomator.apk | | 32.0 KiB / 1.6 MiB�[Kapp-uiautomator.apk | | 48.0 KiB / 1.6 MiB�[Kapp-uiautomator.apk |# | 64.0 KiB / 1.6 MiB�[Kapp-uiautomator.apk |# | 80.0 KiB / 1.6 MiB�[Kapp-uiautomator.apk |# | 96.0 KiB / 1.6 MiB�[Kapp-uiautomator.apk |## | 112.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |## | 128.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |## | 144.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |### | 160.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |### | 176.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |### | 192.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |### | 208.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |#### | 224.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |#### | 240.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |#### | 256.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |##### | 272.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |##### | 288.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |##### | 304.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |###### | 320.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |###### | 336.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |###### | 352.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |####### | 368.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |####### | 384.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |####### | 400.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |####### �[Kapp-uiautomator.apk |#####�[Kapp-uiautomator.apk |########## | 576.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |########### | 592.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |########### | 608.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |########### | 624.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |############ | 640.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |############ | 656.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |############ | 672.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |############# | 688.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |############# | 704.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |############# | 720.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |############## | 736.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |############## | 752.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |############## | 768.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |############## | 784.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |############### | 800.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |############### | 816.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |############### | 832.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |################ | 848.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |################ | 864.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |################ | 880.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |################# | 896.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |################# | 912.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |################# | 928.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |################## | 944.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |################## | 960.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |################## | 976.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |################## | 992.0 KiB / 1.6 Mi�[Kapp-uiautomator.apk |################### | 1008.0 KiB / 1.6 M�[Kapp-uiautomator.apk |############################## | 1.6 MiB / 1.6 MiB

python -m uiautomator2 init安装失败

win10下,执行python -m uiautomator2 init出错:
requests.exceptions.SSLError: [Errno 1] _ssl.c:504: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
image
咋原因呢?

vivo Y67上执行d.info非常慢

原因分析.

d.info中会调用UiDevice.getDisplayRotation() 之后,该函数的实现如下

    public int getDisplayRotation() {
        Tracer.trace();
        waitForIdle();
        return getAutomatorBridge().getRotation();
    }

waitForIdle为等待当前UI稳定的意思。默认等待时间10s。(实际测试每次都会超时)

另外这里uiautomator2也有bug,参考链接 https://www.ydkf.me/archives/22

解决方法

image

将上方的黄色提示框关掉之后。使用IP连接设备,d.info调用速度恢复正常。
怀疑是上方的提示框影响了waitForIdle函数

Command "python setup.py egg_info" failed with error code 1

Hi ,
I download this uiautomator2-master.zip and install it in windows7, but I meet an error by using "pip install -e .":
Complete output from command python setup.py egg_info:
ERROR:root:Error parsing
Traceback (most recent call last):
File "d:\uiautomator\uiautomator2.eggs\pbr-3.1.1-py2.7.egg\pbr\core.py", line 111, in pbr
attrs = util.cfg_to_args(path, dist.script_args)
File "d:\uiautomator\uiautomator2.eggs\pbr-3.1.1-py2.7.egg\pbr\util.py", line 249, in cfg_to_args
pbr.hooks.setup_hook(config)
File "d:\uiautomator\uiautomator2.eggs\pbr-3.1.1-py2.7.egg\pbr\hooks_init_.py", line 25, in setup_hook
metadata_config.run()
File "d:\uiautomator\uiautomator2.eggs\pbr-3.1.1-py2.7.egg\pbr\hooks\base.py", line 27, in run
self.hook()
File "d:\uiautomator\uiautomator2.eggs\pbr-3.1.1-py2.7.egg\pbr\hooks\metadata.py", line 26, in hook
self.config['name'], self.config.get('version', None))
File "d:\uiautomator\uiautomator2.eggs\pbr-3.1.1-py2.7.egg\pbr\packaging.py", line 755, in get_version
name=package_name))
Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's a
e that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project
mator2 was given, but was not able to be found.
error in setup command: Error parsing D:\Uiautomator\uiautomator2\setup.cfg: Exception: Versioning for this project requ
an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package
up.cfg and the argument given to pbr.version.VersionInfo. Project name uiautomator2 was given, but was not able to be found.

How I can resolve it ? thanks~

Failed to establish a new connection:

print(d.info)

File "/usr/local/lib/python2.7/site-packages/uiautomator2/init.py", line 376, in getattr
return getattr(self._default_session, attr)
File "/usr/local/lib/python2.7/site-packages/uiautomator2/init.py", line 620, in info
return self.jsonrpc.deviceInfo()
File "/usr/local/lib/python2.7/site-packages/uiautomator2/init.py", line 154, in call
return self.server.jsonrpc_call(self.method, params)
File "/usr/local/lib/python2.7/site-packages/uiautomator2/init.py", line 173, in jsonrpc_call
data=data)
File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 535, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/site-packages/requests/adapters.py", line 487, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='cb5125l786', port=7912): Max retries exceeded with url: /jsonrpc/0 (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x10f35e690>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',))

uiautomator2.UiaError

Traceback (most recent call last):
  File "D:/Django/project/OneKeyTest/Backend/UIAutomator/OpenSDKUIAuto.py", line 128, in <module>
    print d.info
  File "D:\Django\python\lib\site-packages\uiautomator2\__init__.py", line 523, in __getattr__
    return getattr(self._default_session, attr)
  File "D:\Django\python\lib\site-packages\uiautomator2\__init__.py", line 809, in info
    return self.jsonrpc.deviceInfo()
  File "D:\Django\python\lib\site-packages\uiautomator2\__init__.py", line 192, in __call__
    return self.server.jsonrpc_call(self.method, params)
  File "D:\Django\python\lib\site-packages\uiautomator2\__init__.py", line 216, in jsonrpc_call
    raise UiaError(self._server_jsonrpc_url, data, res.status_code, res.text, "HTTP Return code is not 200", res.text)
uiautomator2.UiaError: ('http://127.0.0.1:60334/jsonrpc/0', '{"params": {}, "jsonrpc": "2.0", "id": "c55179c4c0cb2c166427bb3d61963236", "method": "deviceInfo"}', 504.

使用python27,执行命令python -m uiautomator2 init报错

$ python -m uiautomator2 init
2018-01-22 17:03:44,749 - main.py:241 - INFO - Device(ZX1G22KJB2) initialing ...
2018-01-22 17:03:45,654 - main.py:120 - INFO - install minicap
2018-01-22 17:03:46,246 - main.py:127 - INFO - install minitouch
2018-01-22 17:03:49,286 - main.py:148 - INFO - app-uiautomator.apk(1.0.9) installing ...
Traceback (most recent call last):
File "D:\Python27\lib\runpy.py", line 174, in run_module_as_main
"main", fname, loader, pkg_name)
File "D:\Python27\lib\runpy.py", line 72, in run_code
exec code in run_globals
File "D:\Python27\lib\site-packages\uiautomator2_main
.py", line 290, in
main()
File "D:\Python27\lib\site-packages\uiautomator2_main
.py", line 286, in main
fire.Fire(MyFire)
File "C:\Users\uc\AppData\Roaming\Python\Python27\site-packages\fire\core.py", line 127, in Fire
component_trace = Fire(component, args, context, name)
File "C:\Users\uc\AppData\Roaming\Python\Python27\site-packages\fire\core.py", line 366, in Fire
component, remaining_args)
File "C:\Users\uc\AppData\Roaming\Python\Python27\site-packages\fire\core.py", line 542, in CallCallable
result = fn(*varargs, **kwargs)
File "D:\Python27\lib\site-packages\uiautomator2_main
.py", line 246, in init
ins.install_uiautomator_apk(apk_version, reinstall)
File "D:\Python27\lib\site-packages\uiautomator2_main
.py", line 149, in install_uiautomator_apk
path = cache_download(app_url)
File "D:\Python27\lib\site-packages\uiautomator2_main
.py", line 80, in cache_download
r = requests.get(url, stream=True)
File "D:\Python27\lib\site-packages\requests\api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "D:\Python27\lib\site-packages\requests\api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "D:\Python27\lib\site-packages\requests\sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "D:\Python27\lib\site-packages\requests\sessions.py", line 640, in send
history = [resp for resp in gen] if allow_redirects else []
File "D:\Python27\lib\site-packages\requests\sessions.py", line 218, in resolve_redirects
**adapter_kwargs
File "D:\Python27\lib\site-packages\requests\sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "D:\Python27\lib\site-packages\requests\adapters.py", line 508, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='github-production-release-asset-2e65be.s3.amazonaws.com', port=443): Max retries exceeded with url: /53296967/afe654de-fbc9-11e7-87ef-84b9b7c1d21d?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20180122%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20180122T090355Z&X-Amz-Expires=300&X-Amz-Signature=c6f4bfa9dab0a92044c9c03f55e6cb32a4bfa050dc8951052c17796bf1360a3f&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dapp-uiautomator.apk&response-content-type=application%2Fvnd.android.package-archive (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x034021F0>: Failed to establish a new connection: [Errno 10060] ',))

怎么设置截图后保存的图片的位置

image = d.screenshot()
image.save("home.jpg")
我在pycharm 下创建一个项目。运行这两句的话,图片会存在根目录下面。
我新建一个pic文件夹。想把截图放在里面。
image.save("pic\home.jpg")
发现这样是不行...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.