Yaky's
Part of the Volty MIR project, but can be used for non-interactive applications.
Volty MIR - [M]ap + [I]intelligent [R]everse Camera
To display maps, I need a device that has:
My trusty and crusty old Samsung Galaxy S5 has all that functionality, even video output to HDMI via MHL. I found the MHL cable at a thrift store for a dollar or so.
MHL (Mobile High Definition Link)
What I want the device to do is:
For the map/navigation application, I chose Organic Maps, as it is lightweight, has a great interface, and works offline. I have used it for many years now.
Other options are:
OsmAnd - more customizable, the OG of OpenStreetMap navigation
Osmin - similar to Organic Maps, and works great on Linux (PinePhone etc.)
This does not work on Samsung devices!
Boot to fastboot mode (aka download mode)
Install fastboot on main machine and run
fastboot oem off-mode-charge 0
This worked for Google Nexus 7, and probably works for most Google devices.
Be careful with this - if battery gets too low, device will be stuck in an annoying constantly crashing reboot loop until it is sufficiently charged. See below for automatic shutdown on condition.
This is what I ended up doing.
Rooted device with Magisk, and then downloaded and installed Magisk Autoboot module.
Although their documentation states it works for Android 7, I could not get it to work with Lineage 14 (Android 7 equivalent) for some reason. On Lineage 15, it works and my S5 takes about a minute to boot after connecting power.
This is a somewhat strange way to boot some Samsung devices: It relies on replacing the binary that displays the battery charge animation with a script that (re)boots the device instead. Requires root.
Go to /system/bin and find a file named "playplm", "plm", or "lpm". Then edit it to contain only:
#!/system/bin/sh /system/bin/reboot
I did not find any of these files on my S5, so I don't know if this works.
Termux is a terminal emulator for Android, which can run with and without root.
I installed Termux and Termux:Boot via F-Droid, and ran Termux:Boot once to initialize it.
Some references:
Per instructions, I created a startup script
mkdir -p ~/.termux/boot nano ~/.termux/boot/start-maps.sh
#!/data/data/com.termux/files/usr/bin/sh am start app.organicmaps/.SplashActivity
Easier way is to install and open Activity Launcher, find the app and its name, then find a list of activities it has, and find the main activity. Then use those names in the script above.
In my case:
Another possibility is to get this information through ADB. Allow ADB access and connect mobile device to main machine. Run these commands on main machine.
Get a list of applications via ADB:
adb shell pm list packages -f -3
Get a list of activities via ADB:
PACKAGE=package.name adb shell dumpsys package | grep -Eo $(printf "^[[:space:]]+[0-9a-f]+[[:space:]]+%s/[^[:space:]]+" "${PACKAGE}") | grep -oE "[^[:space:]]+$"
I have not tried this. Might be easier if you don't like the terminal.
Easer is an open-source automation tool like Tasker. While it can be used for some scripting, I was unable to get it to launch Organic Maps on boot.
I implemented this using Termux, Termux:API and crontab.
This requires root, because shutdown is a system function.
I rooted my device using Magisk.
To check the battery status, I used Termux and Termux:API extension.
To check battery status:
termux-battery-status
This returns JSON, which can be parsed using jq.
pkg install jq
Now I can extract the values I need, for example:
batt_pct=`termux-battery-status | jq -r '.percentage'` batt_status=`termux-battery-status |jq -r '.status'`
To shut down Android:
su -c "reboot -p"
These are the various shutdown commands I found for Android.
Most of them seem to run fine in user's Termux session, but when they are run as a part of a cronjob, they run slowly, are buggy, and sometimes reboot the phone instead of shutting down:
sudo reboot -p sudo /system/bin/svc power shutdown sudo /system/bin/svc power reboot -p sudo am start -a android.intent.action.ACTION_REBOOT
So stick with
su -c "reboot -p"
Putting it all together: (with an extra spoken message using another API)
batt_pct=`termux-battery-status | jq -r '.percentage'` batt_status=`termux-battery-status |jq -r '.status'` if [ $batt_pct -lt 60 ] && [ "$batt_status" = 'DISCHARGING' ] then termux-tts-speak 'Low power. Shutting down.' su -c "reboot -p" fi
I put this in a file at
/data/data/com.termux/files/usr/bin/yaky-auto-shutdown
This directory is in $PATH, so no need to specify the full path in the future.
Test by running in Termux:
yaky-auto-shutdown
To automate this script, I used crontab. First, install it through Termux:
pkg install cronie
Edit crontab:
crontab -e
Add an entry to run the auto-shutdown script
* * * * * yaky-auto-shutdown
To run the cron daemon, add another script to execute at boot:
nano ~/.termux/boot/start-cron.sh
#!/data/data/com.termux/files/usr/bin/sh termux-wake-lock crond
This will set a wakelock to prevent Android from killing the long-running process, and then launch crond.
Every minute, cron will run the script, which will check the battery percentage and status, and shut down the device if the specified conditions are met. Although shutdown command requires root, root privileges will be provided to Termux as necessary (as long as they have been provided)
To reduce wear and damage to an already-old battery, I installed Battery Charge Limit app to keep the device charge between 70% and 80%. This requires root, of course.
Battery Charge Limit on F-Droid
There are several Magisk modules to handle charging and automatic shutdown, but I did not have much luck with those:
Advanced Charging Controller (ACC) on GitHub
Input Power Control (IP Control) on GitHub
It appears that the MHL cable does not supply enough current (pun intended) to keep the device charged, so it is gradually losing battery charge even though it is plugged in. Battery status shows current of 300mA when charging via MHL cable, and 450mA when charging through a regular USB cable connected to a laptop USB port.
I am considering combining the MHL USB cable with a regular charging USB cable, or going battery-less.