π Lecture 23 β Mobile & Pervasive Computing
π Overview: This lecture continues the exploration of Windows Phone 7 operating system architecture, focusing on version history updates, the structural building blocks of the OS, and the file system organization that supports system and user data management. Understanding this structure is critical for mobile application developers and system architects.
ποΈ Topics Covered
The lecture covers the version history of Windows Phone 7, including key updates like "NoDo" and "Mango". It then explains the structure of the operating system at the building level, detailing how different layers interact. Finally, it describes the file system architecture, specifically IMGFS, TexFAT, and the Microsoft Unified Storage System for user data.
π Lecture Summary
Version History
Windows Phone 7 underwent several version updates during its lifecycle. The original RTM (Release to Manufacturing) version was 7.0.7004.0. An intermediate test update, 7.0.7008.0, contained no functionality changes. New phones shipped with version 7.0.7389.0, which included all features of OS version 7.0.7390.0. The "NoDo" update (7.0.7390.0) introduced copy/paste functionality, performance improvements, and market search enhancements. The major "Mango" update added third-party multitasking, Internet Explorer 9 (IE9), and Twitter integration, among other features.
π‘ Why this matters: Knowing the version history helps developers understand which API features are available on different devices and why certain updates were critical for the ecosystem's evolution.
Structure of the OS β Building
The lecture presents structural diagrams showing how the Windows Phone 7 operating system is built. The OS architecture includes multiple layers:
- Hardware at the bottom
- Kernel layer above hardware
- Core System Services including:
- Graphics subsystem
- Media subsystem
- Communication services
- Security services
- Application Framework layer
- Applications at the top
The structure shows that applications interact with the application framework, which in turn uses core system services that communicate with the kernel and hardware. This layered architecture ensures stability, security, and abstraction of hardware details from application developers.
Structure of the OS β File
Windows Phone 7 uses two file systems: IMGFS (Image File System) and TexFAT (Transactional Extended File Allocation Table).
- IMGFS is intended for system files, containing the operating system image.
- TexFAT is an 'extended' version of FAT that can handle files larger than 4GB.
π Definition β TexFAT: A transactional version of the FAT file system that supports files larger than 4GB and provides transaction-based write operations for data integrity.
For user files, the OS employs the Microsoft Unified Storage System. This system ensures that applications and users cannot distinguish between files stored in internal flash memory and files stored on a memory card. The unified storage abstracts the physical storage media, presenting a single logical view of all user data.
π Example: When a user saves a photo on a Windows Phone 7 device, the Microsoft Unified Storage System automatically determines whether to store it in internal flash memory or on an external SD card. The user and applications see only one unified file system location, regardless of the physical storage medium used.
β Key Takeaways
The critical points from Lecture 23 include the version history of Windows Phone 7, with "NoDo" and "Mango" being the most significant updates. The OS uses a layered architecture with hardware, kernel, core services, application framework, and application layers. Two file systems exist: IMGFS for system files and TexFAT for user and large files. The Microsoft Unified Storage System makes internal and external storage indistinguishable to applications and users. Understanding this structure is essential for mobile developers creating apps for the Windows Phone 7 platform.
π§ Quick Revision Questions
- What were the three major version updates for Windows Phone 7 mentioned in the lecture, and which one introduced third-party multitasking?
- Name the two file systems used by Windows Phone 7 and describe their primary purposes.
- What is the function of the Microsoft Unified Storage System in the Windows Phone 7 OS?
- Explain the layered architecture of the Windows Phone 7 OS as shown in the "Structure of the OS β Building" section.
- What file size limitation does TexFAT overcome that standard FAT cannot handle?
π Lecture 24 β Structure of the OS β File
π Overview: This lecture examines the structure of the Windows Phone 7 operating system, focusing on its file system components (IMGFS and TexFAT) and graphics framework. It covers system requirements and update mechanisms for Windows Phone 7, highlighting differences from desktop Windows systems.
ποΈ Topics Covered
This lecture details the two file systems used in Windows Phone 7: IMGFS for system files and TexFAT for user files larger than 4GB, explaining Microsoft Unified Storage System that merges internal flash and memory card storage. It introduces the graphics architecture with direct hardware access for high-performance rendering, lists hardware requirements for Windows Phone 7 devices, and describes the update mechanism used for system patches and new features.
π Lecture Summary
Structure of the OS β File
Windows Phone 7 uses two file systems to manage storage. IMGFS is designed for system files and is not user-accessible. TexFAT is an extended version of the FAT file system that can handle files larger than 4GB, intended for user data. The operating system also employs a Microsoft Unified Storage System, which ensures that applications and users cannot distinguish between files stored in internal flash memory and files on an external memory card.
π Definition β IMGFS: A file system intended for system files only, not user-accessible. π Definition β TexFAT: An extended version of the FAT file system capable of handling files larger than 4GB. π Definition β Microsoft Unified Storage System: A system that makes internal flash memory and memory card storage appear as a single unified storage space to applications and users.
Structure of the OS β Graphics
Windows Phone 7 uses a graphics framework that provides direct hardware access for high-performance rendering. The architecture is designed to support smooth animations and touch interactions, leveraging hardware acceleration to ensure responsive user experiences. This approach differs from desktop Windows, where graphics are more abstracted from hardware.
π‘ Why this matters: Direct hardware access in mobile graphics ensures that user interface interactions (swipes, taps, animations) remain smooth even with limited mobile processor resources.
Windows 7 β Requirements
Windows Phone 7 imposes specific hardware requirements on devices to ensure consistent performance and user experience. These requirements include minimum specifications for processors, memory, screen resolution, and sensor capabilities. The requirements help guarantee that all Windows Phone 7 devices can run applications and the operating system smoothly.
Windows 7 β Updates
Windows Phone 7 uses a update mechanism to deliver system patches, bug fixes, and new features. Updates are delivered over-the-air (OTA) and are managed by carriers before release. The update system is designed to be minimal and focused, as mobile platforms have limited storage and bandwidth compared to desktop systems.
β Key Takeaways
Students must remember that Windows Phone 7 uses two distinct file systemsβIMGFS for system files and TexFAT for large user filesβand the Unified Storage System blends internal and external storage. The graphics architecture provides direct hardware access for performance. Hardware requirements ensure consistency across devices, and updates are delivered OTA with carrier approval. These design choices prioritize reliability and performance in a mobile environment.
π§ Quick Revision Questions
- What are the two file systems used by Windows Phone 7, and what type of files does each handle?
- How does the Microsoft Unified Storage System treat internal flash memory versus a memory card?
- Why does the Windows Phone 7 graphics framework use direct hardware access?
- What is the purpose of hardware requirements for Windows Phone 7 devices?
- How are updates delivered in Windows Phone 7, and who manages their release?
π Lecture 25 β Structure of the OS β Building
π Overview: This lecture examines the software architecture and framework details of operating systems for mobile and pervasive computing, with a specific focus on the structure required for building Windows 7. It explores how applications are hosted and the runtime environment that supports them, emphasizing the architectural layers and requirements for modern OS construction.
ποΈ Topics Covered
The lecture covers the structure of the operating system during the building phase, detailing the software architecture that underpins Windows 7, including its requirements. It further delves into framework details that define the OS structure, and concludes with a discussion on app hosting and runtime mechanisms that enable application execution within the pervasive computing environment.
π Lecture Summary
Structure of the OS β Building
This section introduces the overall concept of constructing an operating system. The building phase involves assembling the core components that form the OS foundation. For Windows 7, specific requirements must be met regarding hardware compatibility, memory management, and system resources to ensure proper operation. The structure defines how different layers interact, from kernel services to user interface components, creating a cohesive platform for application execution.
π Definition β Building Phase: The stage in OS development where the core system components are integrated and configured to meet specified requirements. π Formula: No specific formula provided. π Example: When building Windows 7, the OS requires a minimum of 1GB RAM for 32-bit systems or 2GB for 64-bit systems, with a 1GHz processor and 16GB (32-bit) or 20GB (64-bit) available hard disk space, ensuring the structural components have adequate resources.
π‘ Why this matters: Understanding the building requirements helps developers and system architects design compatible hardware and software for pervasive computing environments.
Software Architecture
The software architecture layer describes the high-level organization of the OS into modular components. Windows 7 architecture follows a layered design, separating user-mode processes from kernel-mode services. This architecture includes the hardware abstraction layer (HAL), kernel, executive services, and subsystems that manage I/O, memory, processes, and security. The architecture ensures stability and security by isolating critical system functions from user applications.
π Definition β Software Architecture: The structural organization of an operating system's components and their interrelationships, defining how different modules communicate and cooperate. π Formula: No specific formula provided. π Example: In Windows 7 architecture, the kernel handles thread scheduling and interrupt handling, while the executive services manage memory management, process management, and I/O management, all built upon the HAL that abstracts hardware differences.
Framework Details
This section provides deeper framework details regarding the specific structures and interfaces that implement the architecture. The framework includes programming interfaces like Windows API, device driver frameworks (WDDM for graphics, KMDF/UMDF for drivers), and the Component Object Model (COM) that enables inter-process communication. These details define how developers create software that runs consistently across different hardware configurations.
π Definition β Framework: A structured set of interfaces, tools, and conventions that provide a foundation for developing and running applications within the operating system. π Formula: No specific formula provided. π Example: Windows 7 uses the Windows Driver Framework (WDF) which includes Kernel-Mode Driver Framework (KMDF) for device drivers running in kernel space and User-Mode Driver Framework (UMDF) for drivers running in user space, providing better stability and isolation.
App Hosting and Run Time
The final section discusses how the OS supports application hosting and provides runtime environments for executing programs. This includes the Windows Runtime (WinRT) for modern apps, the Common Language Runtime (CLR) for .NET applications, and the traditional Win32 API for desktop applications. The OS manages process creation, memory allocation, thread scheduling, and resource access during runtime. It also handles application isolation, security enforcement, and inter-process communication.
π Definition β Runtime Environment: The software layer that provides the necessary services and resources for an application to execute, including memory management, exception handling, and security checks. π Formula: No specific formula provided. π Example: When a user launches a .NET application on Windows 7, the Common Language Runtime (CLR) loads the application code, performs just-in-time compilation, manages garbage collection for memory, and ensures type safety and security through code access security policies.
π‘ Why this matters: Understanding app hosting and runtime mechanisms is crucial for developing reliable software that runs efficiently across different Windows 7 configurations.
β Key Takeaways
Students must remember that building an operating system like Windows 7 involves understanding specific hardware and software requirements that must be met. The software architecture follows a layered design with the HAL, kernel, and executive services working together to provide stability and security. Framework details such as the Windows API and device driver frameworks are essential for creating compatible software. App hosting and runtime environments like WinRT, CLR, and Win32 provide the necessary infrastructure for application execution, with each runtime offering different capabilities and security models. The building phase requires careful integration of these components to create a cohesive and reliable operating system.
π§ Quick Revision Questions
- What are the minimum hardware requirements for building Windows 7 (32-bit version)?
- Name three key components of Windows 7's software architecture.
- What is the purpose of the Hardware Abstraction Layer (HAL) in the OS structure?
- Distinguish between KMDF and UMDF in the Windows Driver Framework.
- How does the Common Language Runtime (CLR) manage memory during application hosting?
π Lecture 26 β App Hosting and Run Time
π Overview: This lecture covers the Windows Phone 7 (WP7) execution model, detailing the various states an application can be in during its lifecycle. It explains how resources are managed during deactivation and activation, which is critical for building responsive and battery-efficient mobile applications.
ποΈ Topics Covered
The lecture explores the WP7 execution model with seven application states: Launch, Running, Closing, Deactivated, Activated, Dormant, and Tombstoned. It then delves into the application life cycle, followed by resource management strategies during deactivation and activation phases, ensuring smooth user experience and efficient system resource usage.
π Lecture Summary
WP7 Execution Model
The Windows Phone 7 execution model defines how applications transition through different states during their lifetime. There are seven key states an application can occupy: Launch, Running, Closing, Deactivated, Activated, Dormant, and Tombstoned. When the user launches an app, it enters the Launch state and then moves to Running. If the user presses the Start button or switches to another app, the current app becomes Deactivated. The system may put the app into a Dormant state (preserving memory) or a Tombstoned state (removing it from memory). When the user returns, the app is Activated. Finally, when the user explicitly closes the app, it enters the Closing state.
π Definition β Deactivated: An application state where the app is no longer visible but may still be kept in memory by the system. π Definition β Dormant: An application state where the app is preserved entirely in memory but is not executing any code. π Definition β Tombstoned: An application state where the app has been removed from memory, but its state information is saved for potential restoration.
π Example: When a user receives a phone call while playing a game, the game becomes Deactivated. If the call is short, the game may remain Dormant in memory; if the call is long and memory is needed, the game becomes Tombstoned. When the call ends and the user returns, the game is Activated from either state.
π‘ Why this matters: Proper handling of these states prevents data loss and provides a seamless user experience when switching between apps.
Application Life Cycle
The application life cycle on Windows Phone 7 follows a specific path: the app starts with Launch β then Running β then either Closing (if user exits) or Deactivated (if user leaves). From Deactivated, the app can go to Dormant (memory preserved) or directly to Tombstoned (memory cleared). When the user returns, the app transitions from Dormant/Tombstoned to Activated, then back to Running. This cycle ensures that the system can reclaim resources when needed while maintaining the ability to restore the app's previous state.
π Formula: Life Cycle Sequence: Launch β Running β (Closing / Deactivated β [Dormant or Tombstoned] β Activated β Running)
π Example: A weather app is Launched β enters Running to show today's forecast β user switches to email β app becomes Deactivated β after 5 minutes, system needs memory β app becomes Tombstoned β user returns to weather app β it is Activated and restores its state.
π‘ Why this matters: Understanding this cycle is essential for saving application state correctly in the Deactivated event to avoid data loss.
Deactivation Resource Management
When an application is Deactivated, the system triggers the Deactivated event. During this event, the application must perform resource management tasks such as saving persistent data, releasing unmanaged resources (e.g., file handles, network connections), and saving the current application state (e.g., scroll position, user input). The goal is to free up system resources and ensure the app can be properly restored later. The system provides limited time for this process, so efficient code is required.
π Definition β Resource Management: The process of releasing system resources (memory, file handles, network connections) when an application transitions to a non-running state.
π Example: In a drawing app, during the Deactivated event, the app saves the current drawing to isolated storage, closes the file stream, and releases the drawing surface memory. This ensures no data is lost and system resources are freed.
π‘ Why this matters: Failing to manage resources during deactivation can lead to data loss and poor system performance when many apps are running.
Activation Resource Management
When an application is Activated (returning from Dormant or Tombstoned state), the system triggers the Activated event. During activation, the application must restore its state from previously saved data, re-establish network connections, reload resources, and reinitialize the user interface to its previous state. If the app was Tombstoned, it must reload its entire state from persistent storage; if it was Dormant, state restoration is faster because memory is still intact.
π Definition β Activation: The process of bringing an application back to the Running state after it was Deactivated, including state restoration.
π Example: A social media app that was Tombstoned during a long phone call, upon Activation, re-reads the saved timeline position and user credentials from isolated storage, reconnects to the network, and displays the user's feed exactly where they left off.
π‘ Why this matters: Proper activation resource management ensures a seamless user experience, making the app appear to have been running continuously even when it was tombstoned.
β Key Takeaways
The WP7 execution model defines seven application states: Launch, Running, Closing, Deactivated, Activated, Dormant, and Tombstoned. The application life cycle follows a sequence from Launch to Running, then either Closing or Deactivation (which leads to Dormant or Tombstoned), and back through Activation to Running. During Deactivation, applications must perform resource management by saving state, releasing resources, and closing connections. During Activation, applications must restore state, re-establish connections, and reload resources. Students must understand the difference between Dormant (memory preserved) and Tombstoned (memory cleared) to implement proper state-saving logic. The most critical exam concept is handling the Deactivated event to save data and the Activated event to restore it, as this determines app reliability.
π§ Quick Revision Questions
- What are the seven states in the WP7 execution model?
- What is the difference between Dormant and Tombstoned states?
- What actions must an application perform during the Deactivated event?
- What is the sequence of the application life cycle from Launch to Closing?
- How does resource management differ between activation from Dormant vs. Tombstoned states?
π Lecture 27 β Deactivation Resource Management
π Overview: This lecture explores the contrast between activation and deactivation approaches to resource management, focusing on content-centric computing challenges and solutions. It introduces structured data handling in the Mango framework, emphasizing how these systems maintain performance while managing power constraints.
ποΈ Topics Covered
The lecture covers Activation vs Deactivation Resource Management approaches, Content Centric Experience challenges and working mechanisms, Structured Data concepts and IO Performance considerations, and Structured Data implementation in the Mango framework.
π Lecture Summary
Activation Resource Management
This section covers the activation-based approach where resources are allocated and activated as needed by applications. The system proactively manages resources by anticipating demand and keeping components ready for immediate use. This approach prioritizes responsiveness over power efficiency.
π‘ Why this matters: Activation management is common in desktop systems but can waste significant power in mobile devices.
Deactivation Resource Management
Deactivation resource management takes the opposite approach β resources are deactivated or put into low-power states by default, and only activated when explicitly required. This conservative strategy prioritizes power conservation over immediate responsiveness, making it more suitable for mobile and pervasive computing environments where battery life is critical.
π Definition β Deactivation Resource Management: A resource management strategy where system resources are kept in low-power or inactive states as default, and only activated on demand to minimize energy consumption.
Content Centric Experience: Challenges
The content-centric experience faces several key challenges:
- Data discovery: Finding relevant content across distributed networks
- Content delivery: Ensuring timely delivery while managing network resources
- Caching strategies: Determining what content to cache and for how long
- Power management: Balancing content availability with battery constraints
- Network heterogeneity: Handling varying connectivity conditions
Content Centric Experience: Working
The working mechanism of content-centric systems involves:
- Content naming: Using meaningful names instead of host addresses
- Interest propagation: Broadcasting requests for named content
- Content routing: Forwarding requests to nodes that have the content
- Caching nodes: Intermediate nodes cache popular content for faster future access
- Power-aware scheduling: Deactivating unnecessary network components when idle
Structured Data and IO Performance
Structured data refers to information organized in a predefined format (like tables or records) that enables efficient storage, retrieval, and processing. IO performance in mobile systems is affected by:
- Read/write cycles: Flash memory has limited write endurance
- Access patterns: Sequential vs random access affects speed
- Data fragmentation: Scattered data reduces efficiency
- Cache effectiveness: Proper caching reduces physical IO operations
π Definition β Structured Data: Data organized in a consistent, predictable format (rows, columns, records) that allows systematic access and manipulation.
Structured Data in Mango
Mango implements structured data handling with specific optimizations for mobile environments:
- Schema-based storage: Data organized using predefined schemas for efficient access
- Compression techniques: Reducing data size to minimize IO operations
- Indexing mechanisms: Creating indexes for faster queries without full scans
- Batched operations: Grouping writes to reduce flash wear
- Power-aware transactions: Committing data during active network periods
π Formula: IO Performance β (Data Size Γ Access Frequency) / (Cache Hit Rate Γ Power Budget)
π Example: In Mango, if a contact list with 1000 records is accessed 50 times per day, and caching achieves an 80% hit rate, the physical IO operations are reduced from 50,000 to 10,000 per day, saving 80% of battery consumption.
β Key Takeaways
The fundamental difference between activation and deactivation resource management is that activation prioritizes performance while deactivation prioritizes power savings, making the latter crucial for mobile devices. Content-centric computing addresses challenges of data discovery, caching, and delivery in pervasive networks. Structured data handling significantly improves IO performance by enabling efficient access patterns, indexing, and compression. Mango's implementation shows how batched operations and power-aware transactions can extend battery life while maintaining data integrity. Students must understand that choosing between activation and deactivation strategies depends on the specific application's performance vs power requirements.
π§ Quick Revision Questions
- What is the primary difference between activation and deactivation resource management?
- List three major challenges in content-centric computing experience.
- How does structured data improve IO performance in mobile systems?
- What optimization techniques does Mango use for structured data handling?
- Why is a 50% cache hit rate significant for power consumption in mobile devices?
π Lecture 28 β LINQ to Everything
π Overview: This lecture addresses the challenge of querying diverse data sources in mobile applications, including relational databases with complex relationships, static reference data, web service caches, and local user data like contacts and appointments. It introduces the βLINQ to Everythingβ concept, where Language Integrated Query (LINQ) unifies data access across these varied sources, simplifying development and improving performance.
ποΈ Topics Covered
The lecture covers complex data scenarios with multiple tables and foreign keys, managing huge amounts of static reference data, caching web service data locally, filtering and querying user data (contacts and appointments), and the architecture of local storage code-first development. It also introduces new and updated APIs for accessing user data, including Chooser Tasks and the Microsoft.Phone.UserData namespace.
π Lecture Summary
Complex Scenarios
This section introduces the challenge of complex relationships and constraints in mobile databases. The Shopping List example demonstrates a typical mobile app database with 7 tables, hundreds of records, and 5 foreign keys, including tables for Lists, Stores, Categories, ItemReferenceData, ListItems, Favorites, and History. Each table has primary keys (PK) and foreign keys (FK) linking to other tables, such as ListItemId referencing ListId and StoreId. This structure enables persistent storage of user-specific data, like which items are in a list, at which store, and in which category, but requires careful query design to avoid performance issues on resource-constrained mobile devices. π‘ Why this matters: Understanding these relationships is crucial for writing efficient LINQ queries that join multiple tables while minimizing memory and processing overhead.
Huge amounts of static reference data
This topic addresses applications that rely on large, mostly unchanging datasets. The dictionary app example uses 3 tables, with one table containing 500k rows for words and their definitions. The schema includes a Words table with fields like WordId, Word, Pronunciation, Definition, AlternateSpellings, and Origin, linked to a Favorites table (with FavoriteId and AddedDate) via WordId. Static reference data is typically fetched once from a server and cached locally to reduce network calls and improve app responsiveness. LINQ is used to query this local cache efficiently, for example, to search for a word or retrieve all favorite words, without overwhelming the deviceβs limited memory. π‘ Why this matters: Properly handling large static datasets is essential for apps like dictionaries, encyclopedias, or product catalogs, where offline access and fast search are critical.
Web Services Cache
This section describes a hybrid approach to fetching reference data from the cloud and caching it locally on the device. The Web Services Cache pattern involves: 1) Fetching reference data (e.g., word definitions, product descriptions) from a cloud web service, 2) Storing it in a local database or cache (using SQLite or isolated storage), and 3) Combining it with user-specific data (e.g., userβs favorites, history). The example shows a Words table with web-sourced fields like Pronunciation and Definition, joined with a user-specific Favorites table. This approach ensures fast access to frequently used data while still allowing updates from the cloud when connectivity is available. LINQ queries can seamlessly combine local cache data with real-time web service calls using asynchronous patterns. π‘ Why this matters: This pattern is vital for mobile apps that need to work offline while providing fresh data when online, balancing performance with data freshness.
Users Data
This topic covers querying user-specific local data, such as contacts and appointments. Examples include: filtering contacts to find those with birthdays in the next month, and querying all appointments to find an available time for a meeting. These queries are performed using the Microsoft.Phone.UserData API, which provides read-only access to the phoneβs built-in contacts and appointments databases. LINQ is used to filter, sort, and project this data into useful results. For instance, a query might filter contacts by checking if their birthday date falls within a future range, or find appointment slots by comparing start and end times. This data is local and private, so the API enforces security restrictions. π‘ Why this matters: These capabilities enable apps to provide personalized features like birthday reminders, scheduling assistants, and contact-based recommendations without requiring manual data entry.
Local Storage Data β Overview
This section provides an overview of how local storage data is filtered in mobile applications. The associated diagram shows a Filter abstract process that takes raw data (from contacts, appointments, or local databases) and applies criteria to produce filtered results. The key idea is that mobile apps often need to present only a subset of available data to the user due to screen space and performance constraints. LINQ expressions act as the filtering mechanism, allowing developers to write declarative queries (e.g., Where, OrderBy, Select) that are executed against local data stores. This enables efficient data retrieval without loading entire datasets into memory. π‘ Why this matters: Efficient filtering is crucial for responsive mobile UIs, especially when dealing with large contact lists or appointment calendars.
Architecture
This section discusses the architecture of local storage in mobile applications, specifically focusing on Code First Development. The associated diagram illustrates a flow where developers write code (classes and LINQ queries) that generates the local database schema (tables, relationships) at runtime. This is the Code First approach, where the data model is defined in C# or VB.NET code, and the database (e.g., SQL Server Compact Edition or SQLite) is created from that code. The βCodeβ block includes entity classes (like ListItem, Category) and LINQ queries that define how data is accessed. The βLocal Databaseβ block is created automatically based on these classes. This approach simplifies development by eliminating the need for separate database design tools and allows developers to work entirely in their familiar programming language. π‘ Why this matters: Code First development reduces the gap between object-oriented code and relational storage, enhancing productivity and reducing errors in mobile app data layers.
User Data β New and Updated APIs
This topic introduces the new and updated APIs for accessing user data in Windows Phone. It lists Chooser Tasks that allow the user to pick data from the device:
- EmailAddressChooserTask: Prompt user to select an email address from contacts.
- PhoneNumberChooserTask: Prompt user to select a phone number.
- AddressChooserTask: Prompt user to select a physical address.
Additionally, the Microsoft.Phone.UserData namespace provides direct programmatic access to:
- Contacts (e.g., names, numbers, emails)
- Appointments (e.g., dates, subjects, locations)
These APIs enable apps to integrate deeply with user data without building separate input forms. The Chooser Tasks are βlaunchersβ that return the selected data via events. π‘ Why this matters: Using these standard APIs ensures a consistent user experience and leverages the phoneβs existing data, reducing development effort and increasing app utility.
Microsoft.Phone.UserData
This section highlights important points about the Microsoft.Phone.UserData namespace:
- Contacts and Appointments APIs are read only β Apps cannot modify or delete contacts or appointments using these APIs; they can only query and read existing data.
- Third party social network data cannot be shared β Data from third-party social networks (e.g., Facebook contacts, Twitter followers) that is integrated into the phoneβs contacts list cannot be accessed by other apps due to privacy restrictions.
These restrictions are by design to protect user privacy and data security. Developers must work within these constraints, meaning they cannot create new contacts or sync data back to the cloud without using separate authorizations (e.g., OAuth). π‘ Why this matters: Developers must be aware of these limitations when designing features that depend on user data, and plan for read-only access or alternative data sources.
Contact/Appointment Data Share
This topic likely discusses the concept of sharing contact and appointment data between apps. The lecture suggests that apps can consume contact and appointment data (read-only) but cannot share the raw data with third parties beyond the userβs explicit consent via Chooser Tasks. Data sharing is controlled by the operating system, which enforces per-app permissions. For example, an app can read a contactβs birthday to show a reminder, but it cannot export that birthday to another app without going through share contracts (like ShareTask). The LINQ queries performed against this data are local to the app and do not persist beyond the appβs lifecycle. π‘ Why this matters: Understanding data sharing limitations is essential for building compliant, privacy-respecting mobile apps that work within the platformβs security model.
β Key Takeaways
The most critical concept from this lecture is that LINQ provides a unified query language to access diverse data sourcesβrelational databases with complex schemas (7+ tables, many foreign keys), huge static reference data (500k+ rows), cached web service data, and read-only user data like contacts and appointments. Students must remember that mobile data access requires efficient filtering and caching strategies (e.g., fetching web data only once and storing locally) to optimize performance on resource-constrained devices. The Code First development approach simplifies database creation by generating schemas from code, while APIs like Microsoft.Phone.UserData and Chooser Tasks provide read-only access to personal data with strict privacy protections. Finally, understanding the distinction between static reference data and user-specific data is crucial for designing effective mobile data architectures.
π§ Quick Revision Questions
- In the Shopping List example, how many tables and foreign keys are involved? What is the purpose of each of the major tables (ListItems, Favorites, History)?
- What is the βWeb Services Cacheβ pattern, and how does LINQ help combine cloud data with local user-specific data?
- Describe two examples of filtering user data using LINQ with contacts and appointments APIs.
- What are the key restrictions of the Microsoft.Phone.UserData namespace regarding read/write access and social network data?
- Explain the Code First development approach and how it generates the local database schema from code.
π Lecture 29 β Rethinking Multitasking
π Overview: This lecture explores how to rethink multitasking in mobile and pervasive computing environments to enhance user experience (UX). It emphasizes keeping the UX great, getting more out of the phone, and avoiding user waiting times. The lecture provides practical strategies for balancing efficiency with user satisfaction.
ποΈ Topics Covered
The lecture covers three main areas: keeping the UX great through smooth multitasking design, getting more out of the phone by optimizing resource usage, and not keeping users waiting through efficient task management. Each topic is presented with actionable insights for mobile app developers and designers.
π Lecture Summary
Rethinking Multitasking
This introductory section sets the stage for rethinking multitasking in mobile computing. Traditional multitasking often degrades UX by causing lag, battery drain, or app crashes. The lecture argues for a new approach that prioritizes user satisfaction over raw performance.
π Definition β Multitasking: The ability of a device to run multiple applications or processes simultaneously, allowing users to switch between tasks quickly. π Formula: Efficiency = (Completed Tasks Γ· Total Time) β User Frustration Index β Maximizing completed tasks while minimizing user frustration π Example: A user switches between a messaging app, a web browser, and a music player. If the music skips when switching apps, UX suffers. Solution: Preload audio buffers and keep music priority high in the system.
Keep the UX Great
This section focuses on maintaining high-quality user experience during multitasking. Key strategies include smooth transitions between apps, predictive resource allocation, and graceful degradation when resources are limited. The goal is to make multitasking feel seamless.
π Definition β Graceful degradation: A design principle where a system continues to function acceptably even when parts of it fail or resources are constrained. π Strategy: Prioritize visible UI elements over background processes β Users see smooth animations even if background tasks slow down. π Example: When a user opens a camera app while streaming video, the video may pause briefly (graceful degradation) instead of crashing the entire device. π‘ Why this matters: Great UX in multitasking builds user trust and reduces frustration, directly impacting app retention.
Get More Out of the Phone
This section discusses optimizing device resources to maximize productivity. Techniques include efficient memory management, battery-aware task scheduling, and offloading heavy tasks to the cloud or specialized hardware (e.g., GPUs, neural engines).
π Definition β Battery-aware task scheduling: A scheduling algorithm that prioritizes tasks based on their energy cost and current battery level to extend device usage time. π Formula: Task Priority = (Task Importance Γ Expected Battery Cost)β»ΒΉ β Lower battery cost tasks get higher priority when battery is low π Example: A phone with 15% battery should postpone heavy background syncing (e.g., photo uploads) and prioritize low-energy tasks like checking notifications. π‘ Why this matters: Getting more out of the phone extends usability and improves user satisfaction before needing a recharge.
Donβt Keep Users Waiting
This final section emphasizes minimizing user-perceived latency. Strategies include lazy loading (loading content only when needed), background pre-fetching, and skeleton screens (placeholder UI that shows structure before content loads). The goal is zero visible waiting time.
π Definition β Lazy loading: A design pattern where content is loaded only when it becomes visible or requested by the user, reducing initial load time and memory usage. π Formula: Perceived Wait Time β€ 100ms for instant feel; β€ 300ms for acceptable delay π Example: Instead of loading all 100 posts in a social media feed at once, load the first 10 posts instantly, then load next batches as the user scrolls (lazy loading). π‘ Why this matters: Users associate waiting with poor UX and are likely to abandon apps with long load times.
β Key Takeaways
For exams, remember these critical points: (1) Multitasking design must prioritize user experience over raw processing power. (2) Graceful degradation keeps UX acceptable even under resource constraints. (3) Battery-aware scheduling extends device usefulness. (4) Lazy loading and pre-fetching reduce perceived waiting time. (5) The goal is zero user waiting with smooth transitions between tasks.
π§ Quick Revision Questions
- What is the primary goal of rethinking multitasking in mobile computing?
- How does graceful degradation improve UX during multitasking?
- Explain battery-aware task scheduling and give an example.
- What is lazy loading and how does it reduce perceived waiting time?
- What are the recommended maximum wait times for instant feel and acceptable delay?
π Lecture 30 β Windows Phone Harmony
π Overview: This lecture examines how Windows Phone rethought multitasking to balance UX performance with system resource optimization. It introduces background agents, their architecture, and how they enable efficient background processing without degrading the user experience.
ποΈ Topics Covered
The lecture covers the philosophy of rethinking multitasking for mobile, the relationship between multitasking and phone health, the concept of agents for getting more out of the phone, the components of multitasking, the end-to-end architecture, and background agent functionality.
π Lecture Summary
Rethinking Multitasking
Three core principles guide Windows Phoneβs approach to multitasking. First, keep the UX great β the user interface must remain responsive and smooth. Second, get more out of the phone β maximize the deviceβs capabilities without overloading the system. Third, donβt keep users waiting β background tasks should never cause noticeable delays.
π‘ Why this matters: On resource-constrained mobile devices, traditional PC-style multitasking can kill battery life and responsiveness. Windows Phoneβs approach sacrifices full background execution for a consistently good user experience.
Multitasking and Phone Health
Managing multitasking is essential for maintaining overall phone health. The OS must continuously balance foreground user activity with background processing to prevent battery drain, memory exhaustion, and CPU overheating. Poor multitasking design leads to sluggish performance and shortened battery life.
Getting more out of the phone: agents
Windows Phone uses agents to handle background work efficiently. These agents monitor resource usage and align with system and user activity. They balance foreground and background processing by triggering processing on demand rather than running continuously. Agents leverage new OS services that provide structured APIs for background tasks.
Multitasking Components
The multitasking system consists of several key components working together:
- Background agents that run periodic or event-driven tasks
- Resource management policies that limit CPU, memory, and network usage for background processes
- Tombstoning β the process of suspending and potentially terminating background apps when memory is needed
- Fast application switching that allows quick return to recently used apps
End to End Architecture
The end-to-end architecture shows how foreground apps and background agents interact through the operating system. The OS acts as a mediator, controlling resource allocation and scheduling. Agents communicate with the OS through well-defined interfaces, and the system decides when to activate, suspend, or terminate each agent based on current phone state and resource availability.
Background Agent Functionality
Background agents have specific capabilities and constraints:
- They can perform periodic tasks (e.g., updating live tiles, fetching new data)
- They have limited execution time and memory budgets
- They cannot run continuously β the OS enforces resource quotas
- Agents must declare their intended usage through manifest files
- The system can defer or cancel agent execution based on battery level, network connectivity, or user activity
β Key Takeaways
Windows Phone prioritized UX responsiveness over unrestricted multitasking, using tombstoning and resource-constrained background agents to balance user experience with system health. Agents monitor resource usage, align with system activity, and process on demand rather than continuously. The end-to-end architecture ensures that background tasks never degrade foreground performance. Developers must design agents within strict time and memory limits. Successful mobile multitasking requires the OS to actively manage resource allocation between foreground and background processes.
π§ Quick Revision Questions
- What three principles guide Windows Phoneβs approach to rethinking multitasking?
- How do background agents differ from traditional PC background processes?
- What is tombstoning and why is it necessary for phone health?
- List two constraints placed on background agents by the OS.
- Explain how the end-to-end architecture balances foreground and background processing.