Max Maischein
Frankfurt am Main
Frankfurt.pm
DZ BANK, Information management
Why Android?
State of Perl on Android
Triaging Perl errors/module errors
Running Perl programs
Interacting with Android
Uses for Perl
For non-mobile developers
No App/Activity development
Share media files
No setup, just a device
Otherwise responsible for all problems
Sysadmin in foreign networks
Device on - sharing active
Device off - sharing inactive
Raspberry Pi - EUR 30
Touchscreen - EUR 30
Case - EUR 10
Power supply, WLan, ...
Soldering + glueing
Sysadmin
Device - EUR 130
Touchscreen
Case
Battery
Wlan, USB, Camera, Power supply, ...
Sysadmin
"Android is just Linux, right?"
Android has 3 parts
Android has 3 parts
Android has 3 parts
Android has 3 parts
Android has 3 parts
Android has 3 parts
Android has 3 parts
Android has 3 parts
No JVM, no access to Android Core
Native IDE on Android
Vi
git
gcc
Perl
bash, wget, curl, ...
CCtools has Perl
1: perl -v 2: 3: This is Perl 5.18.2, ...
Perl 5.22 is hopefully more current and works better.
Compiling our own perl
1: sh ./Configure 2: -des 3: -Dusedevel 4: -Dprefix=/data/local/perl/ 5: -Dsysroot=/data/data/com.pdaxrom.cctools/root/cctools 6: -Alibpth=/system/lib /vendor/lib 7: -Dman1dir=none 8: -Dman3dir=none 9: -Dsite1man=none 10: -Dsite3man=none 11: -Dvendorman1=none 12: -Dvendorman3=none 13: -DNO_LOCALE 14: 15: make 16: make test 17: make install
make test
50% bad test assumptions
50% environment/OS peculiarities
1: cpan/Time-Piece/t/02core ...................................... # Failed test at t/02core.t line 62. 2: # got: '3600' 3: # expected: '-18000' 4: # Failed test at t/02core.t line 63. 5: # got: 'CET' 6: # expected: 'EST' 7: # Looks like you failed 2 tests of 95. 8: FAILED at test 36
1: cpanm --no-wget Mojolicious
Sometimes fewer prerequisites is convenient
1: use Mojolicious::Lite; 2: 3: get '/' => sub { 4: my( $c )= shift; 5: $c->render( text => 'Hello YAPC::Europe' ); 6: }
One Unix-User per app
Data protection between apps
root
for access to all data
DBI Installs without problems
SQLite is installed on Android
1: sqlite3 /data/data/com.google.android.keep/data.sqlite
Querylet
root
:-(
1: #!perl -w 2: use strict; 3: use Querylet; 4: use Querylet::Output::Text; 5: 6: database: dbi:SQLite:dbname=/data/data/com.google.android.keep/data/keep.db
1: query: 2: select 3: title 4: , text 5: from tree_entity note 6: left join list_item list on 7: (note._id = list.list_parent_id and note.account_id=list.account_id) 8: where note._id= 143 9: order by list.order_in_parent desc 10: 11: output format: text
1: # perl5.21.11 02-dump-keep.pl
1: # perl5.21.11 02-dump-keep.pl 2: 3: title text 4: Perl on Android Abgrenzung/Erwartungsmanagement 5: Perl on Android Historische Einordnung v. PoA: SL4A,native 6: Perl on Android Java vs native 7: Perl on Android dalvik vs Java -> ART
Launch Activities
Send input
Read input
Read screen
Without JNI
open()
/ Read the right devices
system()
/ launch the right programs
Launch Activity
1: system( "am start 'http://act.yapc.eu/ye2015'" ); 2: 3: Android::launch_activity('http://act.yapc.eu/ye2015')
APK Builder
Google Play Store Account
Size reduction (App::staticperl)
Native UI instead of webserver
Download tarball
Copy files
All sample code is on Github at
Questions?
Questions?
corion@cpan.org
Slides available at
Tarball on
http://corion.net/perl-android/index.html
https://github.com/corion/perl-android on Github
Clicks / taps
1: Android::send_input_event( 2: command => 'tap', 3: args => [$x, $y], 4: );
Text
1: Android::send_input_event( 2: command => 'text', 3: args => ['Hello Perl'], 4: );
1: my $fh= Android::input_event_fh(); 2: while( my $line = <$fh> ) { 3: my $ev= Android::decode_input_event( $line ); 4: if( $ev ) { 5: print join("\t", $ev->{type}, $ev->{subtype}, $ev->{value}), "\n"; 6: }; 7: };
Screenshot
1: Android::screenshot('/sdcard/image.png');
1: Android::vibrate(100);
perlandroid.pod
cctools
perlport.pod
Own mtpServer/mtpDevice
Android has Fuse built-in
CPAN via http as FUSE Plugin - minicpan-on-usb
fuse-android
+Fuse.pm
1: libfuse-lite / ntfs-3g
Raspberry Pi 2 Model B by Multicherry ( https://commons.wikimedia.org/wiki/User:Multicherry )