5 Show of HandsHow 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 devicesBased on the Linux kernel, but most things around the kernel are developed anewDeveloped by initially by Android Inc, acquired by Google in 2005Supports writing managed code in JavaSource 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 wayEasy to manageNot Sun/Oracle Java (discussed in detail later)Google SDK and other dev tools downloadable on for freeMotorola EMDK available on support website for freeAndroid 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 portableRhoMobile (Motorola)Use web technologies to build cross-platform applicationsPackaged as standard Android app when deployed to the deviceAndroid 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 yearsWell architected OSEasy to use development toolsAccess to open source for fixes and modsConsumer by designEnd user has too much controlLacks MDM, Security, Lockdown, mass mgmtMany enterprise-grade features have been added, but still not enough to call an Enterprise OSAndroid 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 PlatformConstrained processing power, memory, storage and battery lifeVariety of device form factors and capabilities (screen size, keyboard, wireless interfaces)Variety of target CPUs (variations of ARM, x86, etc)Non tech-savvy usersApple / MS are already ahead in the gameResultsMinimalistic OS kernelMinimizing memory use through sharing, etcSleep whenever possibleApplication runtime must be abstracted from the OS and hardware platformApplication runtime must be sandboxed to minimize malware impactReuse standard components as much as possibleProvide ‘bare’ OS core and have app developers create lots of portable apps
10 Android OS Architecture Resulting choicesModified Linux 3.x KernelLightweight build, variety of CPU architectures and hardware supported, proven tech, lots of security optionsTweaks and modifications to support advanced memory/power/etc management for resource-constrained devicesJava for applicationsProven technology popular among developers - Enterprise (JSP, etc), mobile (J2ME, etc) and many othersRuns in JavaVM = OS/hw independent = supports diverse set of devices - Missing HW features can be virtualized or replaced with stubsBut – greater CPU/RAM requirements - Custom Java libraries using open source and in-house developed components to address thisDalvik Java VMA custom Java VM optimized for mobile devices - Memory sharing, extra security and sandboxing, quick startup, etcProvide tools to build Dalvik Java apps from ‘standard’ Java source code
11 Android OS Architecture Resulting System Architecture DiagramAPPLICATIONSHomeContactsPhoneBrowser…APPLICATIONS FRAMEWORKActivity ManagerWindow ManagerContent ProvidersViewSystemPackage ManagerTelephony ManagerResource ManagerLocation ManagerNotification ManagerLIBRARIESANDROID RUNTIMESurface ManagerMedia FrameworkSQLiteCore LibrariesOpenGL | ESFreeTypeWebKitDalvik Virtual MachineExpect a lot of talk in this slideThis 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.SGLSSLlibcLINUX KERNELDisplayDriverCamera DriverFlash Memory DriverBinder (IPC)DriverKeypadDriverWiFi DriverAudioDriversPower Management
12 Android OS Architecture Resulting System Architecture DiagramExpect a lot of talk in this slideThis 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 VersioningEvery OS Version has an API Level.Even minor versions may have a different API LevelApp developer targets application for a minimum API levelBecause 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 hacksNow, 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-developersContains useful tools and driversEnable device troubleshooting and low-level management (ADB, DDMS, etc)USB driversNon-developer SDK installSelect “Download for other platforms” -> “SDK Tools Only”Choose bundle for your platform. EXE for simple install, ZIP for customInstall to a path with NO SPACESRun SDK Manager and install onlyAndroid SDK Tools and Platform-ToolsAdd the <SDK>\tools and <SDK>\platform-tools to system PATHInstall Motorola Android USB DriverSupport CentralValidate with ‘adb devices’More on ADB laterInstall to a path with NO SPACESYes, 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 DeviceWe will discuss the details later.I also have Google USB driver installed to access Nexus device.
16 Agenda Get Connected ADB Usage Modes (command line, gui) Pass around jump drive – copy to desktop folderDo the ADB Super-Fast InstallationTalk about USB connection modesADB 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 processGives both visual and command line accessBut it takes how long ?!?If you search “15 second ADB install” you will find a windows install for ADB and FastbootYes it’s about that fistQuick and easyYou can also do a “super-fast install” by dropping just a few files into your PCGives command line accessReally quick and easy
18 Setup Directions From the memory stick being handed around.. Copy the folder “ADB” to your desktopLook in the folder, find and install the MSI Android USB driversConnect your device with a USB cableGo to Settings…Developer Options..enable Developer Options (slide ON)check USB Debugging and Stay AwakeRun “adb devices” to check connection
19 USB Connection Modes USB Mass Storage – direct connection to PC Raw, not sharable, access only to sdcardsComplete control - can format, FATonlySeems to be downplayed as of JellyBeanPTP, MTP – managed connection to PCPicture Transfer Protocol – for camera (pics) Media Transfer Protocol – all kinds of filesFile managed, sharable, access only to sdcardsLimited control – read, write files and folder
20 How ADB Connection Differs ADB allows much greater access to filesFile access not limited to sdcardsAccess from “/” limited only by file permissions/data/tmp, sdcards, /enterprise/usr, …ADB allows interactive running of commands on deviceADB also has higher-level functions for support of development/debugging/screen sharing
21 USB Connection Modes Android PC USB / |-/etc |-/data |-/enterprise storage volumesUSB/|-/etc|-/data|-/enterprise|-/sdcard|-/system|-/storage| |-/sdcard| …File TransferUSBScanFile system accessmass storage switchOFF ONUSBStorATAPIRaw device accessSD card
22 USB Connection Modes Android PC Debug Agent USB ADB cmd or shell / storage volumesUSBADBcmd or shell/|-/etc|-/data|-/enterprise|-/sdcard|-/system|-/storage| |-/sdcard| …File TransferUSBScanFile system accessmass storage switchOFF ONUSBStorATAPIRaw device accessSD card
23 ADB Connection Test ADB Installation needs to be finished by this time Folder with ADBInstallation of latest DriversRun “adb devices”Be sure you have a connectionCheck USB modeAll 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 executionFile/folder transfer.. push/pull/syncPackage install/update/uninstallPackage run/run with parms/stopUse with multiple devices, use over WiFiUse to find out things..Explore filesystem and permissions problemsadb 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 windowthen 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 wayOr 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 mobileand arrange all the files as I want them to beConnect USB via and configure ADB Debugthen run a script thatUses “adb push” the folder as a single item..Installs and runs some APKsScript can end with a command to run ERtests persistencedisables USB DebugWhen setup tests OK, SAME procedure deploys units
29 File Management & ADB Using ADB shell: df, mountcd, pwd, ls, ls -la, mkdir, cp, etc…Piping ‘|’ and redirecting to a file ‘>’Including external launchesadb shell “cd /system/bin; ls” > commandList.txtadb shell “cd /system/bin; ls –l | find “toolbox” > toolbox.txtgrep, more, busyboxUnderstanding permissions (rwxd, user/group/all)Understanding storage modesWhen USB Storage mode is availableCheck Linux kernel version (cat /proc/version)ADB push/pull file to/from SD CardMore details on ADB and /proc latercat /proc/versionLinux version svn1573 (gcc version (Sourcery G++ Lite 2010q1-202) ) #1 SMP PREEMPT Thu Aug 22 17:06:59 CST 2013
30 ADB ScriptingEven COMPLEX tasks can be made simple, reliable and fast..Though you still have to enable USB DebugAnd remember to disable it when you’re doneAnd prevent users from re-enabling itCombine 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 applicationsCorporate dataCorporate WLAN settingsNow 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.