view release on metacpan or search on metacpan
lib/Android/ElectricSheep/Automator.pm view on Meta::CPAN
# a hash of installed apps by package name (e.g. android.google.calendar)
# the value will be an AppProperties object if it was enquired or undef
# if it wasn't. As the addition of apps is done in a lazy way, when
# needed, unless specified otherwise. In any event open_app() will add an
# AppProperties object if missing to the specified package.
'apps' => {},
# legacy, no worries.
'apps-roundabout-way' => undef,
};
bless $self => $class;
# this will read configuration and create confighash,
# make logger, verbosity,
# instantiate any objects we need here etc.
if( $self->init($params) ){ print STDERR __PACKAGE__."${whoami} (via $parent), line ".__LINE__." : error, call to init() has failed.\n"; return undef }
# Now we have a logger
my $log = $self->log();
# do module-specific init
lib/Android/ElectricSheep/Automator/ADB.pm view on Meta::CPAN
# fingers crossed: don't import IPC::Run::run()
# and use fully qualified name when calling it.
use IPC::Run qw/timeout/;
sub new {
my ($class, %args) = @_;
$args{path} //= $ENV{ADB};
$args{path} //= 'adb';
$args{verbosity} //= 0;
$args{args} //= [];
bless \%args, $class
}
sub run2 {
my ($self, @args) = @_;
my ($out, $in);
my @dev_args = $self->{device_serial} ? ('-s', $self->{device_serial}) : ();
my $pid = open2 $out, $in, $self->{path}, @{$self->{args}}, @args;
my $result = read_file $out;
close $out;
close $in;
lib/Android/ElectricSheep/Automator/ADB/Device.pm view on Meta::CPAN
use strict;
use warnings;
use parent qw/Class::Accessor::Fast/;
our $VERSION = '0.006';
sub new {
my ($class, $serial, $state, @attrs) = @_;
my %attrs = map { split ':', $_, 2 } @attrs;
bless { serial => $serial, state => $state, %attrs }, $class
}
__PACKAGE__->mk_ro_accessors(qw/serial state usb product model device/);
1;
__END__
=encoding utf-8
=head1 NAME
lib/Android/ElectricSheep/Automator/ADB/Device.pm view on Meta::CPAN
say $devices[0]->state; # e.g. offline, bootloader, sideload, or device
# The available attributes depend on your device
say $devices[0]->usb; # e.g. 2-1
say $devices[0]->product; # e.g. angler
say $devices[0]->model; # e.g. MI_MAX
say $devices[0]->device; # e.g. angler
=head1 DESCRIPTION
Information about an Android device in form of a blessed hash with a
few accessors. See SYNPOSIS for a list of accessors.
=head1 SEE ALSO
L<Android::ElectricSheep::Automator::ADB>
=head1 AUTHOR
Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
lib/Android/ElectricSheep/Automator/AppProperties.pm view on Meta::CPAN
'declaredPermissions' => [],
'enabledComponents' => [],
# activities
# each item is a hash with name, fully qualified name etc.
'MainActivity' => {}, # <<< this is an item as well if found
'MainActivities' => [], # only those marked as .MAIN and .LAUNCHER
'activities' => [], # all of them
}
};
bless $self => $class;
# we need a mother object (Android::ElectricSheep::Automator)
if( (! exists $params->{'mother'})
|| (! defined $params->{'mother'})
|| (! defined $params->{'mother'}->adb())
){ print STDERR "${whoami} (via $parent), line ".__LINE__." : error, input parameter 'mother' with our parent Android::ElectricSheep::Automator object was not specified.\n"; return undef }
$self->{'_private'}->{'mother'} = $params->{'mother'};
# we now have a mother
if( exists $params->{'logger-object'} ){
lib/Android/ElectricSheep/Automator/DeviceProperties.pm view on Meta::CPAN
# corresponds to dumpsys->RawSurfaceWidth,RawSurfaceHeight
'w' => 0,
'h' => 0,
'orientation' => 0,
'density' => 0,
'density-x' => 0,
'density-y' => 0,
'serial' => '<na>'
}
};
bless $self => $class;
if( exists $params->{'logger-object'} ){ $self->{'_private'}->{'logger-object'} = $params->{'logger-object'} } else { $self->{'_private'}->{'logger-object'} = Mojo::Log->new() }
if( exists $params->{'verbosity'} ){ $self->{'_private'}->{'verbosity'} = $params->{'verbosity'} } else { $self->{'_private'}->{'verbosity'} = Mojo::Log->new() }
# we now have a log and verbosity
my $log = $self->log;
my $verbosity = $self->verbosity;
# we need a mother object (Android::ElectricSheep::Automator)
if( (! exists $params->{'mother'})
lib/Android/ElectricSheep/Automator/Plugins/Apps/Base.pm view on Meta::CPAN
my $whoami = ( caller(0) )[3];
my $self = {
'_private' => {
'child-class' => $class,
'mother' => undef, # the Android::ElectricSheep::Automator object
'confighash' => undef,
'configfile' => '', # this should never be undef
},
};
bless $self => $class;
# this will read the confighash, check our params, confighash params, etc.
# and also instantiate ua etc. and also do the verbosity etc.
if( $self->init($params) ){ print STDERR __PACKAGE__." (via ".$self->child_class.") : ${whoami} (via $parent), line ".__LINE__." : error, call to init() has failed.\n"; return undef }
# do module-specific init
if( $self->init_module_specific($params) ){ print STDERR __PACKAGE__." (via ".$self->child_class.") : ${whoami} (via $parent), line ".__LINE__." : error, call to init_module_specific() has failed.\n"; return undef }
# Now we have a logger
my $log = $self->log();
lib/Android/ElectricSheep/Automator/ScreenLayout.pm view on Meta::CPAN
'dock-divider-area' => [0, 0, 0, 0, 0, 0],
# x1,y1,x2,y2,w,h
# these are some common apps which don't change if you swipe screens i think
'hotseat-area' => [0, 0, 0, 0, 0, 0],
# x1,y1,x2,y2,w,h
'home-buttons-area' => [0, 0, 0, 0, 0, 0],
'apps' => {}, # appname => [bounds x1,y1,x2,y2]
'screen-name' => '',
}
};
bless $self => $class;
if( exists $params->{'logger-object'} ){ $self->{'_private'}->{'logger-object'} = $params->{'logger-object'} } else { $self->{'_private'}->{'logger-object'} = Mojo::Log->new() }
if( exists $params->{'verbosity'} ){ $self->{'_private'}->{'verbosity'} = $params->{'verbosity'} } else { $self->{'_private'}->{'verbosity'} = Mojo::Log->new() }
# we now have a log and verbosity
my $log = $self->log;
my $verbosity = $self->verbosity;
if( exists $params->{'data'} ){
my $d = $self->{'data'};
script/electric-sheep-find-installed-apps.pl view on Meta::CPAN
$fpars->{'lazy'} = 0;
}
my $apps = $client->find_installed_apps($fpars);
if( ! defined($apps) ){ die "$0 : failed to find installed apps on the connected device." }
if( scalar(keys %$apps) == 0 ){ print STDERR "$0 : WARNING, no apps were found, surely there is something wrong.\n"; exit(1) }
# remove the null value (because in FAST mode we have no properties, only keys)
if( $FAST ){ $apps->{$_} = {} for keys %$apps }
# $apps is a hash with keys the package name (e.g. com.google.settings whatever)
# and the value is an AppProperties object.
# you need convert_blessed and TO_JSON!
my $jsonstr = perl2json($apps, {terse=>1, pretty=>1, convert_blessed=>1});
if( ! defined $jsonstr ){ print STDERR "$0 : error, failed to convert perl data structure to JSON.\n"; exit(1) }
if( defined $OUTFILE ){
my $FH;
open($FH, '>', $OUTFILE) or die "$0 : failed to open output file '$OUTFILE' for writing, $!";
print $FH $jsonstr;
close $FH;
} else { print STDOUT $jsonstr }
print STDOUT "$0 : done, success!".(defined($OUTFILE)?" Output written to file '$OUTFILE'.\n":"\n");