π Lecture 31 β Windows Phone Harmony
π Overview: This lecture explores the multitasking architecture of Windows Phone, focusing on how the system monitors resource usage, aligns with system and user activity, and balances foreground and background processing. It explains the end-to-end architecture for background agents, their functionality, and how they enable efficient multitasking while preserving phone health.
ποΈ Topics Covered
The lecture covers Windows Phone multitasking and phone health principles including resource monitoring, foreground-background balance, and processing on demand. It presents the end-to-end architecture of background agents, detailing their functionality and additional features such as periodic and on-idle agents, mutex synchronization, and user control.
π Lecture Summary
Multitasking and Phone Health
The system monitors resource usage to ensure efficient operation. It aligns processing with system and user activity patterns. The architecture balances foreground and background tasks intelligently. Processing occurs on demand rather than continuously. New OS services support this multitasking paradigm.
π‘ Why this matters: This multitasking approach ensures that background processes do not degrade phone performance or battery life while still enabling necessary background functionality.
End to End Architecture
The lecture presents an end-to-end architecture diagram showing how background agents are integrated into the Windows Phone system. This architecture supports seamless integration between foreground applications and background processing tasks.
Background Agent Functionality
Background agents provide specific functionality that runs when the phone is not actively in use by the user. These agents are designed to perform tasks without interfering with the foreground user experience.
Additional Functionality
Generic Background Agents
- Agents come in two types: β Periodic agents that run at regular intervals β On Idle agents that run when the phone is idle β May have one or both capabilities
- Initialized in foreground, run in background β Agents are set up while the app is active but execute when the app is not in focus
- Persisted across reboots β Agents survive phone restarts without needing reinitialization
- User control through CPL β Users can manage agents through the Control Panel
- Up to a maximum of 18 periodic agents β System enforces this limit to maintain performance
- Synchronize with foreground through mutex β Ensures data consistency between foreground and background processes
- Agent runs for up to 14 days (can be renewed) β Agents have a built-in expiration mechanism to prevent runaway processes
π Definition β Periodic Agent: A type of background agent that runs at scheduled regular intervals to perform tasks.
π Definition β On Idle Agent: A type of background agent that executes when the phone detects it is not being actively used.
π Definition β Mutex: A synchronization primitive that prevents concurrent access to shared resources between foreground and background processes.
π Formula: Maximum periodic agents = 18 β The system limits the number of active periodic background agents to 18 to maintain performance and battery life.
π Example: A music application initializes a periodic background agent when the user opens the app. The agent is configured to check for new podcasts every hour. The agent persists across phone reboots, and the user can disable it through the Control Panel. The agent runs for 14 days, after which it must be renewed by the user opening the app again. If the user has 18 other periodic agents already running, the system will not allow this new agent to be added.
β Key Takeaways
The Windows Phone multitasking model prioritizes phone health by monitoring resource usage and balancing foreground and background processing on demand. Background agents are the primary mechanism for background tasks, coming in periodic and on-idle varieties. These agents are initialized in the foreground but run in the background, persist across reboots, and are user-controllable through the Control Panel. The system enforces a strict limit of 18 periodic agents and a 14-day maximum runtime per agent. Mutex synchronization ensures data consistency between foreground and background processes without conflicts.
π§ Quick Revision Questions
- What are the two types of background agents in Windows Phone, and when does each run?
- How does the system ensure data consistency between foreground and background processes?
- What is the maximum number of periodic agents allowed, and why is this limit enforced?
- For how many days can a background agent run before it needs renewal?
- How are background agents persisted, and how can users control them?
π Lecture 32 β Generic Background Agents
π Overview: This lecture covers background processing capabilities in Windows Phone 7, focusing on how applications can perform tasks while not in the foreground. It explores the security model that governs background behavior, including chambers, capabilities, sandboxing, and application deployment, as well as practical mechanisms like background transfers, audio agents, generic agents, and dormant app states.
ποΈ Topics Covered
Background transfers provide a way to keep users from waiting during data operations. The WP7 security model uses chambers, capabilities, and sandboxing to protect the system. Content sharing enables applications to exchange data. Audio agents and generic agents allow background processing for specific scenarios. Dormant apps and graphics composition manage system resources efficiently.
π Lecture Summary
Donβt Keep Users Waiting: Background Transfers
Background transfers allow applications to perform data uploads and downloads without keeping the user waiting. This technique is essential for mobile applications that need to synchronize data or download content while the user interacts with other parts of the app or switches to another application. The system manages these transfers efficiently to maintain responsiveness and battery life.
π‘ Why this matters: Without background transfers, users would experience frozen interfaces during data operations, making the application feel unresponsive and poorly designed.
Multitasking Cheat Sheet
The multitasking cheat sheet provides a quick reference for how Windows Phone 7 handles multiple applications running simultaneously. It outlines the limitations and capabilities of background tasks, helping developers understand what operations can continue when an application is not in the foreground.
Services and Frameworks
Windows Phone 7 provides specific services and frameworks that enable background processing while maintaining security and performance. These include APIs for background file transfers, location services, audio playback, and periodic background agents.
π Definition β Background Agent: A component that runs periodically in the background to perform specific tasks such as updating live tiles or checking for new data.
WP7 Security Model
The security model is built around protection requirements that prevent malicious applications from accessing system resources or user data without permission. It uses chambers, capabilities, and sandboxing to enforce security boundaries.
π Definition β Security Model: A framework defining how applications access system resources and user data while protecting against unauthorized access.
Chambers
Chambers are isolated execution environments that restrict what an application can do based on its privilege level. There are four chamber types that provide different levels of access to system resources.
π Formula: Chamber Hierarchy β TCB > ERC > SRC > LPC (from highest to lowest privilege)
| Chamber Type | Full Name | Description |
|---|---|---|
| TCB | Trusted Computing Base | Highest privilege level, used by core OS components |
| ERC | Elevated Rights Chamber | For system services requiring elevated access |
| SRC | Standard Rights Chamber | For standard applications with declared capabilities |
| LPC | Least Privileged Chamber | Most restricted, for applications with minimal needs |
π Example: An application that needs access to the phone's camera would run in the SRC and declare the camera capability. An application that only needs network access might run in the LPC with just networking capabilities declared.
Capabilities
Each application must disclose its capabilities to users through multiple channels. Capabilities represent the permissions an application needs to access specific features or data on the phone.
π Definition β Capability: A declared permission that an application needs to access a specific system resource or user data.
Capabilities are disclosed in three ways:
- Marketplace listing: Displayed on the application details page in the Windows Phone Marketplace
- Purchase prompt: Explicit prompt upon application purchase for capabilities with legal requirements for explicit disclosure and consent collection
- In-app disclosure: Shown within the application when the user is about to use the location capability for the first time
π Example: When a user downloads a mapping application from the Marketplace, they see "This app needs access to your location" on the app details page. During purchase, they see another prompt. When they first use the map feature, a third prompt appears asking "Allow [App Name] to use your location?"
Sandbox
The sandbox is an isolated environment that restricts what applications can do. Every application on Windows Phone 7 runs in its own isolated chamber, defined by the capabilities it declares.
π Definition β Sandbox: An isolated execution environment that prevents applications from accessing resources or data outside their declared capabilities.
Key characteristics:
- Each application runs in its own isolated chamber
- Applications are defined by their declared capabilities
- Third-party applications distributed via the Marketplace cannot remain active in the background
π‘ Why this matters: This sandbox model prevents malicious applications from accessing other apps' data or system resources, but it also limits background processing capabilities for most applications.
Application Deployment
Application deployment follows strict security procedures to ensure only trusted applications can be installed on Windows Phone.
Key deployment requirements:
- Developer registration: Developers must register with Microsoft before submitting applications to the Marketplace Hub
- Code signing: All applications are code-signed by VeriSign to verify authenticity
- Managed code only: The development model uses "managed code only" which provides additional security protections
π Formula: Security Protection = Least Privilege + Application Isolation + Managed Code + Code Signing
π Example: A developer wants to publish a weather app. They must register with Microsoft, develop it using managed code (like C#), ensure minimal capabilities are declared, and have VeriSign sign the application package before it appears in the Marketplace.
Apps, Contents and Isolation
Applications and their contents remain isolated from each other. Each application has its own storage area that other applications cannot access, protecting user data and preventing interference between applications.
Content Sharing for Applications
Content sharing enables applications to exchange data with each other through controlled mechanisms. While applications are isolated, specific APIs allow sharing of content like images, contacts, or files when the user initiates the sharing action.
Getting More Out of the Phone: Audio Agents
Audio agents allow applications to play audio in the background. This is one of the limited background capabilities available to third-party applications, enabling music players, podcasts, and other audio applications to continue playing when the user switches to another app.
Getting More Out of the Phone: Generic Agents
Generic agents are periodic background agents that can run for a limited time to perform specific tasks. These agents run on a schedule determined by the system and have strict time and resource limits to prevent battery drain and performance issues.
π Definition β Generic Agent: A background component that runs periodically to perform tasks like updating live tiles, checking for new data, or synchronizing content.
π Example: A news application uses a generic agent to check for new articles every hour. The agent runs for up to 15 seconds, updates the live tile with the latest headline, and then terminates.
Donβt Keep Users Waiting: Dormant Apps
Dormant apps are applications that have been suspended but remain in memory. When the user returns to a dormant app, it can resume quickly without a full restart. This provides a fast user experience while conserving resources.
π Definition β Dormant App: An application that is suspended in memory and can be quickly resumed when the user returns to it.
π Example: A user opens a weather app, checks the forecast, then switches to check email. The weather app becomes dormant. When they tap the weather app icon again, it resumes instantly showing the same data without reloading.
Graphics Composition
Graphics composition is the process of combining visual elements from multiple applications on the screen. The system manages how different UI elements from foreground apps, background apps, and system components are layered and displayed together efficiently.
β Key Takeaways
Chambers provide four levels of isolation (TCB, ERC, SRC, LPC) with different privilege levels for applications. Capabilities must be disclosed through three channels: Marketplace listing, purchase prompt, and in-app disclosure (for location). The sandbox model isolates each application in its own chamber, and third-party apps cannot remain active in the background. Application deployment requires developer registration with Microsoft, VeriSign code signing, and managed code development. Background processing is limited to specific scenarios like audio agents, generic agents (periodic, time-limited), and background transfers, with dormant apps providing fast resume capability.
π§ Quick Revision Questions
- What are the four chamber types in the WP7 security model, and how do their privilege levels compare?
- Through which three channels must applications disclose their capabilities to users?
- Why can't third-party applications distributed through the Marketplace remain active in the background?
- What are the three security requirements for deploying an application in the Windows Phone Marketplace?
- What is the difference between an audio agent and a generic agent in terms of background processing?
π Lecture 33 β Research In Motion
π Overview: This lecture covers Research In Motion (RIM), the company behind the BlackBerry smartphone, its market growth, development model, application ecosystem, and operating system architecture. It is significant for understanding how a pioneering mobile platform achieved cultural and commercial success through push email and enterprise integration.
ποΈ Topics Covered
The lecture begins with an introduction to Research In Motion and the BlackBerry, its historical roots in pager technology, and wireless email innovation. It then discusses market share statistics and growth rates, the Java ME-based development model with RIM APIs, the application store ecosystem, and the proprietary BlackBerry OS architecture with emphasis on the MIDP wrapper and MDS applications.
π Lecture Summary
Research In Motion
BlackBerry and its OS are produced by Research In Motion (RIM), recognized as the cultural icon of the office environment and workforce. RIM is Ontario-based, founded in 1984 by Mike Lazaridis. It entered the wireless market by making pagers, such as the inter@active (RIM-900) for Ericsson, and enabled wireless email on GSM and CDMA networks. RIM released the BlackBerry in 2002.
π‘ Why this matters: The BlackBerry's origin in pager technology shaped its focus on reliable, real-time messaging, which became its key differentiator.
Market Share
Actual handset shipment numbers placed BlackBerry closer to 16% market share, with yearly growth of 80% in 2007-08. RIM also offered its push email services to other platforms including Symbian, Windows Mobile, and Palm OS. The company added 1.2 million new users in Q4 2007, and by 2008 the US user base had reached 12 million users. The consumer BlackBerry Internet Service was available in 91 countries worldwide on over 500 mobile service operators using various mobile technologies.
Development Model
BlackBerry applications are written using Java ME. RIM provides a JDE (Java Development Environment) and an Eclipse plug-in. It uses the Mobile Information Device Profile (MIDP), which defines a common interface for low-level features on mobile devices. Users can download and run any application, but code signing is needed for certain functionsβthough it does not guarantee correct code.
π Definition β MIDP (Mobile Information Device Profile): A specification that defines a common interface for low-level features on mobile devices, enabling Java ME applications to run across different handsets.
π Definition β Code signing: A security mechanism required for certain BlackBerry functions; it authenticates the developer but does not verify the correctness of the code.
Applications
Many popular apps are available for BlackBerry. Users can obtain applications through the web, desktop connect, or the device's IM homepage. In October 2008, RIM announced their own Application Store built directly into the BlackBerry, competing with Apple and Google's app stores. The store offers both free and paid applications.
π Definition β RIM Application Store: A marketplace for BlackBerry applications, announced in October 2008, integrated into the device to compete with Apple's App Store and Google's Android Market.
OS Architecture
The BlackBerry OS is proprietary, with no significant information publicly available. Hardware access is achieved through a RIM-developed JVM (Java Virtual Machine) via two types of applications: standard Java ME applications and MDS (Mobile Data System) applications. Legacy devices supported C++, but no longer do. RIM focuses on building cross-platform functionality with Symbian OS, Windows Mobile, and Desktop Connect. This suggests nothing specific about the underlying OS, with the main focus on the RIM API that wraps MIDP.
π Definition β MDS (Mobile Data System): A RIM-developed framework that provides additional APIs for Java ME applications to access network and device features beyond standard MIDP.
π Example: A BlackBerry developer writing a push email client would use the RIM API wrapping MIDP, perhaps utilizing MDS APIs for network access, while the underlying proprietary OS remains hidden from the developer. This allows the app to run across different BlackBerry devices without modification.
β Key Takeaways
The most critical points for exam preparation are: BlackBerry was developed by Research In Motion (RIM), founded in 1984, and evolved from pagers to smartphones with pioneering wireless email on GSM/CDMA. The platform achieved 80% annual growth in 2007-08 and a 16% market share, with push email services extended to other mobile OSes. Applications are developed using Java ME with MIDP, using RIM's JDE or Eclipse plug-in, and require code signing for privileged functions. RIM launched its own Application Store in October 2008 to compete with Apple and Google. The BlackBerry OS is proprietary and undocumented, exposing hardware through a RIM JVM that supports standard Java ME and MDS applications, with the RIM API wrapping MIDP.
π§ Quick Revision Questions
- What company produces the BlackBerry and its operating system?
- How did RIM's initial product line (pagers) influence the BlackBerry's core feature?
- What was the approximate market share and yearly growth rate of BlackBerry in 2007-08?
- What development environment and Java specification are used for BlackBerry applications?
- Why is code signing required for certain BlackBerry functions, and what does it not guarantee?
π Lecture 34 β Development Model
π Overview: This lecture explores the BlackBerry mobile platform's development model, architecture, and security framework, then transitions to cover the iPhone platform's history, development tools, and application structure. Understanding these two contrasting approaches to mobile development is essential for comprehending how different platforms solved the challenges of mobile application creation and deployment.
ποΈ Topics Covered
This lecture covers the BlackBerry development model using Java ME with RIM's JDE and Eclipse plug-in, the proprietary BlackBerry OS architecture, network architecture connecting through RIM's central NOC to BES servers, MDS (Mobile Data Services) for web and enterprise applications, application structure with .cod and .alx files, OTA deployment methods, security model with sensitive APIs, and code signing. The lecture then transitions to iPhone history from 1976 Apple founding through iPhone 3G launch, market share data, iPhone development model with SDK and developer program, development tools including Xcode and Interface Builder, Objective-C language features, application framework based on Darwin and XNU kernel, Mach-O binary format, iPhone runtime model with sandboxing, application structure with bundles, MVC design pattern, and memory management using reference counting.
π Lecture Summary
Development Model
BlackBerry applications are written using Java ME. RIM provides a Java Development Environment (JDE) and an Eclipse plug-in for development. The Mobile Information Device Profile (MIDP) defines a common interface for low-level features on mobile devices. Users can download and run any application, but code signing is needed for certain functions, though it does not guarantee correct code.
OS Architecture
The BlackBerry OS is proprietary, with no significant information publicly available. Hardware access occurs through a RIM-developed JVM via standard JavaME applications and MDS (Mobile Data System) applications. Legacy devices supported C++, but this is no longer the case. RIM focused on building cross-platform functionality with Symbian-OS, Windows Mobile, and Desktop Connect. The architecture suggests nothing specific about the underlying OS, focusing mainly on the RIM API that wraps MIDP.
Network Architecture
All BlackBerry devices connect to RIM's central NOC (Network Operations Center) through a carrier. The NOC connects to all BES (BlackBerry Enterprise Server) systems on site. BES can attach to additional middleware services for expanded functionality.
π‘ Why this matters: This centralized architecture through NOC is what made BlackBerry's push email and enterprise connectivity so reliable and secure, as all data traffic is routed and managed through RIM's infrastructure.
MDS (Mobile Data Services)
MDS focuses mainly on web and enterprise services. It serves as a runtime container for processing pushed data, making it ideal for Rapid Application Development with minimal coding required, sometimes none. BlackBerry enterprise servers perform all the data processing and management, including WSDL and Database operations. The backend can be arbitrarily complex.
Application Structure
JavaME applications like MIDlets contain .jar and .jad files. These are converted to proprietary .cod files for BlackBerry, which are compiled code that is optionally signed and preverified. The Rapc tool converts .jar/.jad files to .cod files. .alx files are used to load applications via the BlackBerry Desktop Manager software and are XML-based BlackBerry application descriptors.
Over the Air (OTA) Deployment
Standard MIDlets and .cod files can be obtained over the air (OTA). The provider puts both a .jad file and either a .cod or a .jar file. Users select the .jad file from a browser. The MDS server provides a built-in transcoder that converts .jar files into .cod files during deployment.
MDS Applications
MDS applications are the simplest to develop on the client side, though they can be arbitrarily complex on the server end. They are considered "Browser Based," essentially laying out HTML forms where all data is received in expected form. These can be developed into browse-able pages using cHTML. The MDS Server defines a WSDL or SQL-DB Schema, and MDS uses standard wrappers to call these accessors. MDS apps use compression and encryption features to securely send data through cell carriers.
Security Model in Brief
The BlackBerry security model includes class files being verified for interface compliance, a limited API set (CLDC), downloading and management within the JVM, no user-defined class loaders, no Java Native Interface or user extensions, and system classes cannot be overridden.
Sensitive APIs
Use of the BlackBerry and RIM API is restricted, tracked for security and export reasons, and not available in the simulator. The JVM checks for valid code signatures. Developers send code hashes to a webservice and receive a RIM-signed signature. Verification occurs at both link time and runtime.
π Definition β Code Signing: A security mechanism where developers submit code hashes to RIM to receive a signed signature that is verified by the JVM at link time and runtime before sensitive APIs can be accessed.
Company History
Apple Computer, Inc. was founded on April 1, 1976 with the Apple I. Products included Apple II, Apple III, and Lisa. In 1984, the Macintosh introduced the mouse and GUI, establishing Apple's "ease of use" philosophy. In 1998, the iMac was designed by Jony Ive, who also designed the iPod and iPhone.
iPhone History
In 1999, Apple began registering trademarks and domain names including iPhone.org. In 2004, Apple and Motorola worked on a phone with iTunes. September 7, 2005 saw the release of the ROKR. On January 9, 2007, the iPhone was announced, and Apple Computer, Inc. became Apple, Inc. The iPhone launched June 29, 2007. On March 6, 2008, the SDK was released; before that, only web applications were available. July 11, 2008 brought the iPhone 3G and the AppStore.
Market Share and Predictions
iPhone had 12.9% market share in Q3 2008, up from 3.4% one year earlier, ranking 3rd after Symbian (49.8%) and RIM (15.9%). In Q4 2008, 6.9 million units were sold, compared to 1.1 million one year earlier. Predictions estimated 45 million total in 2009. By the end of fiscal year 2010, 73.5 million iPhones were sold total. By 2010/2011, the iPhone had barely 4% market share of all cellphones, but Apple still pulled in more than 50% of the total profit from global cellphone sales.
Development Model
A free (with registration) SDK is available, requiring an Intel-based Mac. The SDK allows code development and testing, including a simulator for the iPhone. However, loading code onto an actual iPhone requires joining the iPhone Developer Program.
iPhone Developers Program
The iPhone Developer Program allows developers to load applications on the iPhone and publish applications in the AppStore. Developers set the price, which can be free, with a minimum price of $0.99 and maximum price of $999. Apple takes 30% of application cost for each copy sold. Three different "levels" exist for the developer program.
Development Tools
The SDK is based around Xcode, which is used to develop Mac OS X, iPhone OS, and Apple applications. Other included utilities are Instruments for real-time code profiling, Dashcode for rapid development of widgets and web apps for iPhone, Simulator for testing, and Interface Builder for drag-and-drop interface creation.
iPhone Applications
iPhone applications are written in Objective-C, a superset of C. It is described as "another object-oriented C-like language" with SmallTalk influence, where "messages" are sent to objects following an event-driven model. Even though the SDK is available, Apple does not release all API information; things like CoverFlow and certain hardware APIs are not published.
Applications
The AppStore provides over 20,000 different applications requiring Apple approval to be published. A wide variety of applications are available, from games and social networking to finance and business.
Application Framework
The OS Architecture is based on Darwin, which is open source with a BSD-like system maintained by Apple and the community. Three different "variants" exist: PowerPC and Intel x86 for Mac OS X (released as open source), and ARM for iPhone OS (not released).
Darwin
The Darwin kernel is XNU, a hybrid kernel based on the Mach 3 microkernel and various FreeBSD components. It features an object-oriented device driver framework/API called I/O Kit. The binary format is Mach-O, similar to ELF, a.out, EXE, and COM formats.
π Definition β Mach-O: A binary format that can contain binary code for multiple CPU architectures, known as a "Universal Binary," enabling seamless transition between architectures.
Mach-O
A Mach-O file can contain binary code for multiple CPU architectures, for example, 32-bit (G4) and 64-bit (G5) PowerPC along with Intel x86. This is known as a "Universal Binary" enabling seamless transition between architectures. Rosetta was used during the PowerPC to Intel switch for compatibility.
iPhone Runtime
The iPhone runtime model differs from PCs with short ("bursty") usage and a single foreground application. Currently no "background" processes are allowed for 3rd party app developers. Apple has released guidelines on writing applications that fit this usage model. The app is notified of pending termination and advised to save state. Applications are sandboxed, running in their own virtual address space. No swapping is done; instead, an event is sent to the app to notify it to free some memory. If more memory is still needed, the application can be killed by the OS.
π‘ Why this matters: The sandboxing and single-foreground-app model prioritizes security and battery life over multitasking, which was a deliberate design choice for the iPhone that shaped how all iOS apps behave.
Application Structure
iPhone applications are distributed in a bundle containing an executable file, png files, .nib files, Info.plist, and .lproj files for localization.
Application Lifecycle
Applications are based on event handling for their lifecycle management.
MVC Design Pattern
The MVC (Model-View-Controller) design pattern separates an application into three components: View for the user interface, Model for the engine/data, and Controller as the link between the two.
Objective-C
Objective-C is an object-oriented superset of C, different from C++. It includes some nice features like automatic generation of setters and getters according to properties. It has some difficulties related to the message-passing system.
Memory Management
The iPhone has no garbage collector. Instead, it uses reference counting with methods including Alloc, Release, Retain, Autorelease, and copy.
π Formula: Reference Counting β Objects track how many references point to them; when the count reaches zero, the object is deallocated
π Example: When a developer creates an object using alloc, its reference count becomes 1. Each retain call increments the count, and each release call decrements it. When the count reaches 0, the object is automatically deallocated. autorelease defers the release to a later point, while copy creates a new object with a reference count of 1.
β Key Takeaways
This lecture contrasts two major mobile platforms: BlackBerry's Java ME-based development with centralized NOC/BES architecture, MDS services, and code signing security, versus Apple's iPhone with Objective-C development, Xcode tools, Mach-O universal binaries, sandboxed runtime with no background processes, MVC design pattern, and reference-counted memory management. The critical distinctions include BlackBerry's enterprise-focused proprietary OS with OTA deployment of .cod files compared to iPhone's consumer-focused AppStore model with Apple approval and revenue sharing. Both platforms emphasize security differently: BlackBerry through code signing and JVM verification, while iPhone uses sandboxing and restricted API access. Understanding the iPhone's market disruptionβfrom 3.4% to 12.9% market share in one year and 50% of industry profit with only 4% market shareβhighlights the platform's disproportionate financial success. The architectural differences in runtime behavior (bursty usage vs. constant connectivity), memory management (reference counting vs. no garbage collection), and development models (MIDP/Java ME vs. Objective-C/SDK) represent fundamental design decisions that shaped modern mobile computing.
π§ Quick Revision Questions
- What are the three main application types for BlackBerry development, and how do they differ in complexity between client and server sides?
- Explain the purpose of the NOC (Network Operations Center) in BlackBerry's network architecture and how it connects to BES servers.
- What is a "Universal Binary" in Mach-O format, and how does it enable multi-architecture support?
- Describe the iPhone runtime model's memory management approach: why is there no garbage collector, and how does reference counting work?
- Compare the BlackBerry code signing process with the iPhone's AppStore approval modelβwhat security mechanisms does each platform employ?
π Lecture 35 β Frameworks and APIs
π Overview: This lecture explores the architectural layers and frameworks of iPhone OS (iOS), including its core system layers, media frameworks, and the Cocoa Touch UI layer. It also covers system protection mechanisms like sandboxing and code signing, the controversial topics of jailbreaking and SIM unlocking, and provides a comprehensive introduction to the Android development framework, including the Dalvik Virtual Machine and SDK setup.
ποΈ Topics Covered
The lecture covers the iPhone OS layered architecture (Core OS, Cross Layer Services, Media, Cocoa Touch), undocumented APIs, system protection through sandboxing and code signing, jailbreaking and its vulnerabilities, SIM unlocking, the Android development framework with Dalvik VM, Android SDK components, development environment setup, creating an Android Virtual Device (AVD), and building the first Android application.
π Lecture Summary
iPhone OS based on a layered architecture
The iPhone OS is structured with four basic layers: Core OS Layer, Cross Layer Services, Media Layer, and Cocoa Touch Layer. Each layer provides specific functionalities and APIs for application development.
Core OS Layer
This foundational layer contains three basic frameworks:
- CFNetwork β APIs related to networking including sockets, FTP, HTTP, and Bonjour.
- Security β Handles certificate management, random number generation, and crypto-related functions.
- System β Provides BSD and POSIX related functions.
π Definition β CFNetwork: A framework providing low-level networking APIs for sockets, FTP, HTTP, and Bonjour services.
Cross Layer Services
These services operate across multiple layers and include:
- Address Book β Contact information used by SMS and Phone applications.
- Core Foundation β Access to basic data structures like strings and other basic system functions.
- Core Location β Location-based information providing GPS access.
- Foundation β Base for all Objective-C objects including root NSObject class, NSString, and NSArray.
- System Configuration β Manages system configuration settings.
π Definition β Core Foundation: A framework providing access to fundamental data structures and system functions, forming the base for Objective-C object management.
Media Layer
Includes multiple frameworks for multimedia handling: Audio Toolbox, Audio Unit, AV Foundation, Core Audio, Core Graphics, Media Player, OpenGL ES, and Quartz Core.
π‘ Why this matters: The Media Layer provides all the audio, video, and graphics rendering capabilities essential for creating rich multimedia applications on iOS.
Cocoa Touch Layer
This top layer provides user interface components:
- Address Book UI β User interface for the Address Book.
- UIKit β Contains all user interface components for building iOS applications.
Undocumented APIs
Not all APIs are documented. Examples include CoverFlow and hardware APIs like the proximity sensor. Using undocumented APIs is a reason for application rejection from the AppStore. However, Google uses such APIs in their voice search application and was accepted into the AppStore. Notably, Eric Schmidt (CEO, Google) sat on Appleβs board of directors during this time.
π Definition β Undocumented APIs: Private or non-public APIs that developers are not officially allowed to use, with usage risking AppStore rejection.
System Protection
iOS employs multiple protection mechanisms:
- Sandboxed applications β Each app runs in its own sandboxed environment.
- Code signing β Applications must be signed by Apple. Developerβs certificates are signed with Appleβs root certificate for development and testing. Code is reviewed by Apple before publication in the App Store. The review process is a mystery but seems thorough. Jailbreaking circumvents this protection.
π Definition β Sandboxing: A security mechanism where each application runs in an isolated environment, preventing access to other apps' data or system resources.
JailBreaking
Two firmwares can be modified with different results:
- Application processor firmware modification β Allows unsigned code to run (applications from outside the AppStore). This is actual jailbreaking.
- Baseband processor firmware modification β Allows carriers other than the intended one. This is SIM unlocking.
Similar to other OSes, the iPhone OS loads in stages:
- Boot ROM loads the LLB (Low-Level Bootloader)
- LLB loads the Firmware
- At each stage, signature checks perform validation
In theory, signature checks occur at every stage, but the boot ROM does not perform a signature check on the LLB β a security flaw. More recently, the LLB is subject to a buffer overflow vulnerability that allows unsigned code to be loaded, overriding the signature checks of all subsequent stages.
π Definition β Jailbreaking: The process of modifying the application processor firmware to allow unsigned code to run on iOS devices, circumventing Apple's security measures.
π Example: The boot ROM does not verify LLB signatures, creating a vulnerability where unsigned code can be loaded early in the boot process, bypassing all later security checks.
SIM Unlocking
Jailbreaking is only half the battle. Users remain tied to a specific carrier. Furthermore, jailbreaking can lead to more vulnerabilities.
π Definition β SIM Unlocking: Modifying the baseband processor firmware to allow the device to work with carriers other than the intended one.
Android Development Framework
Android applications are written with Java as the programming language but executed by a custom virtual machine called Dalvik rather than a traditional Java VM. Each Android application runs in a separate process within its own Dalvik instance, relinquishing all responsibility for memory and process management to the Android run time, which stops and kills processes as necessary to manage resources. Dalvik and the Android run time sit on top of a Linux kernel that handles low-level hardware interaction, including drivers and memory management, while a set of APIs provides access to all the underlying services, features, and hardware.
π Definition β Dalvik Virtual Machine: The custom virtual machine used by Android to execute Java applications, optimized for mobile devices with limited resources.
Dalvik Virtual Machine
One of the key elements of Android is the Dalvik virtual machine. The Dalvik VM uses the deviceβs underlying Linux kernel to handle low-level functionality including security, threading, and process and memory management. Itβs also possible to write C/C++ applications that run directly on the underlying Linux OS.
Android Software Development Kit (SDK)
The Android SDK includes everything needed to start developing, testing, and debugging Android applications:
- The Android APIs
- Development Tools
- Android Virtual Device Manager and Emulator
- Full Documentation
- Sample Code
π Definition β Android SDK: A comprehensive software development kit providing APIs, tools, emulators, documentation, and sample code for building Android applications.
Application Development Environment
Required components:
- Android SDK
- The Java development kit
- IDE of Choice β Eclipse
- Versions of the SDK, Java, and Eclipse are available for Windows, MacOS, and Linux
Setting Up the Environment
Steps to set up:
- Download Eclipse
- Download ADT from https://dl-ssl.google.com/android/eclipse/
Create an AVD
An Android Virtual Device can be configured with various parameters:
- Maximum virtual machine heap size
- Screen pixel density
- SD Card support
- The existence of DPad, touchscreen, keyboard, and trackball hardware
- Accelerometer and GPS support
- Available device memory
- Camera hardware (and resolution)
π Definition β Android Virtual Device (AVD): A virtual device configuration used with the Android emulator to simulate specific hardware configurations for testing applications.
Emulator
The Android emulator allows developers to run and test applications on virtual devices without physical hardware.
Creating First Android Application
The lecture concludes by showing the initial steps for creating the first Android application using the configured development environment.
β Key Takeaways
The iPhone OS architecture consists of four layers (Core OS, Cross Layer Services, Media, Cocoa Touch) with specific frameworks like CFNetwork and UIKit. System protection through sandboxing and code signing creates a secure but restrictive environment, leading to jailbreaking that exploits boot chain vulnerabilities like the missing LLB signature check. Android differs fundamentally by using the Dalvik VM on top of a Linux kernel, with each app running in its own process and memory managed by the runtime. Setting up Android development requires the SDK, JDK, and Eclipse IDE with ADT plugin, allowing creation of AVDs with configurable hardware parameters. Understanding these frameworks and APIs is essential for developing applications on both iOS and Android platforms.
π§ Quick Revision Questions
- What are the four basic layers of the iPhone OS architecture?
- Why does the boot ROM's failure to check the LLB signature create a security vulnerability?
- What is the difference between jailbreaking and SIM unlocking?
- How does the Dalvik Virtual Machine differ from a traditional Java Virtual Machine in Android?
- What components are needed to set up an Android development environment, and what is the purpose of an AVD?