Download Android - NIT Durgapur

Document related concepts
no text concepts found
Transcript
Introduction
Android is an operating system
based on the Linux kernel
designed primarily for touchscreen mobile
devices such as smartphones and tablet
computers.
History
Initially developed by Android, Inc., which Google
backed financially and later bought in 2005,
 To develop, in Rubin's words "smarter mobile devices
that are more aware of its owner's location and
preferences".
Google acquired Android Inc. on August 17, 2005,
making it a wholly owned subsidiary of Google.
Key employees of Android Inc., including Rubin,
Miner and White, stayed at the company after the
acquisition.
History
At Google, the team led by Rubin developed a
mobile device platform powered by the Linux
kernel.
Android was unveiled in 2007 along with the
founding of the Open Handset Alliance
The first Android phone (HTC Dream) was sold
in October 2008.
Open Handset Alliance
 The OHA was established on 6 November 2007,
led by Google with 34 members including mobile
handset makers, application developers, some
mobile carriers and chip makers.
 Android, the flagship software of the alliance, is
based on an open source license
 OHA members are contractually forbidden from
producing devices that are based off
incompatible forks of Android
 The source code for Android is available under
free and open-source software licenses.
 The Open Handset Alliance develops the changes
to the Linux kernel, in public, with source code
publicly available at all times.
 The rest of Android is developed in private by
Google, with source code released publicly when
a new version is released.
 Google collaborates with a hardware manufacturer to
produce a "flagship" device (part of the Nexus series)
 It features the new version of Android, then makes the
source code available after that device has been
released.
 Google licenses a suite of proprietary apps for Android,
such as Play Store, Google Search, and Google Play
Services
Features
Multi-touch
Multitasking
Screen capture
Video calling
Features
 Messaging SMS and MMS
 Web browser
 Voice based features
 Multiple language support
 Built in text to speech
Connectivity
 Android supports connectivity technologies including
–
–
–
–
GSM/EDGE,
Wi-Fi
Bluetooth,
LTE, CDMA, EV-DO, UMTS, NFC, IDEN and WiMAX.
 Bluetooth Supports
– voice dialing and sending contacts between phones,
sending files (OPP),
– accessing the phone book (PBAP), A2DP and AVRCP.
 Tethering Android supports tethering, which allows
a phone to be used as a wireless/wired Wi-Fi hotspot.
• Streaming media support :
–
–
–
–
RTP/RTSP streaming (3GPP PSS, ISMA),
HTML progressive download (HTML5 <video> tag).
Adobe Flash Streaming (RTMP)
HTTP Dynamic Streaming are supported by the Flash plugin.
• Media support :Android supports the following audio/video/still media
formats:
– WebM H.263, H.264, AAC, HE-AAC (in 3GP or MP4 container),
– MPEG-4 SP, AMR, AMR-WB (in 3GP container)
– MP3, MIDI, Ogg Vorbis, FLAC, WAV, JPEG, PNG, GIF, BMP, WebP.
• External storage :
– Most Android devices include microSD slot and can read microSD cards
formatted with FAT32, Ext3 or Ext4 file system.
– To allow use of high-capacity storage media such as USB flash drives and USB
HDD
Hardware support
Android devices can include
 still/video cameras,
 touchscreens, GPS,

accelerometers, gyroscopes, barometers,
magnetometers

dedicated gaming controls, proximity and
pressure sensors, thermometers,
 accelerated 3D graphics.
Other
• Java support :
– While most Android applications are written in Java
– Java classes are compiled into Dalvik executables and
run on Dalvik,
– Dalvik, a specialized virtual machine designed
specifically for Android and optimized for batterypowered mobile devices with limited memory
.
• Storage SQLite, a lightweight relational database,
is used for data storage purposes.
Android Architecture
Kernel Layer
At the bottom of the Android stack is the Linux Kernel. It
never really interacts with the users and developers, but
is at the heart of the whole system.
• Hardware Abstraction
• Memory Management Programs
• Security Settings
• Power Management Software
• Other Hardware Drivers (Drivers are programs that
control hardware devices.)
• Support for Shared Libraries
• Network Stack
Here is a Table highlighting the
different Kernel versions.
Native Libraries Layer
The next layer in the Android architecture includes Android’s native libraries.
Libraries carry a set of instructions to guide the device in handling different
types of data. For instance, the playback and recording of various audio and
video formats is guided by the Media Framework Library.
• Open Source Libraries:
• Surface Manager: composing windows on the screen
• SGL: 2D Graphics
• Open GL|ES: 3D Library
• Media Framework: Supports playbacks and recording of various audio,
video and picture formats.
• Free Type: Font Rendering
• WebKit: Browser Engine
• libc (System C libraries)
• SQLite
• Open SSL
Android Runtime
The Android runtime layer includes a set of core Java
libraries as well. Android application programmers
build their apps using the Java programming language.
It also includes the Dalvik Virtual Machine.
Dalvik Virtual Machine
Dalvik is open-source software. Dan Bornstein
originally wrote Dalvic VM which is responsible for
running apps on Android devices.
• It is a Register based Virtual Machine.
• It is optimized for low memory requirements.
• It has been designed to allow multiple VM
instances to run at once.
• Relies on the underlying OS for process isolation,
memory management and threading support.
• Operates on DEX files.
Application Framework Layer
• The applications directly interact with these blocks of the
Android architecture.
• Important blocks of Application Framework:
• Activity Manager: Manages the activity life cycle of
applications.
• Content Providers: Manage the data sharing between
applications. Telephony Manager: Manages all voice calls. We
use telephony manager if we want to access voice calls in our
application.
• Location Manager: Location management, using GPS or cell
tower
• Resource Manager: Manage the various types of resources
we use in our Application
Application Layer
The applications are at the topmost layer of the Android
stack. An average user of the Android device would
mostly interact with this layer (for basic functions, such
as making phone calls, accessing the Web browser etc.).
The layers further down are accessed mostly by
developers, programmers and the likes.
Several standard applications come installed with every
device, such as:
• SMS client app
• Dialer
• Web browser
• Contact manager
Android Software version history
The first commercial version, Android 1.0, was released in September
2008.
Android is under ongoing development by Google and the Open Handset
Alliance (OHA), and has seen a number of updates to its base operating
system since its initial release.
Since April 2009, Android versions have been developed under a codename and
released according to alphabetical order:
Cupcake (1.5)
Donut (1.6)
Eclair (2.0–2.1)
Froyo (2.2–2.2.3)
Gingerbread (2.3–2.3.7)
Honeycomb (3.0–3.2.6)
Ice Cream Sandwich (4.0–4.0.4)
Jelly Bean (4.1–4.3)
KitKat (4.4)
Hardware
• The main hardware platform for Android is the 32-bit ARMv7 architecture.
There is support for x86 from the Android-x86 project,and
• Google TV uses a special x86 version of Android. In 2013, Freescale
announced Android on its i.MX processor, i.MX5X and i.MX6X series.
• As of November 2013, current versions of Android require at least 512 MB
of RAM, and a 32-bit ARMv7, MIPS or x86 architecture processor, together
with an OpenGL ES 2.0 compatible graphics processing unit (GPU).
• Android supports OpenGL ES 1.1, 2.0 and 3.0. Some applications explicitly
require certain version of the OpenGL ES, thus suitable GPU hardware is
required to run such applications.
Why Android is killing Apple?
Reach and Cost
 The operating system is simply available to a
larger number of people
 Apple is maintaining a strong market share in
some of the world’s top economies, the US,
Japan, Europe, etc
 Android, on the other hand, has a range of
manufacturers producing a range of products
Competition & Innovation
 The battle is not just between Google and Apple
 Galaxy S4: exercise tracking software, better
multitasking functionality, and additional camera
settings
 HTC, on the other hand, has invested heavily in
its BoomSound system, Sense 5, and BlinkFeed.
Open Source ,Free market System
 Nvidia Shield is an excellent example of a
company utilizing Android in a fairly unique way
 Android USB Sticks-PC TV
Strong Developer Community
• ROMs like CyanogenMod have proven hugely popular
because of their punctual updates for handsets
• The custom MIUI ROM, which has proven so popular
that handsets pre-installed with the ROM sold out
almost as soon as they were announced.
• Exynos processor root exploit which was plaguing
various Samsung Galaxy handsets a few months back.
• The problem was initially addressed and patched by
members of the development community well before
Samsung put out their own updates
Google Ethos
Google has created a range of free
applications which improve the users experience
over the default operating system
Google Glass is a prime example of an idea,
willingness to Expirement.
Android attracts innovation from both
hardware and software developers, which, in
my opinion, is the main reason why our
favourite mobile operating system is killing
Apple.
Android, the world's most popular
mobile platform
• Android powers hundreds of millions of
mobile devices in more than 190 countries
around the world.
• It's the largest installed base of any mobile
platform and growing fast—every day another
million users power up their Android devices
for the first time and start looking for apps,
games, and other digital content.
Android apps have become invasive.
Categories of Applications
Games
Books & References
Business
Comics
Communication
Education
Entertainment
Finance
Health & Fitness
Libraries
Lifestyle
Live Wallpaper
Media & Video
Medical
Music & Audio
Social
Sports
Transportation
Travel& Local
Weather
Widgets
Development Environment Setup.
• Download the Android SDK.
• Install the ADT plug-in for Eclipse (if you’ll use
the Eclipse IDE).
• Download the latest SDK tools and platforms
using the SDK Manager.
• The Android SDK provides the API libraries and
developer tools necessary to build, test, and
debug apps for Android.
• For a new Android developer,
– download the ADT Bundle to quickly start
developing apps. It includes the essential Android
SDK components and a version of the Eclipse IDE
with built-in ADT (Android Developer Tools).
With a single download, the ADT Bundle includes
everything you need to begin developing apps:
• Eclipse + ADT plugin
• Android SDK Tools
• Android Platform-tools
• The latest Android platform
• The latest Android system image for the emulator
ADT Bundle
• http://dl.google.com/android/adt/adt-bundlewindows-x86-20131030.zip
SDK Tools Only
• http://dl.google.com/android/androidsdk_r22.3-windows.zip
Creating an Android Project
An Android project contains all the files that
comprise the source code for your Android app.
The Android SDK tools make it easy to start a
new Android project with a set of default project
directories and files.
Creating an Android App
Running Android App
• AndroidManifest.xml The manifest file describes the fundamental
characteristics of the app and defines each of its components.
• One of the most important elements manifest should include is the
<uses-sdk> element. This declares our app's compatibility with different
Android
versions
using
the
android:minSdkVersion
and
android:targetSdkVersion attributes. For our first app, it should look like
this:
<manifest
xmlns:android="http://schemas.android.com/apk/res/android" ... >
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17"
/>
...
</manifest>
Running Android App
• src/ : Directory for your app's main source files.
• res/: Contains several sub-directories for app
resources. Here are just a few:
– drawable-hdpi/ : Directory for drawable objects
(such as bitmaps) that are designed for high-density
(hdpi) screens.
– layout/ : Directory for files that define your app's user
interface.
– values/ : Directory for other various XML files that
contain a collection of resources, such as string and
color definitions.
Building a Simple User Interface
• The graphical user interface for an Android app is built
using a hierarchy of View and ViewGroup objects.
• View objects are usually UI widgets such as buttons or
text fields and ViewGroup objects are invisible view
containers that define how the child views are laid out,
such as in a grid or a vertical list.
• Android provides an XML vocabulary that corresponds
to the subclasses of View and ViewGroup so you can
define your UI in XML using a hierarchy of UI elements.
Illustration of how ViewGroup objects form
branches in the layout and contain other
View objects.
Format of activity_main.xml file from the
res/layout/ directory.
In Eclipse, when we open a layout file, we’re first shown
the Graphical Layout editor. This is an editor that helps
us build layouts using WYSIWYG tools.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res
/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
</LinearLayout>
Linear Layout
 LinearLayout is a view group (a subclass of ViewGroup) that
lays out child views in either a vertical or horizontal
orientation, as specified by the android:orientation
attribute. Each child of a LinearLayout appears on the
screen in the order in which it appears in the XML.
 The other two attributes, android:layout_width and
android:layout_height, are required for all views in order to
specify their size.
 Because the LinearLayout is the root view in the layout, it
should fill the entire screen area that's available to the app
by setting the width and height to "match_parent".
Android Application Components
The components are loosely coupled by the application manifest
file AndroidManifest.xml that describes each component of the
application and how they interact.
There are following four main components that can be used
within an Android application:
Activities
• An activity represents a single screen with a user interface.
•
For example, an email application might have one activity that
shows a list of new emails, another activity to compose an email,
and another activity for reading emails.
• if an application has more than one activity, then one of them
should be marked as the activity that is presented when the
application is launched.
• An activity is implemented as a subclass of Activity class as follows:
public class MainActivity extends Activity { }
Starting an Activity
Unlike other programming paradigms in which apps
are launched with a main() method, the Android
system initiates code in an Activity instance by invoking
specific callback methods that correspond to specific
stages of its lifecycle.
There is a sequence of callback methods that start up
an activity and a sequence of callback methods that
tear down an activity.
Understand the Lifecycle Callbacks
Add a Text Field
To create a user-editable text field, add an
<EditText> element inside the <LinearLayout>.
Like every View object, we must define certain XML
attributes to specify the EditText object's
properties. Here’s how you should declare it inside
the <LinearLayout> element:
<EditText android:id="@+id/edit_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/edit_message" />
Add String Resources
 When we need to add text in the user interface, we
should always specify each string as a resource.
 String resources allow us to manage all UI text in a
single location, which makes it easier to find and
update text.
 By default, our Android project includes a string
resource file at res/values/strings.xml. Add a new string
named "edit_message" and set the value to "Enter a
message." (We can delete the "hello_world" string.)
 While we are in this file, also add a "Send" string for
the button you’ll soon add, called "button_send".
strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">My First App</string>
<string name="edit_message">Enter a
message</string>
<string name="button_send">Send</string>
<string name="action_settings">Settings</string>
<string
name="title_activity_main">MainActivity</string>
</resources>
Add a Button
Now add a <Button> to the layout, immediately
following the <EditText> element:
<Button android:id="@+id/button “
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send" />
The height and width are set to "wrap_content"
so the button is only as big as necessary to fit
the button's text.
This is how it looks like
Android OS Security:
Risks and Limitations
Android
Platform-strong
increase
in
vulnerability,as exploits were long publicly available
before the respective Android version’s release.
File System and User/Group Permissions-the
Android kernel assigns each app its own user ID on
installation
Android API Permission Model and Manifest
File-All or none policy.
Android OS Security:
Risks and Limitations
 Android Market (”Google Play”)-As anyone can
publish an app after registration, pirated Apps
 Remote Installation and Uninstallation-Google
possesses the ability to remotely remove or install
any app from/to all Android devices.
 Patch Process-Erroneous installation images may
immediately render customer devices unusable.