Package: appcommander
Command Android Apps from PythonUsesuiautomatorto automatically and safely control and navigate Android
apps.
The user can specify some app logic (series of screens and button clicks) that
is executed on your Android phone through ADB.WhyI wanted self-host my Nextcloud calendar with 1 command, from anywhere in the
world, no port-forwarding, no DNS stuff, no domain-name, no registrar
configuration no nothing. That includes complete Android phone configuration
automation for me. Some apps did not have, and perhaps may not want, a
configuration API. Configuring Android apps with automated key-presses is not
safe because an unexpected event may come up, e.g. a prompt for a phone update,
a call may come in etc.So I wanted a safe- and controlled way to configure the app, using the UI. This
repository verifies each step in an arbitrary script, verifies the button is
the desired button etc. If unexpected changes are expected, the script aborts.Also, each phone manufacturer has a different rooting process, this repo can
become a library to safely- and automatically root all (rootable) Android
phones automatically (except the user must enableADBthemselves).ExampleUsageFirst satisfy the prerequisites:pipinstallappcommanderConnect your phone, and tell this code which app you want to automate, and how:python-msrc.appcommander-aorg.torproject.android-v"16.6.3 RC 1"-t"DAVx5"appcommander-aorg.torproject.android-v"16.6.3 RC 1"-tDAVx5which is the same as:python-msrc.appcommander--app-nameorg.torproject.android\--version"16.6.3 RC 1"-torify"DAVx5"Or, to configure DAVx5:python-msrc.appcommander-aat.bitfire.davdroid-v"4.2.6"-nu\<your_nextcloud_username>-np<your_nextcloud_password>-o<your_onion_url>For more info, run:python-msrc.appcommander--helpTestingOne can simulate an android phone with:chmod+xemulate_android.sh
./emulate_android.shAnd then launch the emulated android phone with:.~/.profilecd~/.android/avd/android-small.avd/
rm*.lock
emulator-avdandroid-small-netdelaynone-netspeedfull-skin768x1280And run tests with:python-mpytestor to see live output, on any tests filenames containing substring:results:python-mpytest--capture=tee-sysTest CoverageDevelopers can use:condaenvcreate--fileenvironment.yml
condaactivateappcommander
python-mpytestCurrently the test coverage is65%. For type checking:mypy--disallow-untyped-calls--disallow-untyped-defstests/some_test.pyReleasing pip package updateTo udate the Python pip package, one can first satisfy the following requirements:pipinstall--upgradepipsetuptoolswheel
pipinstalltwineFollowed by updating the package with:rm-rdist
rm-rbuild
python3setup.pysdistbdist_wheel
python-mtwineuploaddist/\*Developer pip installmkdir-p~/bin
cpapk-ct.sh~/bin/apk-ct
chmod+x~/bin/apk-ctThen you can rebuild and locally re-install theappcommanderpip package the command:apk-ctUpdatingBuild the pip package with:pipinstall--upgradepipsetuptoolswheel
pipinstalltwineInstall the pip package locally with:rm-rdist
rm-rbuild
python-mbuild
pipinstall-e.Upload the pip package to the world with:rm-rdist
rm-rbuild
python-mbuild
python3-mtwineuploaddist/\*that installs the latest changes into the pip package locally (into your conda
environment).Show your app-flowTo show how your script works, run (along with any additional input args
required for that script):python-msrc.appcommander-a<package_name>-v<app_version>-f\<additionalarguments>For example:python-msrc.appcommander-a"at.bitfire.davdroid"-v"4.2.6"-f-nu\<some_filler>-np<some_filler>-o<some_filler>
python-msrc.appcommander-a"at.bitfire.davdroid"-v"4.2.6"-f-nu\asdf-npasdf-oasdf
python-msrc.appcommander-aorg.torproject.android-v"16.6.3 RC 1"\-f-t"DAVx5"