header image

Do you want to gather data from multiple Android devices remotely at the same time or control the devices? Absolutely possible. Although digital markets have solutions already, I wanted to do the task bit differently with common server management tools: SaltStack.

It turned out to be possible: Android devices can successfully be controlled with SaltStack.

Table of Contents


Why?

Imagine you have dozens or hundreds Android devices which require remote management. You don't like market solutions and want to use pure Linux tools for direct & raw access instead? If yes, this article is for you.

Basically, with SaltStack, you can

  • run commands & control applications of multiple Android devices simultaneosly

  • gather statistics such as temperature or GNSS (Global Navigation Satellite System) information from multiple Android devices simultaneosly

  • manage Android devices simultaneosly

  • classify & create separate groups for Android devices

post image
Do you want something like this? It is possible with SaltStack.

About SaltStack

SaltStack is usually used to control multiple remote clients (minions) with a central server (master) or with multiple masters. In the most common use cases, both minions and master(s) are regular laptops, desktop computers or server computers.

Other solutions to centrally manage computers exist, too. Such as Chef, Puppet & Ansible.

There are many good articles covering SaltStack and, additionally, a compherensive SaltStack documentation.

Android and SaltStack

I came up with experimenting with SaltStack on Android due to various reasons: potential, curiosity and as a result of a simple fact that Android mobile phones/tablets are just Linux-based computers with mobile stuff added on the top.

Regardless of the most target systems of SaltStack, launching application processes and accessing system data remotely on Android is possible, as well.

For instance, launching Android app NewPipe from Salt master computer on target Android system android_minion:

1# Launch NewPipe app main activity window remotely from Salt master computer
2sudo salt 'android_minion' cmd.run "am start -a android.intent.action.MAIN -n org.schabi.newpipe/.player.MainActivity"
3
4# Launch NewPipe app video player window remotely from Salt master computer
5sudo salt 'android_minion' cmd.run "am start -a android.intent.action.MAIN -n org.schabi.newpipe/.player.MainVideoPlayer"
6
7# Launch NewPipe app settings window remotely from Salt master computer
8sudo salt 'android_minion' cmd.run "am start -a android.intent.action.MAIN -n org.schabi.newpipe/.settings.SettingsActivity"

or Android tethering settings with:

1# Launch Android tethering settings remotely from Salt master computer
2sudo salt 'android_minion' cmd.run "am start -a android.intent.action.MAIN -n com.android.settings/.TetherSettings"

These commands open the requested application window on the mobile screen and start the app process on a Android phone/tablet.

Example outputs

post image
Gathering basic processor & process information from an Android minion computer (Samsung S5 Neo mobile phone) with SaltStack.
post image
CPU flags and short information and storage devices of an Android minion. Before that, Android minion must be accepted by Salt master (salt-key command on the master computer)
post image
Gathering basic APK package information from an Android minion (Samsung S5 Neo mobile phone) with SaltStack.

Configuration

As prerequisite you need

  • an Android system to which you can establish a SSH connection.

  • Custom SaltStack build is required for the Android

  • Obviously, network connection between minion & master computers must be available.

  • Rooted Android preferable, although might not be required

post image
Running SaltStack locally on an Android mobile phone with salt-call. Basic network interface information gathered from the Android system.

Other SaltStack Deployment Projects

You can find my sample SaltStack project for common Linux & Windows environments on GitHub (SaltStack - GIS workstation setup).