xpdc 0.1.1__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- xpdc-0.1.2/PKG-INFO +64 -0
- {xpdc-0.1.1 → xpdc-0.1.2}/README.md +0 -2
- {xpdc-0.1.1 → xpdc-0.1.2}/pyproject.toml +3 -2
- {xpdc-0.1.1 → xpdc-0.1.2}/src/xpdc/_base/device.py +20 -0
- {xpdc-0.1.1 → xpdc-0.1.2}/src/xpdc/adb/connection.py +1 -1
- {xpdc-0.1.1 → xpdc-0.1.2}/src/xpdc/adb/device.py +21 -6
- {xpdc-0.1.1 → xpdc-0.1.2}/src/xpdc/hdc/connection.py +1 -1
- {xpdc-0.1.1 → xpdc-0.1.2}/src/xpdc/hdc/device.py +19 -0
- {xpdc-0.1.1 → xpdc-0.1.2}/src/xpdc/screenshot.py +1 -2
- xpdc-0.1.2/src/xpdc.egg-info/PKG-INFO +64 -0
- xpdc-0.1.1/PKG-INFO +0 -10
- xpdc-0.1.1/src/xpdc.egg-info/PKG-INFO +0 -10
- {xpdc-0.1.1 → xpdc-0.1.2}/LICENSE +0 -0
- {xpdc-0.1.1 → xpdc-0.1.2}/setup.cfg +0 -0
- {xpdc-0.1.1 → xpdc-0.1.2}/src/xpdc/__init__.py +0 -0
- {xpdc-0.1.1 → xpdc-0.1.2}/src/xpdc/_base/__init__.py +0 -0
- {xpdc-0.1.1 → xpdc-0.1.2}/src/xpdc/_base/connection.py +0 -0
- {xpdc-0.1.1 → xpdc-0.1.2}/src/xpdc/adb/__init__.py +0 -0
- {xpdc-0.1.1 → xpdc-0.1.2}/src/xpdc/hdc/__init__.py +0 -0
- {xpdc-0.1.1 → xpdc-0.1.2}/src/xpdc/resource/__init__.py +0 -0
- {xpdc-0.1.1 → xpdc-0.1.2}/src/xpdc/utils.py +0 -0
- {xpdc-0.1.1 → xpdc-0.1.2}/src/xpdc.egg-info/SOURCES.txt +0 -0
- {xpdc-0.1.1 → xpdc-0.1.2}/src/xpdc.egg-info/dependency_links.txt +0 -0
- {xpdc-0.1.1 → xpdc-0.1.2}/src/xpdc.egg-info/requires.txt +0 -0
- {xpdc-0.1.1 → xpdc-0.1.2}/src/xpdc.egg-info/top_level.txt +0 -0
xpdc-0.1.2/PKG-INFO
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: xpdc
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: XPDC (X-Platform Device Connector) is designed to bridge the gap between devices across multiple platforms (Android, HarmonyOS, iOS).
|
|
5
|
+
Author-email: lanbaoshen <lanbaoshen@icloud.com>
|
|
6
|
+
Requires-Python: >=3.12
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: loguru>=0.7.3
|
|
10
|
+
Requires-Dist: pillow>=12.1.0
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<img src="logo.png" alt="pyecharts logo" width=200 />
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
# Introduction
|
|
18
|
+
|
|
19
|
+
XPDC (X-Platform Device Connector) is designed to bridge the gap between devices across multiple platforms (Android, HarmonyOS, iOS).
|
|
20
|
+
|
|
21
|
+
It allows users to operate devices on different platforms with the same set of code.
|
|
22
|
+
|
|
23
|
+
**Before using XPDC, you need to install the corresponding debug environment separately for each platform's device.**
|
|
24
|
+
|
|
25
|
+
Android is `adb`, HarmonyOS is `hdc`
|
|
26
|
+
|
|
27
|
+
# Installation
|
|
28
|
+
|
|
29
|
+
```shell
|
|
30
|
+
# Using uv
|
|
31
|
+
pip install uv
|
|
32
|
+
uv add xpdc
|
|
33
|
+
|
|
34
|
+
# Using pip
|
|
35
|
+
pip install xpdc
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
# Quick Start
|
|
39
|
+
|
|
40
|
+
## Install Dependencies
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from xpdc import connection, DeviceType
|
|
44
|
+
|
|
45
|
+
# Specify connect device type
|
|
46
|
+
conn = connection(DeviceType.ADB)
|
|
47
|
+
# conn = connection(DeviceType.HDC)
|
|
48
|
+
# iOS will support it in the future.
|
|
49
|
+
|
|
50
|
+
conn.cmd(['devices'])
|
|
51
|
+
|
|
52
|
+
device = conn.devices[0]
|
|
53
|
+
# You can also specify the device by its device id
|
|
54
|
+
# device = conn.device(device_id='device_id')
|
|
55
|
+
|
|
56
|
+
device.tap(500, 500)
|
|
57
|
+
device.type_text(text='lanbaoshen')
|
|
58
|
+
device.screenshot()
|
|
59
|
+
device.cmd(cmd=['shell', 'ls'])
|
|
60
|
+
device.shell(cmd=['ls'])
|
|
61
|
+
|
|
62
|
+
# For Android devices, additionally install ADBKeyboard.apk and enable it to support Chinese input.
|
|
63
|
+
device.install_and_set_adb_keyboard()
|
|
64
|
+
```
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "xpdc"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.2"
|
|
4
4
|
description = "XPDC (X-Platform Device Connector) is designed to bridge the gap between devices across multiple platforms (Android, HarmonyOS, iOS)."
|
|
5
|
-
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.12"
|
|
6
7
|
dependencies = [
|
|
7
8
|
"loguru>=0.7.3",
|
|
8
9
|
"pillow>=12.1.0",
|
|
@@ -41,6 +41,10 @@ class DeviceBase(ABC):
|
|
|
41
41
|
def launch_app(self, bundle: str, ability: str) -> str:
|
|
42
42
|
pass
|
|
43
43
|
|
|
44
|
+
@abstractmethod
|
|
45
|
+
def stop_app(self, bundle: str) -> str:
|
|
46
|
+
pass
|
|
47
|
+
|
|
44
48
|
@abstractmethod
|
|
45
49
|
def type_text(self, text: str) -> str:
|
|
46
50
|
pass
|
|
@@ -56,3 +60,19 @@ class DeviceBase(ABC):
|
|
|
56
60
|
@abstractmethod
|
|
57
61
|
def get_current_app(self) -> str:
|
|
58
62
|
pass
|
|
63
|
+
|
|
64
|
+
@abstractmethod
|
|
65
|
+
def dump_bundles(self) -> str:
|
|
66
|
+
pass
|
|
67
|
+
|
|
68
|
+
@abstractmethod
|
|
69
|
+
def dump_bundle(self, bundle: str, *, shortcut: bool = False) -> str:
|
|
70
|
+
pass
|
|
71
|
+
|
|
72
|
+
@abstractmethod
|
|
73
|
+
def clean_cache(self, bundle: str) -> str:
|
|
74
|
+
pass
|
|
75
|
+
|
|
76
|
+
@abstractmethod
|
|
77
|
+
def clean_data(self, bundle: str) -> str:
|
|
78
|
+
pass
|
|
@@ -52,6 +52,9 @@ class ADBDevice(DeviceBase):
|
|
|
52
52
|
def launch_app(self, bundle: str, ability: str = None) -> str:
|
|
53
53
|
return self.shell(['monkey', '-p', bundle, '-c', 'android.intent.category.LAUNCHER', '1'])
|
|
54
54
|
|
|
55
|
+
def stop_app(self, bundle: str) -> str:
|
|
56
|
+
return self.shell(['am', 'force-stop', bundle])
|
|
57
|
+
|
|
55
58
|
def type_text(self, text: str) -> str:
|
|
56
59
|
encoded_text = base64.b64encode(text.encode('utf-8')).decode('utf-8')
|
|
57
60
|
|
|
@@ -84,13 +87,11 @@ class ADBDevice(DeviceBase):
|
|
|
84
87
|
def screenshot(self, path: Path = None) -> Screenshot:
|
|
85
88
|
path = path or Path(f'adb-{self.device_id}-{now_str()}.png')
|
|
86
89
|
|
|
90
|
+
cmd = [self._adb, '-s', self.device_id, 'shell', 'screencap', '-p']
|
|
91
|
+
logger.debug(f'Executing command: {cmd}')
|
|
92
|
+
|
|
87
93
|
with open(path, 'wb') as f:
|
|
88
|
-
subprocess.run( # noqa: S603
|
|
89
|
-
[self._adb, '-s', self.device_id, 'shell', 'screencap', '-p'],
|
|
90
|
-
stdout=f,
|
|
91
|
-
check=True,
|
|
92
|
-
timeout=30,
|
|
93
|
-
)
|
|
94
|
+
subprocess.run(cmd, stdout=f, check=True, timeout=30) # noqa: S603
|
|
94
95
|
|
|
95
96
|
return Screenshot(path)
|
|
96
97
|
|
|
@@ -104,3 +105,17 @@ class ADBDevice(DeviceBase):
|
|
|
104
105
|
return m['bundle']
|
|
105
106
|
|
|
106
107
|
return ''
|
|
108
|
+
|
|
109
|
+
def dump_bundles(self) -> str:
|
|
110
|
+
return self.shell(['pm', 'list', 'packages'])
|
|
111
|
+
|
|
112
|
+
def dump_bundle(self, bundle: str, *, shortcut: bool = False) -> str:
|
|
113
|
+
cmd = ['dumpsys', 'package', '--checkin', bundle] if shortcut else ['dumpsys', 'package', bundle]
|
|
114
|
+
|
|
115
|
+
return self.shell(cmd)
|
|
116
|
+
|
|
117
|
+
def clean_cache(self, bundle: str) -> str:
|
|
118
|
+
return self.shell(['pm', 'clear', '--cache-only', bundle])
|
|
119
|
+
|
|
120
|
+
def clean_data(self, bundle: str) -> str:
|
|
121
|
+
return self.shell(['pm', 'clear', bundle])
|
|
@@ -47,6 +47,9 @@ class HDCDevice(DeviceBase):
|
|
|
47
47
|
def launch_app(self, bundle: str, ability: str = 'EntryAbility') -> str:
|
|
48
48
|
return self.shell(['aa', 'start', '-b', bundle, '-a', ability])
|
|
49
49
|
|
|
50
|
+
def stop_app(self, bundle: str) -> str:
|
|
51
|
+
return self.shell(['aa', 'force-stop', bundle])
|
|
52
|
+
|
|
50
53
|
def type_text(self, text: str) -> str:
|
|
51
54
|
return self.shell(['uitest', 'uiInput', 'text', text])
|
|
52
55
|
|
|
@@ -84,3 +87,19 @@ class HDCDevice(DeviceBase):
|
|
|
84
87
|
current_bundle = None
|
|
85
88
|
|
|
86
89
|
return foreground_bundle or ''
|
|
90
|
+
|
|
91
|
+
def dump_bundles(self) -> str:
|
|
92
|
+
return self.shell(['bm', 'dump', '-a'])
|
|
93
|
+
|
|
94
|
+
def dump_bundle(self, bundle: str, *, shortcut: bool = False) -> str:
|
|
95
|
+
cmd = ['bm', 'dump', '-n', bundle]
|
|
96
|
+
if shortcut:
|
|
97
|
+
cmd.append('-s')
|
|
98
|
+
|
|
99
|
+
return self.shell(cmd)
|
|
100
|
+
|
|
101
|
+
def clean_cache(self, bundle: str) -> str:
|
|
102
|
+
return self.shell(['bm', 'clean', '-c', '-n', bundle])
|
|
103
|
+
|
|
104
|
+
def clean_data(self, bundle: str) -> str:
|
|
105
|
+
return self.shell(['bm', 'clean', '-d', '-n', bundle])
|
|
@@ -6,8 +6,7 @@ from PIL import Image
|
|
|
6
6
|
from PIL.ImageFile import ImageFile
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
class Screenshot(type(Path()), Path):
|
|
9
|
+
class Screenshot(Path):
|
|
11
10
|
def __init__(self, *args):
|
|
12
11
|
super().__init__(*args)
|
|
13
12
|
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: xpdc
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: XPDC (X-Platform Device Connector) is designed to bridge the gap between devices across multiple platforms (Android, HarmonyOS, iOS).
|
|
5
|
+
Author-email: lanbaoshen <lanbaoshen@icloud.com>
|
|
6
|
+
Requires-Python: >=3.12
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: loguru>=0.7.3
|
|
10
|
+
Requires-Dist: pillow>=12.1.0
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<img src="logo.png" alt="pyecharts logo" width=200 />
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
# Introduction
|
|
18
|
+
|
|
19
|
+
XPDC (X-Platform Device Connector) is designed to bridge the gap between devices across multiple platforms (Android, HarmonyOS, iOS).
|
|
20
|
+
|
|
21
|
+
It allows users to operate devices on different platforms with the same set of code.
|
|
22
|
+
|
|
23
|
+
**Before using XPDC, you need to install the corresponding debug environment separately for each platform's device.**
|
|
24
|
+
|
|
25
|
+
Android is `adb`, HarmonyOS is `hdc`
|
|
26
|
+
|
|
27
|
+
# Installation
|
|
28
|
+
|
|
29
|
+
```shell
|
|
30
|
+
# Using uv
|
|
31
|
+
pip install uv
|
|
32
|
+
uv add xpdc
|
|
33
|
+
|
|
34
|
+
# Using pip
|
|
35
|
+
pip install xpdc
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
# Quick Start
|
|
39
|
+
|
|
40
|
+
## Install Dependencies
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from xpdc import connection, DeviceType
|
|
44
|
+
|
|
45
|
+
# Specify connect device type
|
|
46
|
+
conn = connection(DeviceType.ADB)
|
|
47
|
+
# conn = connection(DeviceType.HDC)
|
|
48
|
+
# iOS will support it in the future.
|
|
49
|
+
|
|
50
|
+
conn.cmd(['devices'])
|
|
51
|
+
|
|
52
|
+
device = conn.devices[0]
|
|
53
|
+
# You can also specify the device by its device id
|
|
54
|
+
# device = conn.device(device_id='device_id')
|
|
55
|
+
|
|
56
|
+
device.tap(500, 500)
|
|
57
|
+
device.type_text(text='lanbaoshen')
|
|
58
|
+
device.screenshot()
|
|
59
|
+
device.cmd(cmd=['shell', 'ls'])
|
|
60
|
+
device.shell(cmd=['ls'])
|
|
61
|
+
|
|
62
|
+
# For Android devices, additionally install ADBKeyboard.apk and enable it to support Chinese input.
|
|
63
|
+
device.install_and_set_adb_keyboard()
|
|
64
|
+
```
|
xpdc-0.1.1/PKG-INFO
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: xpdc
|
|
3
|
-
Version: 0.1.1
|
|
4
|
-
Summary: XPDC (X-Platform Device Connector) is designed to bridge the gap between devices across multiple platforms (Android, HarmonyOS, iOS).
|
|
5
|
-
Author-email: lanbaoshen <lanbaoshen@icloud.com>
|
|
6
|
-
Requires-Python: >=3.11
|
|
7
|
-
License-File: LICENSE
|
|
8
|
-
Requires-Dist: loguru>=0.7.3
|
|
9
|
-
Requires-Dist: pillow>=12.1.0
|
|
10
|
-
Dynamic: license-file
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: xpdc
|
|
3
|
-
Version: 0.1.1
|
|
4
|
-
Summary: XPDC (X-Platform Device Connector) is designed to bridge the gap between devices across multiple platforms (Android, HarmonyOS, iOS).
|
|
5
|
-
Author-email: lanbaoshen <lanbaoshen@icloud.com>
|
|
6
|
-
Requires-Python: >=3.11
|
|
7
|
-
License-File: LICENSE
|
|
8
|
-
Requires-Dist: loguru>=0.7.3
|
|
9
|
-
Requires-Dist: pillow>=12.1.0
|
|
10
|
-
Dynamic: license-file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|