Using Android as a reference, this book teaches the development of mobile apps designed to be responsive, trustworthy and robust, and optimized for maintainability. As the share of mission-critical mobile apps continues to increase in the ever-expanding mobile app ecosystem, it has become imperative that processes and procedures to assure their reliance are developed and included in the software life cycle at opportune times. Memory, CPU, battery life and screen size limitations of smartphones coupled with volatility associated with mobile environments underlines that the quality assurance strategies that proved to be successful for desktop applications may no longer be effective in mobile apps. To that effect, this book lays a foundation upon which quality assurance processes and procedures for mobile apps could be devised. This foundation is composed of analytical models, experimental test-beds and software solutions. Analytical models proposed in the literature to predict software quality are studied and adapted for mobile apps. The efficacy of these analytical models in prejudging the operations of mobile apps under design and development is evaluated. A comprehensive test suite is presented that empirically assesses a mobile app’s compliance to its quality expectations. Test procedures to measure quality attributes such as maintainability, usability, performance, scalability, reliability, availability and security, are detailed. Utilization of test tools provided in Android Studio as well as third-party vendors in constructing the corresponding test-beds is highlighted. An in-depth exploration of utilities, services and frameworks available on Android is conducted, and the results of their parametrization observed through experimentation to construct quality assurance solutions are presented. Experimental development of some example mobile apps is conducted to gauge adoption of process models and determine favorable opportunities for integrating the quality assurance processes and procedures in the mobile app life cycle. The role of automation in testing, integration, deployment and configuration management is demonstrated to offset cost overheads of integrating quality assurance process in the life cycle of mobile apps. Preface 5 Contents 7 Abbreviations and Acronyms 13 Chapter 1: Software Life Cycle 17 1.1 Process Models 18 1.2 Functional Specifications 21 1.2.1 User Stories 22 1.2.2 UML Use Case Diagrams 25 1.2.3 Software Requirements Specifications 28 1.3 Non-functional Requirements 30 1.4 Test-Driven Development 36 1.4.1 Acceptance Tests 36 1.4.2 Unit Tests 56 1.5 Continuous Integration and Delivery 59 1.5.1 Software Configuration Management 60 1.5.2 Build Automation 61 Exercises 66 Review Questions 66 Lab Assignments 69 References 70 Chapter 2: Development Fundamentals 72 2.1 Graphical User Interface 73 2.1.1 GUI Objects and Layouts 73 2.1.2 Event Handling 77 2.1.3 Redirection 78 2.2 Data Storage 81 2.2.1 Key-Value Pairs 82 2.2.2 Files 83 2.2.3 Database Systems 86 2.2.4 Personal Data Storage 92 2.3 Data Connectivity 97 2.3.1 Web Access 97 2.3.2 Short Message Service 107 2.4 Concurrency 112 2.4.1 Threads and Asynchronous Tasks 113 2.4.2 Processes 116 2.5 Location and Sensor APIs 120 Exercises 129 Review Questions 129 Lab Assignments 132 References 133 Chapter 3: Software Quality Assessment 134 3.1 Functional Requirements Testing 134 3.1.1 Equivalence Class Partitioning 136 3.1.2 Boundary Value Analysis 138 3.1.3 Domain Test Design 138 3.2 Maintainability 145 3.2.1 Sub-characteristics 146 3.2.2 Maintainability Measures 147 3.3 Usability and Accessibility 148 3.3.1 Models 149 3.3.2 Evaluation 151 3.4 Performance Testing 153 3.4.1 Latency Measurement 153 3.4.2 GUI Performance 157 3.4.3 Memory Usage 159 3.4.4 Network Usage 161 3.4.5 Battery Usage 162 3.5 Scalability Testing 163 3.5.1 Scalability Models 164 3.5.2 Load Test Design 166 3.6 Reliability Testing 167 3.6.1 Growth Models 168 3.6.2 Fault Injection 169 3.6.3 Operational Profile 169 3.6.4 Reliability Test Design 172 3.7 Availability 173 3.7.1 Availability Models 173 3.7.2 Stress Test Design 175 3.8 Safety 177 3.8.1 FMEA 178 3.8.2 FTA 178 3.9 Security 181 3.9.1 Vulnerabilities and Threat Analysis 181 3.9.2 Security Testing 189 3.10 Static Code Analysis 190 Exercises 195 Review Questions 195 Lab Assignments 199 References 201 Chapter 4: Maintainability and Multi-platform Development 203 4.1 Software Patterns 203 4.1.1 Programming Paradigms 204 4.1.2 Design Patterns 214 4.1.3 Architectural Patterns 221 4.2 Design Description 231 4.2.1 Structural 231 4.2.2 Behavioral 233 4.3 Multi-platform Development 236 4.3.1 Native Development 237 4.3.2 Hybrid 249 4.3.3 Cross-Platform Development 255 Exercises 262 Review Questions 262 Lab Assignments 268 References 269 Chapter 5: User Interaction Optimization 271 5.1 Multimodality 271 5.1.1 Touch Gestures 272 5.1.2 Motion Gestures 278 5.1.3 Verbal Gestures 281 5.1.4 Visual Gestures 284 5.1.5 Accessibility Frameworks 297 5.2 Navigation Controls 302 5.3 Dashboards 314 5.4 Custom GUI 327 5.5 Animated GUI 337 Exercises 346 Review Questions 346 Lab Assignments 348 References 350 Chapter 6: Performance Acceleration 352 6.1 Data Compression 352 6.1.1 Lossless Compression 353 6.1.2 Lossy Compression 357 6.2 Data I/O Optimization 364 6.2.1 File System I/O 365 6.2.2 Network I/O 367 6.3 Rendering Pipelines 380 6.3.1 Animation Rendering 381 6.3.2 Video Rendering 390 6.3.3 Augmented Reality 393 6.3.4 Hardware Acceleration 397 6.4 Parallel Programming 399 6.4.1 Thread Priority 399 6.4.2 Data Parallel Computation 403 Exercises 408 Review Questions 408 Lab Assignments 411 References 414 Chapter 7: Scalability Provisioning 415 7.1 Scalable Media Transport 415 7.2 Scalable Local Storage 427 7.2.1 Data Models 427 Online Transaction Processing 428 Online Analytical Processing 431 Hybrid Transactional Analytical Processing 434 7.2.2 Data Structures and Query Plan 439 7.2.3 Location Queries 446 7.3 Scalable Design Patterns 450 7.3.1 Data Cache 450 7.3.2 Event Notifications 454 Task Scheduling 455 7.4 GUI Scalability 459 Exercises 463 Review Questions 463 Lab Assignments 466 References 468 Chapter 8: Reliability Assurance 469 8.1 Thread-Safe Patterns 469 8.1.1 Serializing GUI Updates 470 8.1.2 Serializing Shared Memory Access 473 8.1.3 Thread Synchronization 480 8.2 Memory Leaks 485 8.3 Reliable Persistent Storage 489 8.3.1 Isolation and Consistency 489 8.3.2 Atomicity and Durability 499 8.3.3 Sharded Persistent Storage 500 8.4 Data Validation 505 8.4.1 Input Validation 505 8.4.2 Integrity Constraints 508 8.5 Stateful Data Transport 511 Exercises 520 Review Questions 520 Lab Assignments 525 References 526 Chapter 9: Availability and Fault Tolerance 527 9.1 Availability Primitives 527 9.1.1 Design Diversity 528 9.1.2 Broadcast Primitives 530 9.2 Critical Communication Availability 531 9.2.1 Network Fault Tolerance 532 9.2.2 Design Diverse Emergency Communication Architecture 538 9.3 Sensor Fusion and Redundancy 547 9.4 Data Availability 562 9.4.1 Data Synchronization 563 9.4.2 Data Sharing 567 9.5 Battery Power Saving 574 Exercises 577 Review Questions 577 Lab Assignments 580 References 581 Chapter 10: Security and Trust 583 10.1 Cryptographic Primitives 583 10.1.1 Symmetric Cryptography 584 10.1.2 Asymmetric Cryptography 585 10.1.3 Message Digest 586 10.1.4 Message Authentication Codes 587 10.1.5 Digital Signatures 587 10.2 Secure Web Access 590 10.2.1 User Authentication 591 10.2.2 Authentication Delegation and Single Sign-On 594 10.2.3 Access and Authorization Delegation 603 10.2.4 Peer Authentication and Confidentiality 617 10.3 Secure Network Access 622 10.3.1 Transport Layer Security 623 10.3.2 Layer 3 Security 624 10.3.3 Layer 2 Security 627 10.4 Secure System Access 631 10.4.1 Mobile Application Authenticity 632 10.4.2 Securing Inter-Application Communication 633 10.4.3 Permissions and Access Control 634 Exercises 639 Review Questions 639 Lab Assignments 641 References 642 Appendix A: Behavior-Driven Development 643 Take Photo 643 Scroll Photos 647 Assign Caption 653 Search Photos 653 Appendix B: Installation and Configuration 657 Compile and Deploy a Servlet 657 Compile and Deploy a Web Socket Hub 658 Configure Tomcat to Enable SSL 659 Install and Configure Jenkins 659 Install Metrics Reloaded 660 Index 661