Download presentation
Published byGloria Richards Modified over 10 years ago
1
APPFORUM2014 Helping the developer community build next-generation, multi-platform apps.
SCHAUMBURG, ILLINOIS | SEPTEMBER 8-10
2
Ritesh Gupta Ι Sr. Manager – WW Technical Operations
Android Bootcamp Ritesh Gupta Ι Sr. Manager – WW Technical Operations
3
Android Bootcamp Agenda
Welcome to Appforum 2014 Android Overview & Architecture ADB – Getting connected Android Application basics Build an simple android application
4
Android Overview
5
Show of Hands How many people know what Android is? How many are Windows developers? Do you have the Android SDK Installed?
6
Android overview What is Android?
A software platform and OS for mobile devices Based on the Linux kernel, but most things around the kernel are developed anew Developed by initially by Android Inc, acquired by Google in 2005 Supports writing managed code in Java Source available via AOSP project (Android Open Source Project)
7
Android overview Development options
Android Java (Google SDK + Motorola EMDK) Most Android apps (and some system services) are written this way Easy to manage Not Sun/Oracle Java (discussed in detail later) Google SDK and other dev tools downloadable on for free Motorola EMDK available on support website for free Android Native SDK (Google NDK) Write some code in C/C++ (high-performance routines). Cannot write the whole app in C++, still must build a Java app. Different APIs, high complexity, less portable RhoMobile (Motorola) Use web technologies to build cross-platform applications Packaged as standard Android app when deployed to the device Android as an operating system is based on Linux, but most apps are written in java and then compiled by the Android SDK. The resulting package is then executed by a virtual machine that runs on the device called Dalvik. There is something called NDK, which allows using C/C++. Many people think that it allows writing “pure” C/C++ code running directly in the Linux OS (i.e. outside the Java VM), and that the existing WM C/C++ apps can thus be easily ported. This is wrong. First of all, WM APIs are not available in Android, so you need to replace all the API calls (and in many cases, the flows and logic of using those APIs). Second, with NDK, in fact, you are running a Java app (within the java VM) that will be able to refer to some C/C++ components that can be run as direct CPU-specific binary code. There is still a lot of wrappers involved, and basically the resulting project is less portable (binary code depends on CPU architecture), and more complex. What are your options for writing Android apps on MSI devices? Can you write native android java apps and native android c apps? Can you write apps in Motorolas Rhomobile mobility suite today that will run on MSI Android devices? The answer is yes to all three. Remember that Android running on MSI devices is based off standard commercial open source android and passes the Compatibility Test Suite. This is not dev course, so we will try to contain the developer information to an absolute minimum (things you need to know). You still have to know a few key concepts.
8
Android and The Enterprise
Evolution over the years Well architected OS Easy to use development tools Access to open source for fixes and mods Consumer by design End user has too much control Lacks MDM, Security, Lockdown, mass mgmt Many enterprise-grade features have been added, but still not enough to call an Enterprise OS Android is the next best alternative OS for the enterprise. However it lacks many enterprise class features today. Motorola is researching the gaps in order to deliver enterprise Android
9
Android OS Architecture Requirements
Design constraints for Android Platform Constrained processing power, memory, storage and battery life Variety of device form factors and capabilities (screen size, keyboard, wireless interfaces) Variety of target CPUs (variations of ARM, x86, etc) Non tech-savvy users Apple / MS are already ahead in the game Results Minimalistic OS kernel Minimizing memory use through sharing, etc Sleep whenever possible Application runtime must be abstracted from the OS and hardware platform Application runtime must be sandboxed to minimize malware impact Reuse standard components as much as possible Provide ‘bare’ OS core and have app developers create lots of portable apps
10
Android OS Architecture
Resulting choices Modified Linux 3.x Kernel Lightweight build, variety of CPU architectures and hardware supported, proven tech, lots of security options Tweaks and modifications to support advanced memory/power/etc management for resource-constrained devices Java for applications Proven technology popular among developers - Enterprise (JSP, etc), mobile (J2ME, etc) and many others Runs in JavaVM = OS/hw independent = supports diverse set of devices - Missing HW features can be virtualized or replaced with stubs But – greater CPU/RAM requirements - Custom Java libraries using open source and in-house developed components to address this Dalvik Java VM A custom Java VM optimized for mobile devices - Memory sharing, extra security and sandboxing, quick startup, etc Provide tools to build Dalvik Java apps from ‘standard’ Java source code
11
Android OS Architecture
Resulting System Architecture Diagram APPLICATIONS Home Contacts Phone Browser … APPLICATIONS FRAMEWORK Activity Manager Window Manager Content Providers View System Package Manager Telephony Manager Resource Manager Location Manager Notification Manager LIBRARIES ANDROID RUNTIME Surface Manager Media Framework SQLite Core Libraries OpenGL | ES FreeType WebKit Dalvik Virtual Machine Expect a lot of talk in this slide This is diagram as presented by Google to everyone. Linux kernel (red) is THE Linux kernel – open source project. However, Android adds some of it’s own proprietary patches to Linux kernel (add some features, drop some others) as initally Linux was not expected to run on smartphones. Over the years, some (but not all) of Android patches have actually made it into the Linux mainstream. Kernel also contains drivers. Unlike ‘big’ Linux, one cannot load/unload drivers dynamically in Android. Then there are libraries (Green). These are native C/C++ code, provide all sorts of functions to the remainder of the OS. Not a lot to discuss. Note that WebKit is there, SQL support (SQLite), OpenGL support, SSL and lots of other cool techs. There’s a library called Bionic, which is Android version of ‘libc’ (main C runtime library) in Linux. The Runtime (Gold) is the core of Android. Here the Java VM (currently Dalvik( runs user apps and provides some libraries to them. Dalvik written by Google from scratch, and Java Core Libraries are from Apache Harmony project (where all the Oracle lawsuit came from). All the blue stuff on top of runtime cannot directly talk to the green stuff and has to go through Java VM (so you could swap SSL implementation w/o rewriting the apps, for example). This includes some Framework libraries (lower blue stuff) that provide the API for developers, runs some system services, etc, and userspace apps. Note that a decent share of Android services (telephony manager, etc) are implemented as Java apps themselves. So far, that’s all you need to know about the OS structure, we’ll discuss more details later. SGL SSL libc LINUX KERNEL Display Driver Camera Driver Flash Memory Driver Binder (IPC) Driver Keypad Driver WiFi Driver Audio Drivers Power Management
12
Android OS Architecture
Resulting System Architecture Diagram Expect a lot of talk in this slide This is diagram as presented by Google to everyone. Linux kernel (red) is THE Linux kernel – open source project. However, Android adds some of it’s own proprietary patches to Linux kernel (add some features, drop some others) as initally Linux was not expected to run on smartphones. Over the years, some (but not all) of Android patches have actually made it into the Linux mainstream. Kernel also contains drivers. Unlike ‘big’ Linux, one cannot load/unload drivers dynamically in Android. Then there are libraries (Green). These are native C/C++ code, provide all sorts of functions to the remainder of the OS. Not a lot to discuss. Note that WebKit is there, SQL support (SQLite), OpenGL support, SSL and lots of other cool techs. There’s a library called Bionic, which is Android version of ‘libc’ (main C runtime library) in Linux. The Runtime (Gold) is the core of Android. Here the Java VM (currently Dalvik( runs user apps and provides some libraries to them. Dalvik written by Google from scratch, and Java Core Libraries are from Apache Harmony project (where all the Oracle lawsuit came from). All the blue stuff on top of runtime cannot directly talk to the green stuff and has to go through Java VM (so you could swap SSL implementation w/o rewriting the apps, for example). This includes some Framework libraries (lower blue stuff) that provide the API for developers, runs some system services, etc, and userspace apps. Note that a decent share of Android services (telephony manager, etc) are implemented as Java apps themselves. So far, that’s all you need to know about the OS structure, we’ll discuss more details later.
13
Android OS Architecture
Libraries and Versioning Every OS Version has an API Level. Even minor versions may have a different API Level App developer targets application for a minimum API level Because apps are targeted for a minimum API level, most older Android apps will work just fine on new Android releases. Does not apply to low-level system apps and hacks Now, every Android version has what is called an api level. For example, Android 2.2, nicknamed Froyo, has an api leval of 8. As an app developer, you target your application to a minimum api level. This means that older android apps typically run fine on new Android releases.
14
Accessing Android Devices
Android SDK for non-developers Contains useful tools and drivers Enable device troubleshooting and low-level management (ADB, DDMS, etc) USB drivers Non-developer SDK install Select “Download for other platforms” -> “SDK Tools Only” Choose bundle for your platform. EXE for simple install, ZIP for custom Install to a path with NO SPACES Run SDK Manager and install only Android SDK Tools and Platform-Tools Add the <SDK>\tools and <SDK>\platform-tools to system PATH Install Motorola Android USB Driver Support Central Validate with ‘adb devices’ More on ADB later Install to a path with NO SPACES Yes, that’s a 21st-century cutting-edge state-of-the-art OS for you! We are intentionally not touching the topic of NDK and Emulator images. Should we? AVD Manager = Android Virtual Device We will discuss the details later. I also have Google USB driver installed to access Nexus device.
15
ADB – Getting Connected
16
Agenda Get Connected ADB Usage Modes (command line, gui)
Pass around jump drive – copy to desktop folder Do the ADB Super-Fast Installation Talk about USB connection modes ADB Usage Modes (command line, gui) What you can do with ADB and scripts (and what you CAN’T do, and why – actually SEE how file permissions control your access) Summary of Online Resources
17
ADB Super-Fast Installation
When you install the Android SDK, ADB is installed as part of that process Gives both visual and command line access But it takes how long ?!? If you search “15 second ADB install” you will find a windows install for ADB and Fastboot Yes it’s about that fist Quick and easy You can also do a “super-fast install” by dropping just a few files into your PC Gives command line access Really quick and easy
18
Setup Directions From the memory stick being handed around..
Copy the folder “ADB” to your desktop Look in the folder, find and install the MSI Android USB drivers Connect your device with a USB cable Go to Settings…Developer Options.. enable Developer Options (slide ON) check USB Debugging and Stay Awake Run “adb devices” to check connection
19
USB Connection Modes USB Mass Storage – direct connection to PC
Raw, not sharable, access only to sdcards Complete control - can format, FATonly Seems to be downplayed as of JellyBean PTP, MTP – managed connection to PC Picture Transfer Protocol – for camera (pics) Media Transfer Protocol – all kinds of files File managed, sharable, access only to sdcards Limited control – read, write files and folder
20
How ADB Connection Differs
ADB allows much greater access to files File access not limited to sdcards Access from “/” limited only by file permissions /data/tmp, sdcards, /enterprise/usr, … ADB allows interactive running of commands on device ADB also has higher-level functions for support of development/debugging/screen sharing
21
USB Connection Modes Android PC USB / |-/etc |-/data |-/enterprise
storage volumes USB / |-/etc |-/data |-/enterprise |-/sdcard |-/system |-/storage | |-/sdcard | … File Transfer USBScan File system access mass storage switch OFF ON USBStor ATAPI Raw device access SD card
22
USB Connection Modes Android PC Debug Agent USB ADB cmd or shell /
storage volumes USB ADB cmd or shell / |-/etc |-/data |-/enterprise |-/sdcard |-/system |-/storage | |-/sdcard | … File Transfer USBScan File system access mass storage switch OFF ON USBStor ATAPI Raw device access SD card
23
ADB Connection Test ADB Installation needs to be finished by this time
Folder with ADB Installation of latest Drivers Run “adb devices” Be sure you have a connection Check USB mode All good – ready to proceed?
24
Why Study ADB? Easiest way to get familiar with basics of how device is set up and some basics about file security. Can be used as tool to deploy apps and settings. Great tool for TESTing what you are about to deploy, even if you will be using an MDM This is as close as we are going to get to the feeling we had on MW/CE that we could use ActiveSync connection to run RAPI installs or to “drop in” files to achieve unit configuration.
25
ADB capabilities to cover..
Shell or remote execution File/folder transfer.. push/pull/sync Package install/update/uninstall Package run/run with parms/stop Use with multiple devices, use over WiFi Use to find out things.. Explore filesystem and permissions problems adb shell getprop | find “MX” adb pm list .. packsges, permissions, features
26
ADB Capabilities - Backup
Rumored to be able to “clone” setup.. It cannot (at least in JB) It’s a darn GOOD thing that it cannot.. Why? Expect future versions of the OS to further restrict what can be exported from a device. Way too slow for use in actual deployments
27
How Easy it Used to Be In Windows CE, you could could..
set up a folder on our desktop, with all the files arranged just as we wanted them on the mobile, Connect USB via ActiveSync, open the AS file browser window then drag and drop the \application folder as a single item.. It copied all the files.. Then cold boot to test your setup. you could deploy devices the same way Or build a custom image from the folder
28
How easy it can be now.. Now with ADB, you can
make a folder on your desktop, with all the files arranged just as we want them on the mobile and arrange all the files as I want them to be Connect USB via and configure ADB Debug then run a script that Uses “adb push” the folder as a single item.. Installs and runs some APKs Script can end with a command to run ER tests persistence disables USB Debug When setup tests OK, SAME procedure deploys units
29
File Management & ADB Using ADB shell:
df, mount cd, pwd, ls, ls -la, mkdir, cp, etc… Piping ‘|’ and redirecting to a file ‘>’ Including external launches adb shell “cd /system/bin; ls” > commandList.txt adb shell “cd /system/bin; ls –l | find “toolbox” > toolbox.txt grep, more, busybox Understanding permissions (rwxd, user/group/all) Understanding storage modes When USB Storage mode is available Check Linux kernel version (cat /proc/version) ADB push/pull file to/from SD Card More details on ADB and /proc later cat /proc/version Linux version svn1573 (gcc version (Sourcery G++ Lite 2010q1-202) ) #1 SMP PREEMPT Thu Aug 22 17:06:59 CST 2013
30
ADB Scripting Even COMPLEX tasks can be made simple, reliable and fast.. Though you still have to enable USB Debug And remember to disable it when you’re done And prevent users from re-enabling it Combine that with the “quick install” and.. You can send quick install and some scripts to a partner, and he can be staging units without an MDM this afternoon.
31
Remember - ADB is Dangerous
Imagine that you deploy devices, containing.. Corporate owned applications Corporate data Corporate WLAN settings Now imagine someone takes a device home and connects ADB… Hey, it’s just a portable device, what could possibly go wrong? (and if it does -- who will get blamed?) Rule: Never deploy with ADB enabled. Ideal: Never allow users to enable ADB.
32
Android Application Fundamentals
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.