pybridge-sdk-android 0.3.0__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.
Files changed (46) hide show
  1. pybridge_sdk_android-0.3.0/MANIFEST.in +2 -0
  2. pybridge_sdk_android-0.3.0/PKG-INFO +45 -0
  3. pybridge_sdk_android-0.3.0/README.md +35 -0
  4. pybridge_sdk_android-0.3.0/pybridge/__init__.py +9 -0
  5. pybridge_sdk_android-0.3.0/pybridge/android/__init__.py +1 -0
  6. pybridge_sdk_android-0.3.0/pybridge/android/context.py +4 -0
  7. pybridge_sdk_android-0.3.0/pybridge/android/intents.py +9 -0
  8. pybridge_sdk_android-0.3.0/pybridge/android/permissions.py +7 -0
  9. pybridge_sdk_android-0.3.0/pybridge/backend.py +13 -0
  10. pybridge_sdk_android-0.3.0/pybridge/backend_manager.py +69 -0
  11. pybridge_sdk_android-0.3.0/pybridge/bridge.py +43 -0
  12. pybridge_sdk_android-0.3.0/pybridge/capabilities.py +29 -0
  13. pybridge_sdk_android-0.3.0/pybridge/config.py +8 -0
  14. pybridge_sdk_android-0.3.0/pybridge/device/__init__.py +0 -0
  15. pybridge_sdk_android-0.3.0/pybridge/device/battery.py +25 -0
  16. pybridge_sdk_android-0.3.0/pybridge/device/info.py +31 -0
  17. pybridge_sdk_android-0.3.0/pybridge/exceptions.py +6 -0
  18. pybridge_sdk_android-0.3.0/pybridge/hardware/__init__.py +1 -0
  19. pybridge_sdk_android-0.3.0/pybridge/hardware/bluetooth.py +4 -0
  20. pybridge_sdk_android-0.3.0/pybridge/hardware/camera.py +4 -0
  21. pybridge_sdk_android-0.3.0/pybridge/hardware/location.py +4 -0
  22. pybridge_sdk_android-0.3.0/pybridge/hardware/sensors.py +4 -0
  23. pybridge_sdk_android-0.3.0/pybridge/intents.py +9 -0
  24. pybridge_sdk_android-0.3.0/pybridge/logger.py +8 -0
  25. pybridge_sdk_android-0.3.0/pybridge/permissions.py +9 -0
  26. pybridge_sdk_android-0.3.0/pybridge/shell.py +59 -0
  27. pybridge_sdk_android-0.3.0/pybridge/shizuku/__init__.py +1 -0
  28. pybridge_sdk_android-0.3.0/pybridge/shizuku/client.py +13 -0
  29. pybridge_sdk_android-0.3.0/pybridge/shizuku/executor.py +4 -0
  30. pybridge_sdk_android-0.3.0/pybridge/system/__init__.py +1 -0
  31. pybridge_sdk_android-0.3.0/pybridge/system/apps.py +11 -0
  32. pybridge_sdk_android-0.3.0/pybridge/system/clipboard.py +7 -0
  33. pybridge_sdk_android-0.3.0/pybridge/system/notifications.py +4 -0
  34. pybridge_sdk_android-0.3.0/pybridge/system/packages.py +14 -0
  35. pybridge_sdk_android-0.3.0/pybridge/system/power.py +7 -0
  36. pybridge_sdk_android-0.3.0/pybridge/system/settings.py +9 -0
  37. pybridge_sdk_android-0.3.0/pybridge/version.py +2 -0
  38. pybridge_sdk_android-0.3.0/pybridge_sdk_android.egg-info/PKG-INFO +45 -0
  39. pybridge_sdk_android-0.3.0/pybridge_sdk_android.egg-info/SOURCES.txt +44 -0
  40. pybridge_sdk_android-0.3.0/pybridge_sdk_android.egg-info/dependency_links.txt +1 -0
  41. pybridge_sdk_android-0.3.0/pybridge_sdk_android.egg-info/top_level.txt +1 -0
  42. pybridge_sdk_android-0.3.0/pyproject.toml +16 -0
  43. pybridge_sdk_android-0.3.0/setup.cfg +4 -0
  44. pybridge_sdk_android-0.3.0/setup.py +13 -0
  45. pybridge_sdk_android-0.3.0/tests/test_030.py +7 -0
  46. pybridge_sdk_android-0.3.0/tests/test_040.py +9 -0
@@ -0,0 +1,2 @@
1
+ include README.md
2
+ include LICENSE
@@ -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,35 @@
1
+ # PyBridge
2
+
3
+ Android functionality bridge for Python.
4
+
5
+ Version: 0.4.0
6
+
7
+ Author: thewhistledev
8
+
9
+ ## Features
10
+
11
+ - Backend system
12
+ - Root support
13
+ - Shizuku foundation
14
+ - Android intents
15
+ - App management
16
+ - Clipboard foundation
17
+ - Notifications foundation
18
+ - Hardware API foundation
19
+
20
+ ## Example
21
+
22
+ from pybridge import bridge
23
+
24
+ bridge.intents.open_url('https://github.com')
25
+
26
+ ## Roadmap
27
+
28
+ 0.5.0:
29
+ - Real Android API bridge
30
+ - Camera support
31
+ - Bluetooth support
32
+ - Sensors
33
+
34
+ 1.0.0:
35
+ Complete Android Python framework.
@@ -0,0 +1,9 @@
1
+ """PyBridge Android Bridge Framework"""
2
+
3
+ __title__ = 'pybridge'
4
+ __version__ = '0.4.0'
5
+ __author__ = 'thewhistledev'
6
+
7
+ from .bridge import Bridge
8
+
9
+ bridge = Bridge()
@@ -0,0 +1 @@
1
+ # Android API modules
@@ -0,0 +1,4 @@
1
+ class Context:
2
+
3
+ def available(self):
4
+ return False
@@ -0,0 +1,9 @@
1
+ from pybridge.shell import Shell
2
+
3
+
4
+ class Intents:
5
+
6
+ def open_url(self, url):
7
+ return Shell.exec(
8
+ f'am start -a android.intent.action.VIEW -d {url}'
9
+ )
@@ -0,0 +1,7 @@
1
+ class Permissions:
2
+
3
+ def check(self, permission):
4
+ return False
5
+
6
+ def request(self, permission):
7
+ return False
@@ -0,0 +1,13 @@
1
+
2
+ from enum import Enum
3
+
4
+
5
+ class Backend(Enum):
6
+
7
+ ROOT = "root"
8
+
9
+ SHIZUKU = "shizuku"
10
+
11
+ SHELL = "shell"
12
+
13
+ ANDROID = "android_api"
@@ -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
+ }
@@ -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()
@@ -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
+ }
@@ -0,0 +1,8 @@
1
+ class Config:
2
+
3
+ def __init__(self):
4
+ self.backend = 'auto'
5
+ self.debug = False
6
+
7
+
8
+ config = Config()
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
@@ -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
+ )
@@ -0,0 +1,6 @@
1
+ class PyBridgeError(Exception):
2
+ pass
3
+
4
+
5
+ class BackendError(PyBridgeError):
6
+ pass
@@ -0,0 +1 @@
1
+ # Hardware modules
@@ -0,0 +1,4 @@
1
+ class Bluetooth:
2
+
3
+ def available(self):
4
+ return False
@@ -0,0 +1,4 @@
1
+ class Camera:
2
+
3
+ def available(self):
4
+ return False
@@ -0,0 +1,4 @@
1
+ class Location:
2
+
3
+ def available(self):
4
+ return False
@@ -0,0 +1,4 @@
1
+ class Sensors:
2
+
3
+ def available(self):
4
+ return False
@@ -0,0 +1,9 @@
1
+ from pybridge.shell import Shell
2
+
3
+
4
+ class Intent:
5
+
6
+ def open(self, url):
7
+ return Shell.exec(
8
+ f'am start -a android.intent.action.VIEW -d {url}'
9
+ )
@@ -0,0 +1,8 @@
1
+ import logging
2
+
3
+ logging.basicConfig(
4
+ level=logging.INFO,
5
+ format='[PyBridge] %(message)s'
6
+ )
7
+
8
+ logger = logging.getLogger('PyBridge')
@@ -0,0 +1,9 @@
1
+ class Permissions:
2
+
3
+ def check(self, permission):
4
+ return False
5
+
6
+ def request(self, permission):
7
+ raise NotImplementedError(
8
+ 'Android permission bridge required'
9
+ )
@@ -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,13 @@
1
+ from pybridge.shell import Shell
2
+
3
+
4
+ class ShizukuClient:
5
+
6
+ def available(self):
7
+ return Shell.exec('which rish').success
8
+
9
+
10
+ def run(self, command):
11
+ return Shell.exec(
12
+ 'rish ' + command
13
+ )
@@ -0,0 +1,4 @@
1
+ class ShizukuExecutor:
2
+
3
+ def execute(self, command):
4
+ return None
@@ -0,0 +1 @@
1
+ # System modules
@@ -0,0 +1,11 @@
1
+ from pybridge.shell import Shell
2
+
3
+
4
+ class Apps:
5
+
6
+ def list(self):
7
+ result = Shell.exec(
8
+ 'pm list packages'
9
+ )
10
+
11
+ return result.stdout.splitlines()
@@ -0,0 +1,7 @@
1
+ class Clipboard:
2
+
3
+ def copy(self, text):
4
+ return False
5
+
6
+ def paste(self):
7
+ return None
@@ -0,0 +1,4 @@
1
+ class Notifications:
2
+
3
+ def send(self, title, message):
4
+ return False
@@ -0,0 +1,14 @@
1
+ from pybridge.shell import Shell
2
+
3
+
4
+ class Packages:
5
+
6
+ def list(self):
7
+ result = Shell.exec(
8
+ 'pm list packages'
9
+ )
10
+
11
+ return [
12
+ x.replace('package:', '')
13
+ for x in result.stdout.splitlines()
14
+ ]
@@ -0,0 +1,7 @@
1
+ from pybridge.shell import Shell
2
+
3
+
4
+ class Power:
5
+
6
+ def reboot(self):
7
+ return Shell.exec('reboot')
@@ -0,0 +1,9 @@
1
+ from pybridge.shell import Shell
2
+
3
+
4
+ class Settings:
5
+
6
+ def get(self, name):
7
+ return Shell.exec(
8
+ f'settings get system {name}'
9
+ ).stdout
@@ -0,0 +1,2 @@
1
+ __version__ = '0.4.0'
2
+ __author__ = 'thewhistledev'
@@ -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,44 @@
1
+ MANIFEST.in
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ pybridge/__init__.py
6
+ pybridge/backend.py
7
+ pybridge/backend_manager.py
8
+ pybridge/bridge.py
9
+ pybridge/capabilities.py
10
+ pybridge/config.py
11
+ pybridge/exceptions.py
12
+ pybridge/intents.py
13
+ pybridge/logger.py
14
+ pybridge/permissions.py
15
+ pybridge/shell.py
16
+ pybridge/version.py
17
+ pybridge/android/__init__.py
18
+ pybridge/android/context.py
19
+ pybridge/android/intents.py
20
+ pybridge/android/permissions.py
21
+ pybridge/device/__init__.py
22
+ pybridge/device/battery.py
23
+ pybridge/device/info.py
24
+ pybridge/hardware/__init__.py
25
+ pybridge/hardware/bluetooth.py
26
+ pybridge/hardware/camera.py
27
+ pybridge/hardware/location.py
28
+ pybridge/hardware/sensors.py
29
+ pybridge/shizuku/__init__.py
30
+ pybridge/shizuku/client.py
31
+ pybridge/shizuku/executor.py
32
+ pybridge/system/__init__.py
33
+ pybridge/system/apps.py
34
+ pybridge/system/clipboard.py
35
+ pybridge/system/notifications.py
36
+ pybridge/system/packages.py
37
+ pybridge/system/power.py
38
+ pybridge/system/settings.py
39
+ pybridge_sdk_android.egg-info/PKG-INFO
40
+ pybridge_sdk_android.egg-info/SOURCES.txt
41
+ pybridge_sdk_android.egg-info/dependency_links.txt
42
+ pybridge_sdk_android.egg-info/top_level.txt
43
+ tests/test_030.py
44
+ tests/test_040.py
@@ -0,0 +1,16 @@
1
+ [build-system]
2
+ requires = ['setuptools>=61', 'wheel']
3
+ build-backend = 'setuptools.build_meta'
4
+
5
+ [project]
6
+ name = 'pybridge-sdk-android'
7
+ version = '0.3.0'
8
+ description = 'A modular Android functionality bridge for Python'
9
+ readme = 'README.md'
10
+ requires-python = '>=3.8'
11
+
12
+ authors = [
13
+ {name='thewhistledev'}
14
+ ]
15
+
16
+ license = {text='MIT'}
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,13 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name='pybridge-sdk-android',
5
+ version='0.3.0',
6
+ author='thewhistledev',
7
+ description='A modular Android functionality bridge for Python',
8
+ long_description=open('README.md', encoding='utf-8').read(),
9
+ long_description_content_type='text/markdown',
10
+ packages=find_packages(),
11
+ python_requires='>=3.8',
12
+ license='MIT',
13
+ )
@@ -0,0 +1,7 @@
1
+ from pybridge import bridge
2
+
3
+ print('PyBridge 0.3.0 Test')
4
+
5
+ print(bridge.info())
6
+
7
+ print(bridge.device.model)
@@ -0,0 +1,9 @@
1
+ from pybridge import bridge
2
+
3
+ print('PyBridge 0.4.0 Test')
4
+
5
+ print(bridge.info())
6
+
7
+ print(bridge.device.model)
8
+
9
+ print(bridge.apps.list())