Android-ElectricSheep-Automator
view release on metacpan or search on metacpan
Set the GPS / geo-location position to the specified coordinates.
electric-sheep-dump-ui.pl --configfile config/myapp.conf --latitude 12.3 --longitude 45.6
electric-sheep-dump-screen-shot.pl
Take a screenshot of the device (current screen) and save to a PNG
file.
electric-sheep-dump-screen-shot.pl --configfile config/myapp.conf --output screenshot.png
electric-sheep-dump-screen-video.pl
Record a video of the device's current screen and save to an MP4 file.
electric-sheep-dump-screen-video.pl --configfile config/myapp.conf --output video.mp4 --time-limit 30
electric-sheep-pull-app-apk.pl
Extract the APK file (java bytecode) for an app installed on the device
## **`electric-sheep-emulator-geofix.pl`**
Set the GPS / geo-location position to the specified coordinates.
electric-sheep-dump-ui.pl --configfile config/myapp.conf --latitude 12.3 --longitude 45.6
## **`electric-sheep-dump-screen-shot.pl`**
Take a screenshot of the device (current screen) and save to a PNG file.
electric-sheep-dump-screen-shot.pl --configfile config/myapp.conf --output screenshot.png
## **`electric-sheep-dump-screen-video.pl`**
Record a video of the device's current screen and save to an MP4 file.
electric-sheep-dump-screen-video.pl --configfile config/myapp.conf --output video.mp4 --time-limit 30
## **`electric-sheep-pull-app-apk.pl`**
Extract the APK file (java bytecode) for an app installed on the device and save locally, perhaps, for disassembly and/or modification and/or re-installation.
lib/Android/ElectricSheep/Automator.pm view on Meta::CPAN
}
# optional display-id (TODO: confirm that this display id is valid with
# dumpsys SurfaceFlinger --display-id
my @options;
if( exists($params->{'display-id'}) && defined($params->{'display-id'}) ){
push @options, '--display-id', $params->{'display-id'}
}
# WARNING, you need to wake up the phone before dumping !!!!
my $devicefile = File::Spec->catfile('/', 'data', 'local', 'tmp', $$.'.png');
my @cmd = ('screencap', @options, '-p', $devicefile);
if( $verbosity > 0 ){ $log->info("${whoami} (via $parent), line ".__LINE__." : sending command to adb: @cmd") }
my $res = $self->adb->shell(@cmd);
if( ! defined $res ){ $log->error(join(" ", @cmd)."\n${whoami} (via $parent), line ".__LINE__." : error, above shell command has failed, got undefined result, most likely shell command did not run at all, this should not be happening."); return unde...
if( $res->[0] != 0 ){ $log->error(join(" ", @cmd)."\n${whoami} (via $parent), line ".__LINE__." : error, above shell command has failed, with:\nSTDOUT:\n".$res->[1]."\n\nSTDERR:\n".$res->[2]."\nEND."); return undef }
$res = $self->adb->pull($devicefile, $filename);
if( ! defined $res ){ $log->error("${whoami} (via $parent), line ".__LINE__." : error, failed to pull remote file '$devicefile' into local file '$filename', because undefined was returned, this should not be happening."); return undef }
if( $res->[0] != 0 ){ $log->error("${whoami} (via $parent), line ".__LINE__." : error, failed to pull remote file '$devicefile' into local file '$filename' with:\nSTDOUT:\n".$res->[1]."\n\nSTDERR:\n".$res->[2]."\nEND."); return undef }
lib/Android/ElectricSheep/Automator.pm view on Meta::CPAN
=head2 B<C<electric-sheep-emulator-geofix.pl>>
Set the GPS / geo-location position to the specified coordinates.
electric-sheep-dump-ui.pl --configfile config/myapp.conf --latitude 12.3 --longitude 45.6
=head2 B<C<electric-sheep-dump-screen-shot.pl>>
Take a screenshot of the device (current screen) and save to a PNG file.
electric-sheep-dump-screen-shot.pl --configfile config/myapp.conf --output screenshot.png
=head2 B<C<electric-sheep-dump-screen-video.pl>>
Record a video of the device's current screen and save to an MP4 file.
electric-sheep-dump-screen-video.pl --configfile config/myapp.conf --output video.mp4 --time-limit 30
=head2 B<C<electric-sheep-pull-app-apk.pl>>
Extract the APK file (java bytecode) for an app installed on the device and save locally, perhaps, for disassembly and/or modification and/or re-installation.
script/electric-sheep-dump-screen-shot.pl view on Meta::CPAN
};
# we assume there is a device connected which the user
# must specify by serial, of if just one, we connect to
# it without the serial
if( defined $DEVICE ){ $params->{'device-serial'} = $DEVICE }
else { $params->{'device-is-connected'} = 1 }
my $client = Android::ElectricSheep::Automator->new($params);
if( ! defined($client) ){ die "$0 : failed to instantiate the automator." }
my $pngimg = $client->dump_current_screen_shot({
'filename' => $OUTFILE
});
if( ! defined($pngimg) ){ die "$0 : failed to dump current screen as a PNG image." }
print STDOUT "$0 : done, success! Output written to file '$OUTFILE'.\n";
sub usage {
return "Usage $0 --configfile CONFIGFILE [--output screenshot.png] [--device DEVICE] [--verbosity v]\n"
. "\nThis script will dump the current screen as a PNG image to the specified output filename.\n"
. "\nExample:\n"
. "$0 --configfile config/myapp.conf --output screenshot.png\n"
. "\nProgram by Andreas Hadjiprocopis (c) 2025 / bliako at cpan.org / andreashad2 at gmail.com\n\n"
;
}
1;
xt/live/320-dump_current_screen_shot.t view on Meta::CPAN
# we have a device connected and ready to control
'device-is-connected' => 1,
});
ok(defined($mother), 'Android::ElectricSheep::Automator->new()'." : called and got defined result.") or BAIL_OUT;
my $res = $mother->dump_current_screen_shot();
ok(defined($res), 'Android::ElectricSheep::Automator->dump_current_screen_shot()'." : called and got good result.") or BAIL_OUT;
is(ref($res), 'Image::PNG', 'Android::ElectricSheep::Automator->dump_current_screen_shot()'." : called and got good result which is of class 'Image::PNG'.") or BAIL_OUT("no it is '".ref($res)."'");
# now save it to a file
my $outfile = File::Spec->catfile($tmpdir, 'screenshot.png');
$res = $mother->dump_current_screen_shot({
'filename' => $outfile
});
ok(defined($res), 'Android::ElectricSheep::Automator->dump_current_screen_shot()'." : called and got good result.") or BAIL_OUT;
is(ref($res), 'Image::PNG', 'Android::ElectricSheep::Automator->dump_current_screen_shot()'." : called and got good result which is a Image::PNG object.") or BAIL_OUT("no it is '".ref($res)."'");
ok(-f $outfile, 'Android::ElectricSheep::Automator->dump_current_screen_shot()'." : called and result saved to output file '$outfile'.") or BAIL_OUT;
diag "temp dir: $tmpdir ..." if exists($ENV{'PERL_TEST_TEMPDIR_TINY_NOCLEANUP'}) && $ENV{'PERL_TEST_TEMPDIR_TINY_NOCLEANUP'}>0;
# END
( run in 0.881 second using v1.01-cache-2.11-cpan-df04353d9ac )