Android - ByrneTube

Download Report

Transcript Android - ByrneTube

Android
Operating Systems
Case Study
1
Topics
 History of Android
 Activity Manager
 Architecture
 Threads and States
 Virtual Memory
2
What is it?
 Android is a mobile operating system developed by Google,
based on the Linux kernel and designed primarily
for touchscreen mobile devices such
as smartphones and tablets.
 Android's user interface is mainly based on direct
manipulation, using touch gestures that loosely correspond to
real-world actions, such as swiping, tapping and pinching, to
manipulate on-screen objects, along with a virtual
keyboard for text input.
3
History of Android
 Android, Inc. was founded in Palo Alto, California in
October 2003
 In July 2005, Google acquired Android Inc. for at least $50
million.
 On November 5, 2007, the Open Handset Alliance (Google,
Samsung, Sprint, Nextel, T-Mobile) announced open
standards for mobile devices and that Android was it’s first
product (mobile device platform built on the Linux Kernel)
4
Android – Activity Manager
 Zygote is a special process that launches applications
 Users request an application launch by tapping the screen
 The home screen is the only application listening onClick()
 A Handler through the Binder calls the Activity Manager
 The Activity Manager receives the request to startActivity()
 Zygote forks itself and starts a new VM to run the app.
 It does this via startViaZygote() method which will open a connection to the
Zygote socket (/dev/socket/zygote)
Source: anatomyofandroid.com
5
Android Activity Manager Flow
6
Android Architecture
7
Threads
 When an application is launched, the system creates a thread
of execution for the application, called "main.
 This thread is very important because it is in charge of
dispatching events to the appropriate user interface widgets,
including drawing events.
 It is also the thread in which your application interacts with
components from the Android UI toolkit (called UI thread)
8
Worker Threads
Because of the single thread model, it's vital to the responsiveness of your
application's UI that you do not block the UI thread. If you have operations to
perform that are not instantaneous, you should make sure to do them in separate
threads ("background" or "worker" threads).
public void onClick(View v) {
new Thread(new Runnable() {
public void run() {
Bitmap b = loadImageFromNetwork("http://example.com/image.png");
mImageView.setImageBitmap(b);
}
}).start();
}
https://developer.android.com/guide/components/processes-and-threads.html
9
Processes in order of importance
Foreground process – required for what the user is
currently doing.
2) Visible process – does work that user is currently aware
of
3) Service process - is one holding a Service that has been
started with the startService() method.
4) Cached process is one that is not currently needed, so
the system is free to kill it when memory is needed
elsewhere. Kept in a LRU list
1)
10
Virtual Memory in Android
 Android doesn't use virtual memory by default. Transparently
writing pages of memory to flash storage is bad for battery life
(and for the life of your flash storage, which can only handle a
certain number of writes) and performance, especially since the
application has no control over which parts of memory are "paged
out".
 Instead, Android manages memory using the same mechanism it
uses to decide when to terminate apps that are no longer running.
When it finds it needs to free up some RAM, it chooses an app
that was cached (one that isn't currently in use). It terminates this
app to free its RAM, but first, it gives that app's activities a chance
to save some state by writing it to storage.
11
Virtual Memory in Android
 Of course, Android is based on Linux, and uses virtual
memory in other ways not visible to the user. Android
systems must have an MMU, so apps use virtual, not physical,
addresses.
Note: You can enable swap on Android. It's not recommended
to do so in most cases, because it defeats the memory-saving
mechanism described above. Adding a swap partition will make
the battery run down faster, wear out your flash storage faster,
and make the system less responsive
12
Ex) Samsung Galaxy S7 Specs
 Display







13
5.1 inch Display (1440 X 2560 Resolution)
Processor
Octa Core Snapdragon 820, Exynos 8890,
64 bit Chipset
Dimensions
142.4 X 69.6 X 7.9 mm, 152 grams
OS
Android v6.0 (Marshmallow OS)
RAM
4 GB
Memory
32 / 64 GB, Micro SD up to 200 GB
Networking
2G, 3G, 4G LTE, HSPA, GSM support v4.2
Bluetooth, NFC, Wi-Fi, A-GPS, GLONASS
Release date
March 11, 2016