Max Maischein
Frankfurt.pm
Perl seit 2000
Android seit 2014
Warum Android?
Perl selber bauen
Perl-Fehler/Modul-Fehler einschätzen
Eigenheiten von Android
Anwendungen für Perl
Ausblick / App-Entwicklung
Auch für nicht-mobil-Entwickler
Keine App-/Activity-Entwicklung
Teilen von Mediendateien
Kein Setup
Sonst verantwortlich für alle Probleme
Sysadmin in fremden Netzwerken
Leichte Kontrolle
Gerät an - Verbindung an
Gerät aus - Verbindung aus
Via Wlan
Via USB
Raspberry Pi - EUR 30
Touchscreen - EUR 30
Gehäuse - EUR 10
Netzteil, WLan, ...
Löten + Basteln
Sysadmin
Gerät - EUR 130
Touchscreen
Gehäuse
Akku
Wlan, USB, Kamera, Netzteil, ...
Sysadmin
Android hat 3 Bestandteile
Android hat 3 Bestandteile
Android hat 3 Bestandteile
Android hat 3 Bestandteile
Android hat 3 Bestandteile
Android hat 3 Bestandteile
Android hat 3 Bestandteile
Android hat 3 Bestandteile
Keine JVM, kein Zugriff auf Android Core
perlandroid.pod
cctools
perlport.pod
SL4A - Scripting Layer for Android
Vereinfachtes UI
Nur wenige Android-Klassen exportiert
Lokale Kommunikation über Socket
Kivy - Cross-Platform Python Apps
Eigenes "Cross-Platform" UI (GLES)
Python-Java-Brücke
Lokale Kommunikation über Socket
NDK-Entwicklungsumgebung unter Android
Vi
git
gcc
Perl
bash, wget, curl, ...
CCtools liefert Perl mit
1: perl -v 2: 3: This is Perl 5.18.2, ...
Perl 5.20 ist hoffentlich aktueller.
Eigenes Perl kompilieren
Zwei Möglichkeiten:
App::perlbrew
manuell kompilieren
1: sh ./Configure -Dprefix=/storage/sdcard0/perl 2: make 3: make test 4: make install
1: sh ./Configure -Dprefix=/storage/sdcard0/perl 2: -des 3: -Dusedevel 4: -Dprefix=/data/local/perl-5.21.11/ 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
1: Failed 16 tests out of 2190, 99.27% okay. 2: ../cpan/Memoize/t/expmod_t.t 3: ../cpan/Sys-Syslog/t/syslog.t 4: ../cpan/Time-Piece/t/02core.t 5: ../dist/Net-Ping/t/110_icmp_inst.t 6: ../dist/Net-Ping/t/120_udp_inst.t 7: ../dist/Net-Ping/t/130_tcp_inst.t 8: ../dist/Net-Ping/t/140_stream_inst.t 9: ../dist/Net-Ping/t/150_syn_inst.t 10: ../dist/Net-Ping/t/450_service.t 11: ../dist/Net-Ping/t/500_ping_icmp.t 12: ../dist/Net-Ping/t/510_ping_udp.t 13: ../dist/Net-Ping/t/520_icmp_ttl.t 14: ../lib/warnings.t 15: op/tie_fetch_count.t 16: op/time.t 17: porting/globvar.t
1: t/op/tie_fetch_count .......................................... The crypt() function is unimplemented due to excessive paranoia. at op/tie_fetch_count.t line 253. 2: # Looks like you planned 347 tests but ran 185. 3: FAILED--expected 347 tests, saw 185 4: ... 5: t/op/tiehandle ................................................ ok 6: t/op/time ..................................................... # Failed test 7 - changes to $ENV{TZ} respected at op/time.t line 62 7: FAILED at test 7 8: t/op/time_loop ................................................ ok 9: 10: cpan/Memoize/t/expmod_t ....................................... FAILED at test 7
1: cpan/Sys-Syslog/t/syslog ...................................... # Failed test '[stream] syslog() called with level 'info' (string)' 2: # at t/syslog.t line 179. 3: # got: 'Your vendor has not defined POSIX macro LC_TIME, used at ../../lib/Sys/Syslog.pm line 436 4: # ' 5: # expected: '' 6: # Failed test '[stream] syslog() should return true: '0'' 7: # at t/syslog.t line 180. 8: # Failed test '[stream] syslog() called with level 'info' (macro)' 9: # at t/syslog.t line 186. 10: # got: 'Your vendor has not defined POSIX macro LC_TIME, used at ../../lib/Sys/Syslog.pm line 436 11: # ' 12: # expected: '' 13: # Failed test '[stream] syslog() should return true: '0'' 14: # at t/syslog.t line 187. 15: # Looks like you failed 4 tests of 225. 16: FAILED at test 122
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: dist/Net-Ping/t/110_icmp_inst ................................. Can't get icmp protocol by name at t/110_icmp_inst.t line 28. 2: # Looks like you planned 2 tests but ran 1. 3: # Looks like your test exited with 255 just after 1. 4: FAILED--expected 2 tests, saw 1
1: lib/Config .................................................... 2: # Failed test 146 - Expect archlibexp './../lib/5.21.11/armv7l-linux-android' to be in @INC at ../lib/Config.t line 275 3: # Failed test 147 - Expect privlibexp './../lib/5.21.11' to be in @INC at ../lib/Config.t line 275 4: # Failed test 148 - Expect sitearchexp './../lib/site_perl/5.21.11/armv7l-linux-android' to be in @INC at ../lib/Config.t line 275 5: # Failed test 149 - Expect sitelibexp './../lib/site_perl/5.21.11' to be in @INC at ../lib/Config.t line 275 6: # @INC is: 7: # ../lib 8: # ./../lib/perl5/site_perl/5.21.11/armv7l-linux-android 9: # ./../lib/perl5/site_perl/5.21.11 10: # ./../lib/perl5/5.21.11/armv7l-linux-android 11: # ./../lib/perl5/5.21.11 12: # . 13: FAILED at test 146
???
1: getprotobyname('tcp')
Sys::SysLog, RT Ticket 90218.
Betrifft auch HTTP::Server::Simple
... und damit Dancer
1: -Dprefix=/data/local/perl
=>
1: /data/local/perl/bin 2: /data/local/perl/lib 3: /data/local/perl/lib/site_lib
Extutils::MakeMaker etc. wollen aber (entgegen INSTALL)
1: /data/local/perl/lib/perl5/site_lib
=>
1: ln -s /data/local/perl/lib /data/local/perl/lib/perl5
1: cpanm --no-wget App::cpanminus
1: cpanm --no-wget Dancer
1: HTTP::Request::Common schlägt fehl
2x installieren hilft
1: cpanm --no-wget Mojolicious
Manchmal sind wenige Prerequisites besser
1: use Mojolicious::Lite; 2: 3: get '/' => sub { 4: my( $c )= shift; 5: $c->render( text => 'Hallo Perlworkshop' ); 6: }
Temporäre Dateien
mktemps()
$ENV{STORAGE}
"external storage", d.h. eingebauter Flash
"secondary storage", d.h. Speicherkarte
/data/local/tmp
Direkter Weg geht nicht
Java-Server (Service unter Android), mit dem Perl bei Bedarf redet
Java-Server (Service unter Android), mit dem Perl bei Bedarf redet
Scripting Languages 4 Android-Ansatz
Plan: Erstmal während Configure die Daten auslesen und fest
in Config_heavy.pl
hinterlegen
Pfusch:
1: export TEMPDIR=/data/local/tmp
Ein Unix-User pro Anwendung
Datenschutz zwischen den Anwendungen
root
für Zugriff auf alle Anwendungsdaten
Läuft direkt.
SQLite ist unter Android installiert
1: sqlite3 /data/data/com.google.android.keep/data.sqlite
GraphViz2::DBI
leider kein references foo.bar
Tabelle tree_entity
mit _id
, account_id
Tabelle list_item
mit list_parent_id
, account_id
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
Anwendungen starten
Eingaben senden
Eingaben lesen
Bildschirm lesen
Alles ohne JNI
Passende Dateien lesen/schreiben
Programme starten
Activity / Aktivitaeten starten
1: system( "am start 'http://act.yapc.eu/gpw2015'" ); 2: 3: Android::launch_activity('http://act.yapc.eu/gpw2015')
Klicks
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: );
Events mitschreiben
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);
Ein eigener mtpServer/mtpDevice
Android hat Fuse eingebaut
CPAN via http as FUSE Plugin - minicpan-on-usb
fuse-android
+Fuse.pm
1: libfuse-lite / ntfs-3g
APK Builder
Google Play Store Account
Größenreduktion
Natives UI statt lokalem Webserver
Dateien kopieren
Fragen?
corion@cpan.org
Folien unter
1: perldoc perlandroid
http://corion.net/talks/perl-on-android/demo - Verwendete Dateien
Perl 5.21.11 f. ARM v7
http://corion.net/talks/perl-on-android/demo/perl-5.21.11-armv7l-linux-android.tar.gz
Python for Android - http://kivy.org/
React Native
https://github.com/Corion/perl-android - Android.pm
Google (http://developer.android.com/distribute/googleplay/promote/brand.html)
Larry Ewing(lewing@isc.tamu.edu)
The Perl logo is a trademark of the Perl Foundation (http://perl.org)
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of Sun Microsystems Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY SUN MICROSYSTEMS INC. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SUN MICROSYSTEMS INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.