Android OS - Basic Overview

 

Structure of Android OS 

Android operating system consist of several layers, which are staring from bottom to top

Linux Kernel

  • Core Component that manages hardware and system resources
  • Acts as an interface between Android OS and the device hardware
  • Handles threading, memory management, process management, hardware drivers, networking, and security. Includes drivers for components such as:

  1. Camera
  2. Audio
  3. Keypad
  4. Bluetooth

Hardware Abstraction Layer (HAL)

  • Exposes hardware capabilities (e.g., Bluetooth, Camera) to the Android API through standard interfaces.
  • Applications interact with the hardware via the Android API, which communicates with system services.
  • System services bridge the gap between the Android API and HAL.
  • HAL is implemented as shared libraries, which are loaded by system processes when needed.
  • HAL interacts with Linux drivers to facilitate communication between software and hardware.
  • When a device component is required, the Android API calls the appropriate HAL interface, which loads the necessary library to enable communication with the hardware.

Android Runtime (ART)

  • The environment used to run applications.
  • Each app runs in its own process.
  • Designed based on the Java Virtual Machine (JVM) to operate in a shared environment with limited battery, CPU, and memory.
  • Reads .dex files (Dalvik Executable format).

Native C/C++ Libraries

  • Android includes several native libraries written in C/C++, which provide core functionalities such as graphics, rendering, media playback
  • These libraries interact with the ART and the Linux Kernel to support app execution
  • C/C++ code runs faster and on multiple architectures
  • Used to build core Android components such as ART and HAL.
  • Their functionalities are exposed through the Java Framework API.

Java API Framework

  • A set of APIs (classes, interfaces) written in Java that expose Android features.
  • Several packages starting with "android.", such as android.view, etc
  • Acts as a bridge between the apps and the lower level system components
  • Key services and components:
    • View System: Builds the UI.
    • Managers: Notification, Activity, Content, and Resource (strings, graphics, layers, etc.).
    • Content Providers: Share data with other apps.

System Apps

  • Pre-installed apps like Email, Calendar, and Camera.
  • Third-party apps can invoke them to reuse functionality.
  • Can be replaced with custom apps.

Android Libraries

Libraries designed for multiple Android apps, useful for:

  • Multiple apps needing the same components.
  • Different APK variations (e.g., free vs. paid versions) sharing core components.
  • They follow the same structure as an Android app module, including a manifest, resources, and source code.

Main Libraries:

  • android.view - Includes UI components such as TextView and ImageView.
  • android.widget - Includes interactive components such as Button and Spinner.

Android Libraries

  • Designed to be used by multiple Android apps. 
  • Example:  multiple apps needing the same components, multiple APK variations of the same app - paid and free needing the same core components. 
  • Has the same structure as Android app module - manifest, resources, source code. 

Components of Android Application

Activities

  • Each screen extends the Activity class.
  • Composed of multiple views grouped in a layout.

Services 

  • Runs in background without a UI
  • Performs continuous processing tasks

Content Providers: 

  • Share data between different parts of an app or across different apps.
  • Store data in databases, files, etc.
  • Used by Android for contacts, call logs, etc.

Intents

  • Send messages across the Android system.
  • Used to start activities, services, etc.
  • Android determines the appropriate target for execution based on the content

Broadcast Receivers

  •  receive messages from intents 

Views

  • Objects drawn on the screen.
  • Parents of all UI components

Widgets

  • UI components such as ButtonAppBar, and Bottom Navigation.
  • Rounded corners introduced in Android 12.

Notifications  

  • Appear in the status bar.
  • Display popup-style messages.

App Life cycle 

onCreate → onStart → onResume → onPause → onStop → onDestroy

Types of Android Processes

Android assigns priority to processes and can kill process to free resources based on its priority. Types of processes starting with highest priority

Android assigns priorities to processes and can kill them to free up resources based on priority:

Foreground Process

  • Visible and active.
  • Very few exist; killed only as a last resort.

Visible Process

  • Visible but inactive (e.g., partially obscured by another app).
  • Killed only in extreme cases.

Service Process

  • Runs in the background but performs foreground tasks.
  • Killed only if resources are needed.

Background Process

  • Not visible but has pending services.
  • Killed on a last-seen, first-killed basis.

Empty Process:

  • No active components; kept in memory to improve app startup time.

  • Routinely killed to free resources.

Android SDK (Software Development Kit)

Components

  • Android SDK Tools: Development and debugging tools.
    • AVD
    • SDK Manager
    • Lint
    • Logical
    • Proguard
  • SDK Build Tools: Required to build app code; runs continuously in the background. Help with compiling and packaging Android apps

Android Studio

  • Google's official IDE for Android app development.
  • Based on IntelliJ IDEA.
  • Uses the Android SDK.
  • Prerequisites: Java JDK and JRE.

Considerations When Creating a New Project

  • Target a newer Android OS to utilize new features, but avoid the latest version to ensure compatibility with most devices.

Components

  1. Navigation bar 
  2. Toolbar - running app, launching tools
  3. Editor Window
  4. Tool Windows - specific tasks such as project management
  5. Tool window bar
  6. Status Bar

Emulator Toolbar Options

  1. Power Up
  2. Sound up/down
  3. Rotate
  4. Zoom
  5. Screenshot
  6. Home
  7. Back
  8. Overview
  9. More options

Running Android Apps

Requirements:

  • Intel x86 Emulator Accelerator (for running Intel-based PC) to improve performance
  • Phone Emulator: Android Virtual Device (AVD)
  • USB Cable: Must support both power and data transfer for physical device testing.
  • Instant Run and Apply Changes for quick testing.
  • AVD Manager: Requires BIOS virtualization to be enabled.

Android Studio Gradle

  • Build automation tool.
  • Uses build scripts written in Groovy or Kotlin DSL.
  • Manages the build, run, test, and packaging of applications.





Comments

Popular posts from this blog

Maps - Overview

Android UI - Review Questions