Android App Model · 2020-03-18 · (APK) APK is a packing format Parts of an APK – Classes.dex...
Transcript of Android App Model · 2020-03-18 · (APK) APK is a packing format Parts of an APK – Classes.dex...
Slide title
In CAPITALS
50 pt
Slide subtitle
32 pt
Muhammad Rizwan Asghar
March 18, 2020
ANDROID APP MODEL
Lecture 8
COMPSCI 702
Security for Smart-Devices
Top right
corner for
field
customer or
partner logotypes.
See Best practice
for example.
Slide title
40 pt
Slide subtitle
24 pt
Text
24 pt
5
20 pt
2
AN INSTANCE OF DALVIK VM PER APK
Init
Linux Kernel
Zygote
DalvikVM
APK2
DalvikVM
APK3
DalvikVM
APK1
Top right
corner for
field
customer or
partner logotypes.
See Best practice
for example.
Slide title
40 pt
Slide subtitle
24 pt
Text
24 pt
5
20 pt
3
ANDROID APPLICATION PACKAGE
(APK)
APK is a packing format
Parts of an APK
– Classes.dex (Dalvik executable)
Android app components
– Application can contain native code
C/C++ shared libraries linked dynamically
– Resources and assets
E.g., images, string values, layout definitions, and
raw data
– META-INF
It includes the certificate and signature information
– Application manifest
Top right
corner for
field
customer or
partner logotypes.
See Best practice
for example.
Slide title
40 pt
Slide subtitle
24 pt
Text
24 pt
5
20 pt
4
SIGNING YOUR APP
Android requires that all apps to be digitally
signed with a certificate
Android apps often use self-signed certificates
Android uses this certificate to identify the
developer of an app
Android follows the same origin policy– Android uses the same signing key pair to make sure that
updates are coming from the same developer
Top right
corner for
field
customer or
partner logotypes.
See Best practice
for example.
Slide title
40 pt
Slide subtitle
24 pt
Text
24 pt
5
20 pt
5
APPLICATION MANIFEST
An XML format
Declares application metadata and components– Names, intent filters, and permissions
Main elements– Package information
Package name and version
– App information
Launcher icon
– Activity component
– …
Top right
corner for
field
customer or
partner logotypes.
See Best practice
for example.
Slide title
40 pt
Slide subtitle
24 pt
Text
24 pt
5
20 pt
6
APPLICATION MANIFEST: A SAMPLE
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:"http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0"
package="com.example.compsci702.helloworld"
platformBuildVersionCode="23"
platformBuildVersionName="6.0-2438415">
<uses-sdk android:minSdkVersion="15"
android:targetSdkVersion="23" />
<application android:theme="@style/AppTheme"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:allowBackup="true"
android:supportsRtl="true">
<activity android:theme="@style/AppTheme_NoActionBar"
android:label="@string/app_name"
android:name="com.example. compsci702.helloworld.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Top right
corner for
field
customer or
partner logotypes.
See Best practice
for example.
Slide title
40 pt
Slide subtitle
24 pt
Text
24 pt
5
20 pt
7
ANDROID APP COMPONENTS
Android app is a combination of loosely
coupled components
Each component can offer multiple entry points
– Activity
User interface
– Service
Background services
– Content provider
Database
– Broadcast receiver
Mailbox for broadcasted messages
Top right
corner for
field
customer or
partner logotypes.
See Best practice
for example.
Slide title
40 pt
Slide subtitle
24 pt
Text
24 pt
5
20 pt
8
INTENT
Intents are named events
Represents the intent to do something
Examples– Launching an activity
– Starting a service or
– Broadcasting a message
Its payload and attributes describe the intended
action
It can be sent and received by an application
Top right
corner for
field
customer or
partner logotypes.
See Best practice
for example.
Slide title
40 pt
Slide subtitle
24 pt
Text
24 pt
5
20 pt
9
INTENT TYPES
Explicit– Sets the target component name
– E.g., “com.example.app.MainActivity”
Implicit– Provides information including action, data, and type
– Resolved at runtime by the Package Manager
– Android framework will find a suitable receiver for this intent
– Example
Action=intent.ACTION_VIEW;
Data=www.youtube.com
It will open the app that can show youtube
It could be the default web browser or youtube app
Top right
corner for
field
customer or
partner logotypes.
See Best practice
for example.
Slide title
40 pt
Slide subtitle
24 pt
Text
24 pt
5
20 pt
10
WHERE IS PACKAGE MANAGER?
Linux Kerne lDisplay Driver Camera Driver Bluetooth Driver
Shared Memory Driver Binder (IPC) Driver
Power ManagementUSB Driver Keypad Driver WiFi Driver
Audio Drivers
Appl icat ionsHome Dialer
Contacts
SMS/MMS
Email Calendar Media Player Albums
Appl icat ion Framework
IM Browser Camera
Clock
Calculator
…Voice Dial
Alarm
Android RuntimeCore Libraries
Dalvik Virtual Machine
View SystemContent Providers
Resource Manager …
Libc
Notification Manager
Location Manager
FreeType
SGL SSL
SQLite
WebKitOpenGL|ES
And r o id RuntimeCore Libraries
DalvikVirtual Machine
Libraries
FreeType
Surface Manager
OpenGL|ES
Media Framework
Activity Manager
Package Manager
Window Manager
Telephony Manager
Source: Android Anatomy and Physiology, Patrick Brady
Top right
corner for
field
customer or
partner logotypes.
See Best practice
for example.
Slide title
40 pt
Slide subtitle
24 pt
Text
24 pt
5
20 pt
11
ACTIVITY
A main building block of Android GUI
applications
Activity is like a website– Multiple activities ~ multiple web pages
– Main activity ~ homepage
– Moving from one activity to another ~ navigation
E.g., in Contacts app, choosing to compose a message to
a contact by launching the Messaging app
Top right
corner for
field
customer or
partner logotypes.
See Best practice
for example.
Slide title
40 pt
Slide subtitle
24 pt
Text
24 pt
5
20 pt
12
ACTIVITY LIFECYCLE
System calls component
as its state changes due
to user actions
If another activity is
started, the on-going
activity is paused
App process may be killed
A stopped activity may be
destroyed
Source: android.com
Top right
corner for
field
customer or
partner logotypes.
See Best practice
for example.
Slide title
40 pt
Slide subtitle
24 pt
Text
24 pt
5
20 pt
13
ACTIVITY MANAGER
Activity Manager is responsible for creating, destroying, and
managing activities
When the user starts an application for the first time, the Activity
Manager will create its activity and put it onto the screen
Later, when the user switches screens, the Activity Manager will
move that previous activity to a holding place
This way, if the user wants to go back to an older activity, it can be
started more quickly
Older activities that the user has not used in a while will be
destroyed in order to free more space for the currently active one
This mechanism is designed to help improve the speed
Top right
corner for
field
customer or
partner logotypes.
See Best practice
for example.
Slide title
40 pt
Slide subtitle
24 pt
Text
24 pt
5
20 pt
14
TO BE CONTINUED
See the next lecture
Top right
corner for
field
customer or
partner logotypes.
See Best practice
for example.
Slide title
40 pt
Slide subtitle
24 pt
Text
24 pt
5
20 pt
15
Questions?
Thanks for your attention!