Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/osfunapps/os_android_adb_handler-py
This repo aims to provide functional and simple ADB commands to control an Android device from code (externally).
https://github.com/osfunapps/os_android_adb_handler-py
adb android automation osapps osfunapps python
Last synced: 27 days ago
JSON representation
This repo aims to provide functional and simple ADB commands to control an Android device from code (externally).
- Host: GitHub
- URL: https://github.com/osfunapps/os_android_adb_handler-py
- Owner: osfunapps
- License: mit
- Created: 2021-02-08T08:15:41.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-02-08T08:23:21.000Z (almost 4 years ago)
- Last Synced: 2024-11-04T17:26:47.508Z (about 2 months ago)
- Topics: adb, android, automation, osapps, osfunapps, python
- Language: Python
- Homepage:
- Size: 7.81 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
Introduction
------------This module aims to provide functional and simple ADB commands to control an Android device from code (externally).
## Installation
Install via pip:```python
pip install os-android-adb-handler
```# Usage and examples:
* Make sure you have [adb](https://developer.android.com/studio/command-line/adb) installed and an Android device connected.Then just import the module and use it like so:
```python
from os_android_adb_handler import adb_handler# install an apk
adb_handler.install_apk(apk_path='path/to/apk/file.apk')# start an app
adb_handler.start_app(package_name='com.osapps.pacakge', path_to_first_activity='startup.MainActivity')# wait a bit for the app execution
time.sleep(7)# go right
adb_handler.dpad_right()# go up
adb_handler.dpad_up()# take a screen shot
adb_handler.take_ss('path/to/ss1.png')# go right
adb_handler.dpad_right()# click enter
adb_handler.enter()# take another ss
adb_handler.take_ss('path/to/second/ss2.png')# send a shell command
adb_handler.send_shell(command='run something')# send a custom key events
from os_android_adb_handler import key_events
adb_handler.key_event(key_events.KEYCODE_F)
adb_handler.key_event(key_events.KEYCODE_U)
adb_handler.key_event(key_events.KEYCODE_C)
adb_handler.key_event(key_events.KEYCODE_K)
adb_handler.key_event(key_events.KEYCODE_DEL)# remove an app
adb_handler.uninstall_app(package_name='com.osapps.pacakge')
```## Function signatures
```python
def start_app(package_name, path_to_first_activity):
"""
Will start an already installed App in the device.Args:
package_name: The app's package name
path_to_first_activity: The relative path to the first activity (like main.MainActivity)
"""def take_ss(ss_file_path):
"""
Will take a screen shot.Args:
ss_file_path: The destination path of the screen shot (file name, incl extension)
"""def install_apk(apk_path):
"""
Will install an APK file.Args:
apk_path: The path to your APK file.
"""def uninstall_app(package_name):
"""
Will uninstall an app.Args:
package_name: The app's package name
"""def go_back():
"""
Will navigate back
"""def enter():
"""
Will click the Enter key
"""def dpad_right():
"""
Will click the Right key
"""def dpad_left():
"""
Will click the Left key
"""def dpad_up():
"""
Will click the Up key
"""def dpad_down():
"""
Will click the Down key
"""def key_event(key):
"""
Will send a key event.
Args:
key: The key you want to send. You can use of the key_events keys
"""def send_input(event):
"""
Will send an input event
"""def send_shell(command):
"""
Will send a shell command
"""def adb(command):
"""
Will send an adb command
""".....
```## Licence
MIT