Skip to content

Commit

Permalink
add device_info back, fix screenshot error
Browse files Browse the repository at this point in the history
  • Loading branch information
codeskyblue committed Apr 28, 2024
1 parent dc080d0 commit a0e9612
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ print(d.info)
screenOn': True, 'sdkInt': 27, 'naturalOrientation': True}
```

另外为了保持稳定,还需要开启`小黄车`的悬浮窗权限。参考文章 [py-uiautomator2通过悬浮窗让服务长时间可用](https://zhuanlan.zhihu.com/p/688009468)

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

## Sponsors
Expand All @@ -77,7 +79,6 @@ Thank you to all our sponsors! ✨🍰✨
# Article Recommended
优秀文章推荐 (欢迎QQ群里at我反馈)

- [py-uiautomator2通过悬浮窗让服务长时间可用](https://zhuanlan.zhihu.com/p/688009468) 这个**强烈推荐**看一下
- [termux里如何部署uiautomator2简介](https://www.cnblogs.com/ze-yan/p/12242383.html) by `成都-测试只会一点点`

## 相关项目
Expand Down
48 changes: 47 additions & 1 deletion docs/2to3.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
- Remove function connect_wifi() -> Device, 该函数依赖atx-agent
- Remove function connect_adb_wifi(str) -> Device, 直接用connect就行了
- Remove function set_new_command_timeout(timeout: int), 用不着了
- Remove function device_info(), 函数依赖atx-agent
- Remove function open_identify(), 打开一个比较明显的界面,这个函数出了点毛病,先下掉了

### Command remove
Expand Down Expand Up @@ -114,3 +113,50 @@ It seems the strict is useless, so I delete it.
### push
- 2.x push(src, dst, mode, show_process:bool=False)
- 3.x push(src, dst, mode)

### device_info
print(d.device_info)

2.x prints

```
{'udid': '08a3d291-26:17:84:b6:cb:a0-DT1901A',
'version': '10',
'serial': '08a3d291',
'brand': 'SMARTISAN',
'model': 'DT1901A',
'hwaddr': '26:17:84:b6:cb:a0',
'sdk': 29,
'agentVersion': '0.10.0',
'display': {'width': 1080, 'height': 2340},
'battery': {'acPowered': False,
'usbPowered': True,
'wirelessPowered': False,
'status': 5,
'health': 2,
'present': True,
'level': 100,
'scale': 100,
'voltage': 4356,
'temperature': 292,
'technology': 'Li-poly'},
'memory': {'total': 7665272, 'around': '7 GB'},
'cpu': {'cores': 8, 'hardware': 'Qualcomm Technologies, Inc SM8150'},
'arch': '',
'owner': None,
'presenceChangedAt': '0001-01-01T00:00:00Z',
'usingBeganAt': '0001-01-01T00:00:00Z',
'product': None,
'provider': None}
```

3.x prints

```
{'serial': 'VVY0223208008426',
'sdk': 31,
'brand': 'HUAWEI',
'model': 'JAD-AL80',
'arch': 'arm64-v8a',
'version': 12}
```
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ include = ["*/assets/*"]
python = "^3.8"
requests = "*"
lxml = "*"
adbutils = "^2.2.3,!=2.3.0"
adbutils = "^2.5.0"
retry = ">=0,<1"
Deprecated = "*"
Pillow = "*"
Expand Down
17 changes: 17 additions & 0 deletions uiautomator2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,23 @@ def shell(self, cmdargs: Union[str, List[str]], timeout=60) -> ShellResponse:
@property
def info(self):
return self.jsonrpc.deviceInfo(http_timeout=10)

@property
def device_info(self) -> Dict[str, Any]:
serial = self._dev.getprop("ro.serialno")
sdk = self._dev.getprop("ro.build.version.sdk")
version = self._dev.getprop("ro.build.version.release")
brand = self._dev.getprop("ro.product.brand")
model = self._dev.getprop("ro.product.model")
arch = self._dev.getprop("ro.product.cpu.abi")
return {
"serial": serial,
"sdk": int(sdk) if sdk.isdigit() else None,
"brand": brand,
"model": model,
"arch": arch,
"version": int(version) if version.isdigit() else None,
}

@property
def wlan_ip(self) -> Optional[str]:
Expand Down
4 changes: 1 addition & 3 deletions uiautomator2/assets/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,4 @@ function download_apk(){
download_apk "$APK_VERSION" "app-uiautomator.apk"
download_apk "$APK_VERSION" "app-uiautomator-test.apk"

echo "apk_version: $APK_VERSION" >> version.txt


echo "apk_version: $APK_VERSION" > version.txt

0 comments on commit a0e9612

Please sign in to comment.