Betabeers Android as a Digital Signage platform

Post on 09-Jul-2015

710 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

Slids from my talk at Betabeers Barcelona on November of 2013

Transcript

Android as a Digital Signage platform

Betabeers Barcelona November 2013

Hello worldClients

OrangeEl Corte Inglés

EndesaSodexo

IkeaNespresso

Fira BarcelonaAjuntament de Barcelona

ESADEThe Phone House

The company20 peopleDigital SignageUser Interactivity

ProjectsSpain United Kingdom GermanyNetherlandsFinland

www.focusonemotions.com@focusonemotions

Hello world

Orestes Carracedo

8 years as a developer4 years as an Android user3,5 years at Focus On Emotions

Software Development DirectorCertified SCRUM MasterPHP 5.3 Zend Certified Engineer

Read about mehttp://blog.orestes.io

Follow me@orestesCA

What’s Digital Signage?

What’s Digital Signage?

The beginning

Briefing

Make it on timeCode as less as possible

Be robustMake use of existing OS toolsMake use of existing apps

Be flexibleCreate multiple decoupled tools that work together

System architecture

Apache Cordova

VPN

BusyBox

ADB

SSH

JavaScript player

SuperSU

scheduler

HTTP API

API Client

cron

CLI API

Prototype

http://vimeo.com/72032877

Let’s do it!

Quick ADB recap$ adb devicesList of devices attached4df144cb39376f2f device # Over USB192.168.1.42:5555 device # Over NET

$ adb shell echo “Hello world”Hello world

$ adb -d shell ls /mnt/sdcard$ adb -s 192.168.1.42:5555 shell ls /mnt/sdcard

Enable ADB over Wi-Fi$ adb shell setprop service.adb.tcp.port 5555$ adb shell stop adbd && start adbd # or you’ll be locked out

$ adb connect 192.168.1.42:5555

Quick ADB recapSending keys$ adb shell input keyevent 3 # home

Starting activities$ adb shell am start -n com.focusonemotions.android.player./Wrapper

Killing a process$ pm stop com.focusonemotions.android.player

Installing apps$ adb install foe-player-v1.1.apk$ adb push foe-player-v1.1.apk /system/app

Android Monitor<android-sdk>/tools/monitor

http://developer.android.com/reference/android/view/KeyEvent.html

Features

Player

CordovaRotates screenShows WebViewProvides OS shell access

JavaScriptDisplays contentReads content index fileListens for gestureAsks for security codeShows config manager

SchedulerPower management$ reboot # (duh)

Screen state management$ input keyevent 26 # power

$ input keyevent 82 # menu

Player state management$ killall com.focusonemotions.android.player

$ am start -n com.[...].player/.Wrapper

http://developer.android.com/reference/android/view/KeyEvent.html

Restricted user access● Kill UI process● Custom launcher

AndroidManifest<category android:name="android.intent.category.HOME" />

/system/build.propqemu.hw.mainkeys=1

● Custom ROM

http://thebitplague.wordpress.com/2013/04/05/kiosk-mode-on-the-nexus-7/

Local configuration manager

Content Index file

Player configuration file

Configuration manager

Content player

Static IP address

https://play.google.com/store/apps/details?id=de.schaeuffelhut.android.openvpn.installerhttps://play.google.com/store/apps/details?id=de.blinkt.openvpn

$ openvpn --config /mnt/sdcard/focus/openvpn/conn.conf > /mnt/sdcard/focus/openvpn/run.log &

$ cat /mnt/sdcard/focus/openvpn/conn.conf | grep resolvresolv-retry infinite

Remote shell$ adb connect 192.168.1.42:5555

$ time adb connect 192.168.1.42:5555

unable to connect to 192.168.1.42:5555

real 1m3.163s

user 0m0.000s

sys 0m0.020s

.

.

$ time timeout 9s adb connect 192.168.1.42

real 0m9.003s

user 0m0.000s

sys 0m0.020s

Screen capture$ adb shell screencap /mnt/sdcard/focus/capture.png

$ adb pull /mnt/sdcard/focus/capture.png

$ ./capture.sh oratab-030-01

Getting screencap from oratab-030-01 ... done.

Wi-Fi management$ echo "12345678" | wpa_passphrase "SSID"

# reading passphrase from stdin

network={

ssid="SSID"

#psk="12345678"

psk=34b59e6b0182725d42460 [...]

}

$ wpa_passphrase "SSID" "12345678" # may malfunction

$ wpa_passphrase "SSID" # may malfunction

# reading passphrase from stdin

Android Wi-fi/WPA settings/data/misc/wifi/wpa_supplicant.conf

Content management$ adb push /local/folder /remote/folder

PHP SFTP Wrapper$ php load-device-content.php 300 7

Loading content …

50 % 20/40 KB

100 % 40/40 KB

Done.

/mnt/sdcard/focus

+ openvpn

+ player

+ scheduler

+ upload

- content

- october_2013

+ media

Statistics & graphs

Statistics & graphsWhisper database (updates to past data)Carbon aggregation (Use an IP, not a hostname UDP is better than TCP, is off by default)Graphite for rendering

$ /opt/graphite/bin/carbon-cache.py start --debug

$ echo ‘value.received’ `date +%s` | nc -w 1 127.0.0.1 2003

StatsD/statsite as aggregator/proxy (v8 nodejs vs C)<?php StatsD::increment(‘com.focusonemotions.app.pushing’);

http://graphite.readthedocs.org/en/latest/https://github.com/etsy/statsd/https://github.com/armon/statsite

Platforming

1. Plug device in2. Enable ADB over USB3. Launch script4. Enter ID5. Done!

Check

● PING● SFTP● SSH● ADB

Platforming

$ sftp root@192.168.1.42:mnt/sdcard/focusbash: /usr/libexec/sftp-server: No such file or directory$ sftp -s /system/xbin/sftp-server root@192.168.1.42:mnt/sdcard/focussftp># quick fix[adb] $ ln -s /system/xbin/sftp-server /usr/libexec/sftp-server

Install SuperSU + settingsInstall BusyBoxInstall DropBearSSHFix SFTP subsystemInstall playerInstall schedulerInstall OpenVPN certificates from IDReboot

Platforming

http://www.chainfire.eu/projects/52/SuperSU/https://play.google.com/store/apps/details?id=stericson.busyboxhttps://github.com/yath/android_external_dropbear

Content Management System

Testing

Quick feedback

Acceptance Tests● CLI API ● Web API

Physical testing devices

Testing

Testing Scenario Outline: Get a list of cities based on the passed parameters Given I have an endpoint "http://api.pushmaster.focusonemotions.com/1.0/city/" And I pass an argument "id" "<id>" And I pass an argument "title" "<title>" When I make a "<method>" request to the endpoint Then I should get a valid response "<response>"

Examples: | method | id | title | response | | GET | | | city/city-list.json | | GET | 1 | | city/city-get-by-id.json | | GET | | Hobbiton | city/city-get-by-title.json | | GET | -1 | | null.json | | GET | | FOO | null.json |

All done

Ha ha!

Monitoring with Nagios

Monitoring with Nagios$ php check-device-content.php 192.168.1.42

Up-to-date

$ php check-device-content.php 192.168.1.42

Out of date

http://nagios.sourceforge.net/docs/3_0/quickstart.html

Monitoring with Nagios<?xml version="1.0" encoding="UTF-8"?><nagios_status><hosts><host name="dev-001"> <status last_change="2013-10-08T16:27:37+02:00">0</status> <connectivity last_change="2013-10-08T16:27:37+02:00">0</connectivity> <content last_change="2013-10-08T16:27:37+02:00">0</content> <sftp last_change="2013-10-08T16:27:37+02:00">0</sftp></host>[...]

http://www.focusonemotions.com

dev@focusonemotions

Thank you!Feedback

orestes.ca@gmail.com

TeamJuanra PosadaOrestes Carracedo

Javier MoralesDimas López

Raúl Jiménez Javier DomingoGonzalo Rodríguez

Project ManagerLead Developer

Developers

JavaScript NinjaSystem Administrators

ChallengeBreak out of the player app, win an Amazon gift card!

● Try to guess the unlock gesture● Try to guess the unlock code● No buttons● No fastboot

top related