3.3 KiB
3.3 KiB
Introduction to Android
Linux Kernel: threading, low-level memory management, driver
Hardware Abstraction Layer: Libraries for hardware modules, because different devices have different hardware
Android Runtime: A virtual machine
Native C/C++ Libraries: Libraries for rendering & fundamental core functionalities
Java API Framework: Programming interface
System Apps: Normal apps that can be customised.
Android-Specific Mods
Android is based on Linux with some key differences:
- Wake locks - keep the phone awake
- Binder - inter-process communication; this is so no app can communicate with others, otherwise banking apps could be compromised
ashmem- shared memory- oom - kills processes when memory is low
- alarm manager - wakes up the phone when necessary (raise to wake)
Android Apps
- Applications are sandboxed
- A security mechanism for separately running applications and data
- Android application sandbox
- Linux is a multi-user system - this isn't needed
- Makes use of Linux permissions and security
- No root access
System Boot-up Process
- Boot ROM/Bootloader: Load bootloader into RAM, detect external RAM, set up network, memory, etc.
- Kernel: Set up cache, protected memory, scheduling and load drivers
- Init: Mount directories like
/sys,/devand runrcscripts. - Zygote & VM: Enables code sharing across the Android VM for quick startup of separate VMs for different apps
- System service: Power manager, activity manager, telephony registry, package manager.
Zygote
- Initialise a process that has all core libraries linked in.
- Load all
*.javaand*.androidclasses at boot. - Initially create a single Android VM process
- When the user runs an application
- Creates a copy of itself in a separate address space
- Does not copy memory; instead, refers to original memory until modified
Android Compilation
-
Applications are written in Java and run on Google's own VM - Dalvik/Android Runtime
-
.apkis analogous to.exe
Dalvik
- Dalvik architecture is register-based rather than stack-based.
- This makes it optimised to use less space
- Executes its own Dalvik bytecode rather than Java bytecode
Android Programming Model
- Traditional OS applications
- Single entry point -
main() - OS loads the program into a process and executes
- Single entry point -
- Java Applications
- A Java VM is instantiated
- Loads all classes used by the application
- Executes
main()
- Component-based model
- Multiple entry points - think sharing a photo through WhatsApp; WhatsApp loads in a different way.
- Not all entry points are for the user
4 Main Components
Communicating via specific interfaces
- Inter-process - between
- Intra-process - within
- Bound at runtime
- Each with a specific life cycle
- Dynamically loaded and unloaded as necessary
- Activities
- UI components
- Services
- Mechanism for doing something long-running in the background (front-end / back-end)
- Broadcast Receivers
- Respond to broadcast messages from the OS / other apps
- Content Providers
- Make data available for use by other apps



