Skip to main content

handles spaces, accents and other sneaky characters in ADB commands

Project description

handles spaces, accents and other sneaky characters in ADB commands

Tested against Windows / Python 3.11 / Anaconda

pip install adbeasykey

from adbeasykey import AdbEasyKey
adbpath = r"C:\Android\android-sdk\platform-tools\adb.exe"
serial_number = "127.0.0.1:5555"
adb = AdbEasyKey(adbpath, serial_number, use_busybox=False) # if use_busybox is True, busybox will be used to decode the base64-encoded command
adb.connect_to_device_ps()
adb.connect_to_device_subprocess()
text = f'"it\'s me", he said then he went away "Montréal, über, 12.89, Mère, Françoise, noël, 889 groß"""'
adb.install_adb_keyboard()
adb.input_text_adb_keyboard_ps(
    text, change_back=True, sleeptime=(0, 0), add_exit=True
)  # preserves accents - suffix _ps is for use Windows Powershell
adb.input_text_adb_keyboard_subprocess(
    text, change_back=True, sleeptime=(0.1, 0.2), add_exit=True
)  # preserves accents
adb.keyevents.KEYCODE_A.press_ps()
adb.keyevents.KEYCODE_A.press_subproc()
adb.keyevents.KEYCODE_A.longpress_subproc()
adb.keyevents.KEYCODE_A.longpress_ps()
adb.input_text_ps(text)  # doesn't preserve accents
adb.input_text_ps(text, remove_accents=True)  # ç -> c
adb.input_text_ps(text, sleeptime=(0.1, 0.2), remove_accents=True) # one by one

adb.input_text_subprocess(text)  # doesn't preserve accents
adb.input_text_subprocess(text, remove_accents=True)  # ç -> c
adb.input_text_subprocess(text, sleeptime=(0.1, 0.2), remove_accents=True)
stdout, stderr = adb.adb_shell_ps("ls / -1 -R -i -H -las")
stdout, stderr = adb.adb_shell_ps("ls /data")  # no permission
stdout, stderr = adb.adb_shell_ps("ls /data", su=True)  # permission
stdout, stderr = adb.adb_shell_ps('mkdir "/sdcard/bub ö äß"')
stdout, stderr = adb.adb_shell_ps("ls /sdcard/")
stdout, stderr = adb.adb_shell_subprocess("ls / -1 -R -i -H -las")
stdout, stderr = adb.adb_shell_subprocess("ls /data")  # no permission
stdout, stderr = adb.adb_shell_subprocess("ls /data", su=True)  # permission
stdout, stderr = adb.adb_shell_subprocess('mkdir "/sdcard/#gx bub ö äß"')
stdout, stderr = adb.adb_shell_subprocess("ls /sdcard/")
stdout, stderr = adb.adb_ps(
    cmd=r"push C:\Users\hansc\Downloads\Roger LeRoy Miller, Daniel K. Benjamin, Douglass C. North - The Economics of Public Issues-Pearson College Div (2017).pdf /sdcard/Download/testbba.pdf"
)
stdout, stderr = adb.adb_subprocess(
    cmd=r"push C:\Users\hansc\Downloads\Roger LeRoy Miller, Daniel K. Benjamin, Douglass C. North - The Economics of Public Issues-Pearson College Div (2017).pdf /sdcard/Download/testbba.pdf"
)

stdout, stderr = adb.adb_shell_ps(
    "input swipe 600 600 0 0 1000\ninput swipe 0 0 600 600 1000",
)
adb.is_keyboard_shown()
adb.get_active_keyboard()
adb.change_to_adb_keyboard()
adb.change_keyboard(
    keyboard="com.android.inputmethod.latin/.LatinIME",
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adbeasykey-0.10.tar.gz (26.2 kB view details)

Uploaded Source

Built Distribution

adbeasykey-0.10-py3-none-any.whl (26.7 kB view details)

Uploaded Python 3

File details

Details for the file adbeasykey-0.10.tar.gz.

File metadata

  • Download URL: adbeasykey-0.10.tar.gz
  • Upload date:
  • Size: 26.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for adbeasykey-0.10.tar.gz
Algorithm Hash digest
SHA256 4886c2bbe81c08b7611ff46ca005d4b73e49fce3f8f9188ab376a32c0ae5216b
MD5 95c217b9d455ca7ed05dc139b0773033
BLAKE2b-256 542513f982bb2351e825529e9f7b791f1c7157d970849370c6f52e809beb8f7a

See more details on using hashes here.

File details

Details for the file adbeasykey-0.10-py3-none-any.whl.

File metadata

  • Download URL: adbeasykey-0.10-py3-none-any.whl
  • Upload date:
  • Size: 26.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for adbeasykey-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 04dc0c713b34660f31eebd61633141d911d2c07c7ac022894be2811017d3560b
MD5 f2da6b56531dbac58c3bc3727ac8cdc0
BLAKE2b-256 6aa769eed7779ff448a08de418a2a597fe9d134048db3e1de4391b5246831385

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page