Date post: | 22-Jan-2018 |
Category: |
Engineering |
Upload: | imam-raza |
View: | 192 times |
Download: | 0 times |
Android N 7.0DevFest 2016 event, Iqra University, KarachiPresenter: Imam Raza
Speaker.bio.toString()
Senior Software Architect @ Folio3
Specialities:
Enterprise Software Architecture,
Mobile Software Architecture
About this presentation
me.loveQuestion==true. Let's have interactive session
The content is designed on basis of industry experience.
Love to do hands-on coding session but this session is not hands-on. Why?
See in later slides
Switching the gear with interesting silicon valley facts.
Agenda
Android Marketing Statistics
Android N
Market Statistic shared in DevFest 2012
Today Market Statistic
9 in every 10 smartphones is Android
Switching the gear
A mandatory books for all silicon
valley graduates seeking jobs.
Android N
What’s new in Android N?
Multi-Window Support
Notifications
JIT/AOT Compilation
Quick Path to App Install
Doze on the Go
Background Optimizations
SurfaceView
Number Blocking
Call Screening
Locales and Languages
New Emojis
ICU4J APIs in Android
WebView
OpenGL ES 3.2 API
Key Attestation
Network Security Config
Default Trusted CA
APK Signature Scheme v2
Scoped Directory Access
Keyboard Shortcuts Helper
Custom Pointer API
So many things to cover in 60min Session
Chose my fight for today session
Android Compiler
Recent Google strategy seems to removing the old intermediary java bytecode .class all
together. why? Due to Google dispute with Oracle over use of Java?
Android Runtime
A journey that starts with Dalvik VM and now ends removing dalvik completely. Why Google
has to throw away its dalvik vm?
Webview
How it will impact the cross-platform development app? how to keep webview changes be
tested before it is released some easy option.
Android Compiler
Q: Why Android need a new compiler?
Benefits of Jack
Completely open source
Available in AOSP; partners are welcome to contribute.
Speeds compilation time
Jack has specific supports to reduce compilation time: pre-dexing,
incremental compilation and a Jack compilation server.
Handles shrinking, obfuscation, repackaging and multidex
Using a separate package such as ProGuard is no longer necessary.
Compilation Prior to Jack/Jill
Compilation with Jack/Jill
If we want to use Java 8 language feature set in Android then Jack toolchain
is must. Remember Android doesn’t support all Java 8 features as of now.
Jack is must for Java 8 language features
How to use Jack/Jill in Gradle for compilation
Known Issues
Instant Run does not currently work.
Tools that work on generated .class file would not work e.g
Lint detectors that operate on class files
Tools and libraries that require the app’s class files (such as instrumentation tests with
JaCoCo)
Switching the gear
Zareen is a pakistani restaurant in
Google Mountain View.
1477 Plymouth Street, Suite C
Mountain View, CA 94043
http://www.zareensrestaurant.com/
Android RuntimeDalvik Vs ART
Timeline
Prior to Kitakat 4.4, android OS has only dalvik as runtime.
In Kitkat 4.4, Google introduced ART alongside with Dalvik as an experiment
and let user select the runtime from developer options.
Timeline
Lollipop 5.0 ART completely replaced Dalvik. App become fast but
installation start taking time.
Marshmallow 6.0 ART some fixes.
Android N added Just in Time (JIT) compiler with code profiling to ART that
fixes app installation time problem.
Dalvik Vs ART(Android RunTime)
● Dalvik is JIT(Just in time compiler) that
translate app code into machine code
when the app is run.
● As you progress through the app,
additional code is going to be compiled
and cached, so that the system can reuse
the code while the app is running.
● It has a smaller memory footprint and uses
less physical space on the device
● ART, is AOT(Ahead of Time) compiler
that compiles the intermediate language,
Dalvik bytecode, into a system-
dependent binary.
● The whole code of the app will be pre-
compiled during install (once), thus
removing the lag that we see when we
open an app on the device.
● As ART runs app machine code directly
(native execution), it doesn't hit the CPU
as hard as just-in-time code compiling on
Dalvik
ART Some benchmark shared by android police
increased speed in CPU floating operations by approx. 20%
increased speed in RAM operations by approx. 10%
increased speed in storage operations by approx. 10
CPU integer operations - slight advantage goes to Dalvik
ART Downside
The code is pre-compiled at app install time, so the installation
process takes a bit longer.
The generated machine code requires more space than the existing bytecode
With Android N faster App installation and System Update
How?
Android N Hybrid RuntimeProfile-guided JIT/AOT Compilation
Android N Hybride Runtime with JIT/AOT
There won’t be any compilation during install, and applications can be
started right away, the bytecode being interpreted.
There is a new, faster interpreter in ART accompanied by a new JIT, but the
JIT information is not persisted.
The code is profiled during execution and the resulted data is saved. Later,
when the device is idle and charging, ART will perform a profile-based
compilation of the hot sections of the code, the rest remaining untouched.
While this procedure is still called AOT for simplicity, it can be read All-Of-
the-Time compilation.
Android N Hybride Runtime with JIT/AOT
Switching the gear
Silicon valley awakes early in the
morning
WebView
Why bother for WebView?
cross-platform framework Ionic, Sencha ,phonegapMake use of Webview
Multiprocess Webview
Multiprocess Architecture
Multiprocess Webview
Starting with Chrome version 51 in Android 7.0, WebView will run web
content in a separate sandboxed process when the developer option
"Multiprocess WebView" is enabled.
one of the benefits of multiprocess is the ability to run the renderer in 32-bit
to save memory even when webview is being used by a 64-bit app.
Javascript run before page load
Javascript context will be reset when a new page is loaded.
Currently, the context is carried over for the first page loaded in a new
WebView instance.
Developers looking to inject Javascript into the WebView should execute the
script after the page has started to load.
Geolocation on insecure origins
Geolocation API will only be allowed on secure origins (over HTTPS.)
This policy is designed to protect users’ private information when they’re
using an insecure connection.
Production problems of cross-platform appsDue to webview updates
Just like any native application, cross-platform apps usually have issues
when webview is changed with the release of OS sdk API.
The impact of webview changes has lot on cross-platform app, as the whole
app is running under webview. So webview is like OS for cross-platform
app.
How to test app with Webview Beta updates
Testing with Webview Beta
Testing with Webview Beta
Switching the gear
Silicon valley folks are casual and
funny.
Doze
Q:What does Doze mean?
Lets ask Google translator
What is Android Doze?
A system mode that
saves battery by deferring apps'
CPU and
network activities
when the device is idle
Doze on the Go
Doze introduced in Android 6.0 MarshMallow
Android 7.0, Doze takes a step further and saves battery while on the go.
Any time the screen is off for a period of time and the device is unplugged,
Doze applies a subset of the familiar CPU and network restrictions to
apps. This means users can save battery even when carrying their devices
in their pockets.
Android N Doze
Doze Restriction
Network access is suspended.
GCM messages are suspended. Only high-priority GCM messages are
delivered.
The system ignores wake locks.
Standard AlarmManager alarms (including setExact() and setWindow()) are
deferred to the next maintenance window.
The system does not perform Wi-Fi scans.
Conditions that exit Doze restriction
The user explicitly launches the app.
The app has a process currently in the foreground (either as an activity or
foreground service, or in use by another activity or foreground service).
The app generates a notification that users see on the lock screen or in the
notification tray.
When the user plugs the device into a power supply.
Can I Whitelist App from Doze?
An app that is whitelisted can use the network and hold partial wake locks
during Doze and App Standby.
However, other restrictions still apply to the whitelisted app, just as they do
to other apps. e.g the whitelisted app’s jobs and syncs are deferred (on API
level 23 and below), and its regular AlarmManager alarms do not fire.
User can whitelist app from Doze
Apps can request for whitelisting from Doze
An app can fire the ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS
intent to take the user directly to the Battery Optimization, where they can
add the app.
An app holding the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
permission can trigger a system dialog to let the user add the app to the
whitelist directly, without going to settings. The app fires a
ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS Intent to trigger
the dialog.
How to test app against Doze
$ adb shell dumpsys battery unplug
$ adb shell am set-inactive <packageName> true
Questions