pybridge-sdk-android 0.3.0__py3-none-any.whl
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.
- pybridge/__init__.py +9 -0
- pybridge/android/__init__.py +1 -0
- pybridge/android/context.py +4 -0
- pybridge/android/intents.py +9 -0
- pybridge/android/permissions.py +7 -0
- pybridge/backend.py +13 -0
- pybridge/backend_manager.py +69 -0
- pybridge/bridge.py +43 -0
- pybridge/capabilities.py +29 -0
- pybridge/config.py +8 -0
- pybridge/device/__init__.py +0 -0
- pybridge/device/battery.py +25 -0
- pybridge/device/info.py +31 -0
- pybridge/exceptions.py +6 -0
- pybridge/hardware/__init__.py +1 -0
- pybridge/hardware/bluetooth.py +4 -0
- pybridge/hardware/camera.py +4 -0
- pybridge/hardware/location.py +4 -0
- pybridge/hardware/sensors.py +4 -0
- pybridge/intents.py +9 -0
- pybridge/logger.py +8 -0
- pybridge/permissions.py +9 -0
- pybridge/shell.py +59 -0
- pybridge/shizuku/__init__.py +1 -0
- pybridge/shizuku/client.py +13 -0
- pybridge/shizuku/executor.py +4 -0
- pybridge/system/__init__.py +1 -0
- pybridge/system/apps.py +11 -0
- pybridge/system/clipboard.py +7 -0
- pybridge/system/notifications.py +4 -0
- pybridge/system/packages.py +14 -0
- pybridge/system/power.py +7 -0
- pybridge/system/settings.py +9 -0
- pybridge/version.py +2 -0
- pybridge_sdk_android-0.3.0.dist-info/METADATA +45 -0
- pybridge_sdk_android-0.3.0.dist-info/RECORD +38 -0
- pybridge_sdk_android-0.3.0.dist-info/WHEEL +5 -0
- pybridge_sdk_android-0.3.0.dist-info/top_level.txt +1 -0
pybridge/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Android API modules
|
pybridge/backend.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from .backend import Backend
|
|
5
|
+
|
|
6
|
+
from .capabilities import Capabilities
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class BackendManager:
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def __init__(self):
|
|
14
|
+
|
|
15
|
+
self.capabilities = Capabilities()
|
|
16
|
+
|
|
17
|
+
self.backend = self.detect()
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def detect(self):
|
|
22
|
+
|
|
23
|
+
if self.root():
|
|
24
|
+
|
|
25
|
+
self.capabilities.root = True
|
|
26
|
+
|
|
27
|
+
return Backend.ROOT
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
if self.shizuku():
|
|
32
|
+
|
|
33
|
+
self.capabilities.shizuku = True
|
|
34
|
+
|
|
35
|
+
return Backend.SHIZUKU
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
return Backend.SHELL
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def root(self):
|
|
44
|
+
|
|
45
|
+
return os.system(
|
|
46
|
+
"su -c id >/dev/null 2>&1"
|
|
47
|
+
) == 0
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def shizuku(self):
|
|
52
|
+
|
|
53
|
+
return os.system(
|
|
54
|
+
"which rish >/dev/null 2>&1"
|
|
55
|
+
) == 0
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def info(self):
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
|
|
63
|
+
"backend":
|
|
64
|
+
self.backend.value,
|
|
65
|
+
|
|
66
|
+
"capabilities":
|
|
67
|
+
self.capabilities.as_dict()
|
|
68
|
+
|
|
69
|
+
}
|
pybridge/bridge.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from .backend_manager import BackendManager
|
|
2
|
+
from .device.info import Device
|
|
3
|
+
from .device.battery import Battery
|
|
4
|
+
|
|
5
|
+
from .android.intents import Intents
|
|
6
|
+
from .android.permissions import Permissions
|
|
7
|
+
|
|
8
|
+
from .system.apps import Apps
|
|
9
|
+
from .system.clipboard import Clipboard
|
|
10
|
+
from .system.notifications import Notifications
|
|
11
|
+
from .system.settings import Settings
|
|
12
|
+
|
|
13
|
+
from .hardware.camera import Camera
|
|
14
|
+
from .hardware.bluetooth import Bluetooth
|
|
15
|
+
from .hardware.sensors import Sensors
|
|
16
|
+
from .hardware.location import Location
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class Bridge:
|
|
20
|
+
|
|
21
|
+
def __init__(self):
|
|
22
|
+
|
|
23
|
+
self.backend = BackendManager()
|
|
24
|
+
|
|
25
|
+
self.device = Device()
|
|
26
|
+
self.battery = Battery()
|
|
27
|
+
|
|
28
|
+
self.intents = Intents()
|
|
29
|
+
self.permissions = Permissions()
|
|
30
|
+
|
|
31
|
+
self.apps = Apps()
|
|
32
|
+
self.clipboard = Clipboard()
|
|
33
|
+
self.notifications = Notifications()
|
|
34
|
+
self.settings = Settings()
|
|
35
|
+
|
|
36
|
+
self.camera = Camera()
|
|
37
|
+
self.bluetooth = Bluetooth()
|
|
38
|
+
self.sensors = Sensors()
|
|
39
|
+
self.location = Location()
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def info(self):
|
|
43
|
+
return self.backend.info()
|
pybridge/capabilities.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
class Capabilities:
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def __init__(self):
|
|
6
|
+
|
|
7
|
+
self.root = False
|
|
8
|
+
|
|
9
|
+
self.shizuku = False
|
|
10
|
+
|
|
11
|
+
self.android = False
|
|
12
|
+
|
|
13
|
+
self.shell = True
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def as_dict(self):
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
|
|
21
|
+
"root": self.root,
|
|
22
|
+
|
|
23
|
+
"shizuku": self.shizuku,
|
|
24
|
+
|
|
25
|
+
"android": self.android,
|
|
26
|
+
|
|
27
|
+
"shell": self.shell
|
|
28
|
+
|
|
29
|
+
}
|
pybridge/config.py
ADDED
|
File without changes
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
from pybridge.shell import Shell
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Battery:
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@property
|
|
10
|
+
def level(self):
|
|
11
|
+
|
|
12
|
+
result = Shell.exec(
|
|
13
|
+
"dumpsys battery | grep level"
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
try:
|
|
18
|
+
|
|
19
|
+
return int(
|
|
20
|
+
result.stdout.split(":")[1]
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
except:
|
|
24
|
+
|
|
25
|
+
return None
|
pybridge/device/info.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
from pybridge.shell import Shell
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Device:
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def prop(self, key):
|
|
10
|
+
|
|
11
|
+
return Shell.exec(
|
|
12
|
+
f"getprop {key}"
|
|
13
|
+
).stdout
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@property
|
|
18
|
+
def model(self):
|
|
19
|
+
|
|
20
|
+
return self.prop(
|
|
21
|
+
"ro.product.model"
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@property
|
|
27
|
+
def android(self):
|
|
28
|
+
|
|
29
|
+
return self.prop(
|
|
30
|
+
"ro.build.version.release"
|
|
31
|
+
)
|
pybridge/exceptions.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Hardware modules
|
pybridge/intents.py
ADDED
pybridge/logger.py
ADDED
pybridge/permissions.py
ADDED
pybridge/shell.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
|
|
2
|
+
import subprocess
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ShellResult:
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def __init__(
|
|
10
|
+
self,
|
|
11
|
+
code,
|
|
12
|
+
stdout,
|
|
13
|
+
stderr
|
|
14
|
+
):
|
|
15
|
+
|
|
16
|
+
self.code = code
|
|
17
|
+
|
|
18
|
+
self.stdout = stdout
|
|
19
|
+
|
|
20
|
+
self.stderr = stderr
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@property
|
|
25
|
+
def success(self):
|
|
26
|
+
|
|
27
|
+
return self.code == 0
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class Shell:
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@staticmethod
|
|
36
|
+
def exec(command):
|
|
37
|
+
|
|
38
|
+
result = subprocess.run(
|
|
39
|
+
|
|
40
|
+
command,
|
|
41
|
+
|
|
42
|
+
shell=True,
|
|
43
|
+
|
|
44
|
+
capture_output=True,
|
|
45
|
+
|
|
46
|
+
text=True
|
|
47
|
+
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
return ShellResult(
|
|
52
|
+
|
|
53
|
+
result.returncode,
|
|
54
|
+
|
|
55
|
+
result.stdout.strip(),
|
|
56
|
+
|
|
57
|
+
result.stderr.strip()
|
|
58
|
+
|
|
59
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Shizuku backend
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# System modules
|
pybridge/system/apps.py
ADDED
pybridge/system/power.py
ADDED
pybridge/version.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pybridge-sdk-android
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: A modular Android functionality bridge for Python
|
|
5
|
+
Author: thewhistledev
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Dynamic: requires-python
|
|
10
|
+
|
|
11
|
+
# PyBridge
|
|
12
|
+
|
|
13
|
+
Android functionality bridge for Python.
|
|
14
|
+
|
|
15
|
+
Version: 0.4.0
|
|
16
|
+
|
|
17
|
+
Author: thewhistledev
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- Backend system
|
|
22
|
+
- Root support
|
|
23
|
+
- Shizuku foundation
|
|
24
|
+
- Android intents
|
|
25
|
+
- App management
|
|
26
|
+
- Clipboard foundation
|
|
27
|
+
- Notifications foundation
|
|
28
|
+
- Hardware API foundation
|
|
29
|
+
|
|
30
|
+
## Example
|
|
31
|
+
|
|
32
|
+
from pybridge import bridge
|
|
33
|
+
|
|
34
|
+
bridge.intents.open_url('https://github.com')
|
|
35
|
+
|
|
36
|
+
## Roadmap
|
|
37
|
+
|
|
38
|
+
0.5.0:
|
|
39
|
+
- Real Android API bridge
|
|
40
|
+
- Camera support
|
|
41
|
+
- Bluetooth support
|
|
42
|
+
- Sensors
|
|
43
|
+
|
|
44
|
+
1.0.0:
|
|
45
|
+
Complete Android Python framework.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
pybridge/__init__.py,sha256=9bsk6iY2ZrHMq5XudV9HZ0rPiP3Q1CkGFxECRPf8lx8,161
|
|
2
|
+
pybridge/backend.py,sha256=BKEWrvW0UYrt5CerBt-vZ-msCXLTz-FSBMn5cXFHn84,140
|
|
3
|
+
pybridge/backend_manager.py,sha256=1SYDlj6BwNzbj0FLwLunCp4uHKaNssHuK_j4blQulBw,882
|
|
4
|
+
pybridge/bridge.py,sha256=f-Q_IOW_zXW5g8kofYM7Rp-zzcNauKwWu6Cw7f8B1KA,1069
|
|
5
|
+
pybridge/capabilities.py,sha256=CAlEmtkXdpGUzx_DKEbpdERUKJdYt4ALP8xn6N0J5Rw,357
|
|
6
|
+
pybridge/config.py,sha256=rXrZ2LxCCcCXs4S5Xe1u8CXKEAKacH3tbvlOcUEbqu4,115
|
|
7
|
+
pybridge/exceptions.py,sha256=yEjPA62CWCj53XLOzvdlGI0YY5DV9Uh5o5cbyC3SyG4,86
|
|
8
|
+
pybridge/intents.py,sha256=HmSXuIA1tE9AyjEP14lo9HvvPvsxv-PqSDpAYL7iv0s,174
|
|
9
|
+
pybridge/logger.py,sha256=Ksgl2Kfv2hWeZyucAU8FWncW141kzmxexpvZsDBlldI,138
|
|
10
|
+
pybridge/permissions.py,sha256=wEQi-DDqSnHX7XRZahBZkmqfbLt3LK_Bmwdfne-sPlU,203
|
|
11
|
+
pybridge/shell.py,sha256=kijbW79tXyPRie-UbW7fWPTdjDk6480swC2Mo2CmX90,637
|
|
12
|
+
pybridge/version.py,sha256=Ffqdd4x6xPFVl4qI2rtgWHcBfmm1QZbqehAEuXpkgi0,50
|
|
13
|
+
pybridge/android/__init__.py,sha256=X0Srxk0fYUl8Ake0aWQRWlHULAFpGii5nyln5qjxdWU,21
|
|
14
|
+
pybridge/android/context.py,sha256=auuHHIgS7X_l7ZMWRVhK_YR2G4NxyI4hf7X48i7y60g,61
|
|
15
|
+
pybridge/android/intents.py,sha256=XgKMgq9V9A1SQbV2MwVIP6pMWHKwGnUUyPCxHRibiZs,179
|
|
16
|
+
pybridge/android/permissions.py,sha256=_PIuneyAtCDtiib70QgcdoRl2TUMp-tSuROZHfAMzlU,130
|
|
17
|
+
pybridge/device/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
|
+
pybridge/device/battery.py,sha256=OEeKQv8GYwIuS3hxUxaQ-EtwV9B7sqEmFqXYnQcTok8,312
|
|
19
|
+
pybridge/device/info.py,sha256=Y_ylsG90g6eRCOOrvek1G4qftS2OWArEoiSeivsz0tE,374
|
|
20
|
+
pybridge/hardware/__init__.py,sha256=s5IVjCOY6RbM0wpMRBtaw78F7fxxy0_TEGHGYGwwIeE,18
|
|
21
|
+
pybridge/hardware/bluetooth.py,sha256=8owhVKHbdJ9XqD_ybVaH0ozcywPFKpqRo69eeJwQqKg,63
|
|
22
|
+
pybridge/hardware/camera.py,sha256=ntmyf7JW7kriyA9MJng6EKp4_wHstmT4LtZ3f8k7a9I,60
|
|
23
|
+
pybridge/hardware/location.py,sha256=f5wdS6gAzF-vaOJLUC-s0-TB7VQoUkUNVhET-N0FIjs,62
|
|
24
|
+
pybridge/hardware/sensors.py,sha256=k3F5S2BPnyAoeHRl0Gfd78QtYbKF82gv9d-RT_sS2Ow,61
|
|
25
|
+
pybridge/shizuku/__init__.py,sha256=qqaa5ceeFn8JtH5E_ta7fNYkmAzymqJv4IWXPHMnMvs,17
|
|
26
|
+
pybridge/shizuku/client.py,sha256=zOmmFcFXDV3tTSlHkbEvuwrcefg0LKFDcATlZDFjnwk,226
|
|
27
|
+
pybridge/shizuku/executor.py,sha256=faQXuMeqjJ-GknoDyAQOTOVLIP_uplQ1uWGnfdhZvnw,75
|
|
28
|
+
pybridge/system/__init__.py,sha256=t5n6VskkQ1PSU8N1yyxftYL1BIJImYaShU1HnIzTjpA,16
|
|
29
|
+
pybridge/system/apps.py,sha256=Ed1522D8EHEDoywt5jIiHw8cyMbWHOQ3XjFEhLZOH7M,180
|
|
30
|
+
pybridge/system/clipboard.py,sha256=8FIbTiMdxNgXFDcz3dwqJ8zvy5MYZbj1W_oynbW5fks,106
|
|
31
|
+
pybridge/system/notifications.py,sha256=EQugCIjDrRup80eS9Ye_utwjrbx7CWH8kEGtJbdv65o,78
|
|
32
|
+
pybridge/system/packages.py,sha256=DSmFVHgf-G2agC0F0zQGLBxRzO7N7fDdtL3J50SDm-c,255
|
|
33
|
+
pybridge/system/power.py,sha256=RyJEh7MQsJ5CMXqwaCASdIGV9TlAl-52sazS69sgotI,106
|
|
34
|
+
pybridge/system/settings.py,sha256=aiQpUra_pw-o1PpRxRiCzkJ8AlpBlIWLkclaJLDbnGE,162
|
|
35
|
+
pybridge_sdk_android-0.3.0.dist-info/METADATA,sha256=XflT5r8gaYruVmq9LgADsYoFyLtV1kJDdChaVXK-jFw,741
|
|
36
|
+
pybridge_sdk_android-0.3.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
37
|
+
pybridge_sdk_android-0.3.0.dist-info/top_level.txt,sha256=Xg6g5Bue-9WdrWfUgylpVb5JkgpSHilgAddduW6mKi4,9
|
|
38
|
+
pybridge_sdk_android-0.3.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pybridge
|