Android Meetup, Илья Лёвин

Post on 06-May-2015

134 views 4 download

transcript

Android* on Intel platforms

Ilya Levin, Software Developer

Smartphones with Intel Inside - 2012

Motorola* RAZR i ZTE* Grand X IN

Lava* Xolo X900 Megafon* Mint

Lenovo* K800

Orange* San Diego (UK)

Orange* avec Intel Inside (FR)

Z2460

Smartphones with Intel Inside - 2013

Intel® Yolo

Acer* Liquid C1

Z2420 Z2580Z2560

Lenovo* K900 – 5.5”

ASUS Fonepad™ Note FHD - 6”

ZTE* Grand X2 In – 4.5”

ZTE* Geek – 5”

Etisalat E-20*

Tablets with Intel Inside - 2013ASUS* MeMO Pad FHD 10”

(Z2560)

ASUS* Fonepad™ 7”

(Z2420/Z2560)

Dell* Venue 7/8

(Z2560)

Samsung* Galaxy™ Tab 3 10.1”

(Z2560)

LTE version now available

Future Android* platforms based on Intel* Silvermont microarchitecture

New 22nm tri-gate microarchitecture~3X more peak performance or ~5X lower power than previous Atom microarchitecture

Intel® Atom™ Processor Z3000 Series (Bay Trail)

Next Generation Tablets

MerrifieldNext Generation Smartphones

Intel devices are already fully compatible with established Android* ecosystemAndroid* Dalvik* apps

These will directly work, Dalvik has beenoptimized for Intel® platforms.

Android NDK apps Most will run without any recompilation on consumer

platforms. Android NDK provides an x86 toolchain since 2011 A simple recompile using the Android NDK yields the

best performance If there is specific processor dependent code, porting

may be necessary

Most of the time, it just works !

When optimization is needed

Performance critical apps are popular Games Real time multimedia Augmented reality

Users are sensitive Don’t accept lags Fluid animations Minimal load time

How to target multiple platforms (incl. x86) from NDK apps?

If you have the source code of your native libraries, you can compile it for several CPU architectures by setting APP_ABI to all in the Makefile “jni/Application.mk”:

APP_ABI=all

The NDK will generate optimized code for all target ABIsYou can also pass APP_ABI variable directly to ndk-build, and specify each ABI:

ndk-build APP_ABI=x86

Configuring NDK Target ABIs

ARM v7a libs are builtARM v5 libs are builtx86 libs are built

mips libs are built

Put APP_ABI=all inside Application.mkRun ndk-build…

PSI

TS

PIDs

Packaging APKs for Multiple CPU Architectures

Two options:

One package for all (“fat binary”)

Embed native libraries for each architecture in one APK

Easiest and preferred way to go

Multiple APKs

One APK per architecture

If you have good reasons to do so (i.e., your fat binary APK would be larger than 50MB)

Fat BinariesBy default, an APK contains libraries for every supported ABIs.

Use lib/armeabi libraries

Use lib/armeabi-v7a libraries

Use lib/x86 libraries

libs/armeabi-v7a

libs/x86

libs/armeabi

APK file

The application will be filtered during installation (after download)

Multiple APKsGoogle Play* supports multiple APKs for the same application.

What compatible APK will be chosen for a device entirely depends on the android:VersionCode

If you have multiple APKs for multiple ABIs, best is to simply prefix your current version code with a digit representing the ABI:

2310 6310

You can have more options for multiple APKs, here is a convention that will work if you’re using all of these:

x86ARMv7

Intel® Tools for Android* apps developersHAXM, GPA, and others

Most of Intel tools are relevant even if you’re not targeting x86 platforms!

Intel x86 Emulator Accelerator

Intel x86 Atom System Image

Faster Android* Emulation on Intel® Architecture Based Host PC

Pre-built Intel® Atom™ Processor Images

• Android* SDK manager has x86 emulation images built-in

• To emulate an Intel Atom processor based Android phone, install the “Intel Atom x86 System Image” available in the Android SDK Manager

Much Faster Emulation

• Intel® Hardware Accelerated Execution Manager (Intel® HAXM) for Mac and Windows uses Intel® Virtualization Technology (Intel® VT) to accelerate Android emulator

• Intel VT is already supported in Linux* by qemu -kvm

ARM and x86 Emulators running AnTuTu* Benchmark

Android* on Intel platformsAnd what it means for you, developers.

Ilya Levin, Software Developer

HAXM(Hardware Accelerated Execution Manager)

Intel® Graphics Performance Analyzers

• Profiles performance and Power

• Real-time charts of CPU, GPU and power metrics

• Conduct real-time experiments with OpenGL-ES* (with state overrides) to help narrow down problems

• Triage system-level performance with CPU, GPU and Power metrics

Available freely on intel.com/software/gpa

Using the Second-Screen API and Intel® Wireless Display From Android* Applications

What is Miracast*?• Miracast* is standard for wireless peer-to-peer

screen-casting, created and certified by the WiFi Alliance*

• Wireless replacement for HDMI*/MHL*

• Built upon existing standards

- H.264 (MPEG-4 AVC) video compression & WiFi Direct

• Based on Intel® Wi-Fi Display specifications

• Open for the industry

• Support added in Android* 4.2

What is Intel® Wireless Display (WiDi)

Supports two additional Display modesExtended Video mode (with Android* media framework)Multi-task usage support (content on second screen, while local screen used for other task)

Available on most Intel® Atom™ SOCs

Intel® WiDi is a superset of WFA Miracast*

• WFA Miracast* certified– compatible with Miracast* certified receivers.

• Supports HD video up to 1080p/60 with 5.1 audio• Content protection with HDCP2.1

Miracast* Concept

Video Render Audio Render

Video Decode Audio Decode

De-Packetize De-Packetize

Link Content Protection Decrypt (Optional)

AV DeMux

Transport

LLC

WI-Fi MAC (Direct Link)

Wi-Fi PHY

SINK

Video Encode Audio Encode

Packetize Packetize

Link Content Protection Encrypt (Optional)

AV Mux

Transport

LLC

WI-Fi MAC (Direct Link)

Wi-Fi PHY

Video Frames Audio Samples

SOURCE

Adapters• Actiontec* ScreenBeam Pro• Netgear* (ex: PTV3000)• Viewsonic (WPG-370)• Acer*

• Best Buy* Rocketfish*

• Lenovo*

• …

Projectors• Dell*

• Seiko Epson *• Ricoh*• LG*• …

TVs• Samsung*• Toshiba*• LG*• TCL*• Sharp*• Philips*• …

Miracast* Certified Sink Devices

Intel® WiDi Certified

Second-Screen Enabled Devices running Android* 4.2.x

Device Miracast* Certified

HDMI*, MHL* or SlimPort*

Samsung* Galaxy S4 Yes Yes

Samsung Galaxy Tab3 10.1 No Yes

Sony* Xperia Z Yes Yes

LG* Optimus G Yes Yes

Nexus* 4 Yes Yes

HTC* One Yes Yes

Lenovo* K900 Yes No

Asus* MeMO Pad FHD10 Yes Yes

Connecting a Wireless Display on Android*

Sony* Xperia Z Stock/Intel® Samsung* Galaxy S4

Clone Mode (Default)

After establishing the connection, user sees local screen on the remote display

Resolution sent to remote is the same as local display’s

No need to do anything to support this mode

Remote screen used for content viewing

Local screen used for control & context info

Application can target this mode using the Android* Presentation API

Dual Screen Display With Single App

Video mode is activated automatically when user plays a video using Android* Media Player framework (ex: VideoView)

User sees video content on the remote at the 1080p resolution (or whatever the native resolution of the content is)

Local video rendering is turned off to save power, but UI stays untouched

Extended Video Mode(Intel® Platform Specific)

Use-Cases for Second Screen Applications Multi-Media Sharing

‒ Share videos and photos to a large screen and use handset to navigate

Gaming‒ Use handset as game controller

Productivity Apps‒ Sharing presentations to large screen or projector

IVI‒ Transfer phones screen to car head unit (Navigation)

Ideas for Dual Screen Applications

Enter search term

Touchpad Mode

Web Browser

Ideas for Dual Screen Applications

And

Keyboard Input Mode

wq e r t y u i o p

sa d f g h j k l

z x c v b n m&12

3/ space · searc

h

And

Web Browser

Ideas for Dual Screen Applications

Games

Dual Joysticks Mode

Ideas for Dual Screen Applications

Productivity App

The Presentation Object

Dialog

Presentation

You need to have a fragment based navigation if you want to keep it running while navigating in the app.

The activity should take care of pausing and resuming whatever content is playing within the presentation whenever the activity itself is paused or resumed.

• Presentation is the based class and should be extended:

• Presentation inherits from Dialog, and as for a Dialog its lifecycle is bound to an Activity

public class DemoPresentation extends Presentation {

• Needs to be associated with a Display at creation time

Before showing a Presentation you need to select a Display, this can be done in 2 ways:

1. MediaRouter API (in API 16): system will decide the best display for you!

2. Display Manager API (in API 17): Enumeration of displays

Using the Presentation API

// Get the MediaRouter service MediaRouter mMediaRouter = (MediaRouter)getSystemService(Context.MEDIA_ROUTER_SERVICE); // Care only about routes that have full video support.MediaRouter.RouteInfo mRouteInfo = mMediaRouter.getSelectedRoute(MediaRouter.ROUTE_TYPE_LIVE_VIDEO);Display presentationDisplay = mRouteInfo.getPresentationDisplay();

// Get the DisplayManager service. DisplayManager mDisplayManager = (DisplayManager)getSystemService(Context.DISPLAY_SERVICE); // enumerate the displaysDisplay[] presentationDisplays = mDisplayManager.getDisplays(DisplayManager.DISPLAY_CATEGORY_PRESENTATION);

Presentation API

MediaRouter.getSelectedRoute

(ROUTE_TYPE_LIVE_VIDEO)

MediaRouter.routeInfo

getPresentationDisplay()new Presentation

(activityContext, display)

.show()

Then, using MediaRouter.addCallback, you have to monitor:• onRouteUnselected• onRouteSelected• onRoutePresentationDisplayChanged

And inside the activity owning the Presentation:• onResume• onPause

How to get a Presentation displayed:

Testing your Second-Screen AppsOptions:• Real Hardware - supporting second screen functionality• Simulate secondary screen - new feature in Android* 4.2 (in Developer options). You

can select by resolution and DPI and once activated you get an overlay emulating the secondary screen.

Q&A