Brothers and sisters, fellow Monks (lend me your ears),
I have recently discovered that there is still quite a lot of hope for using a smartphone as a tool for empowering people and not enterprises. Android is providing a very potent program: the Android Debug Bridge (ADB) which communicates with an Android device connected to your desktop (via USB or in same wifi network). With this program, one can tell the device to wake up, to enter the passcode of the screensaver, to navigate to the home screen, to open apps, to close apps, to swipe, to click, to input text. To get readings from sensors, to get a screenshot or a screenvideo and finally to dump the current screen's UI as XML which can then be parsed to find widgets of interest, e.g. a button to click, a textbox to enter text, a list of contacts, etc.
The two main problems with controlling your smart device in such a way are: 1) Android API differences between versions, so standard apps or widgets are named differently. 2) Android remembers to notify you about something when in the middle of controlling an app and steals the focus. But neither of these problems is insurmountable.
The idea of controlling a device from my desktop is very appealing. In fact, I do not use a real device but an emulator (A note of warning here, better use an emulator or an unimportant phone).
At first a friend wanted to keep tapping on an app in order to gain some points for an idiotic competition. Then I wanted to send viber and skype messages from the command line of my linux terminal. And so I have set out to make a thin wrapper to the ADB for Perl. There are a lot of such wrappers for a lot of environments but I did not see one for Perl yet. So here it is : Android::ElectricSheep::Automator
use Android::ElectricSheep::Automator; my $mother = Android::ElectricSheep::Automator->new({ 'configfile' => $configfile, 'verbosity' => 1, # we already have a device connected and ready to control 'device-is-connected' => 1, }); $mother->tap({position=>[1,2]}); use Android::ElectricSheep::Automator::Plugins::Viber; my $vib = Android::ElectricSheep::Automator::Plugins::Viber->new({ configfile=>'config/plugins/viber.conf', 'device-is-connected' => 1 +}); $vib->open_viber_app(); $vib->send_message({recipient=>'My Notes', message=>'hello%sMonkees +'}); $vib->close_viber_app();
bw, bliako
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Do Androids Dream of Electric Sheep? Control your smartphone from the desktop
by choroba (Cardinal) on Apr 19, 2025 at 15:47 UTC | |
by bliako (Abbot) on Apr 20, 2025 at 09:04 UTC | |
Re: Do Androids Dream of Electric Sheep? Control your smartphone from the desktop
by cavac (Prior) on Apr 25, 2025 at 09:43 UTC | |
by bliako (Abbot) on Apr 26, 2025 at 10:48 UTC |