Kick off your book project in 3 hours! Live workshop on Zoom. You’ll leave with a real book project, progress on your first chapter, and a clear plan to keep going. Saturday, May 16, 2026. Learn more…

Leanpub Header

Skip to main content

Mastering Android Systems: Hardware, Graphics and the Native Layer

Minimum price

$19.00

$29.00

You pay

$29.00

Author earns

$23.20
$
You can also buy this book with 1 book credit. Get book credits with a Reader Membership or an Organization Membership for your team.
PDF
EPUB
WEB
About

About

About the Book

This book explores how Java communicates with the native layer, how the rendering pipeline works with GPU and what happens when sensors are at work

Share this book

Categories

Author

About the Author

Abdur-Rahmaan Janhangeer

Long-time Python and Open Source specialist.

Contents

Table of Contents

Chapter 1: A Recap About The Four Components

  1. 1.1: The Four Components Overview
  2. 1.2: Applications as Clients, Not Owners
  3. 1.3: Android Framework as the Control Plane
  4. 1.4: Native System Layer as Execution Engine
  5. 1.5: Linux Kernel as Resource Authority
  6. 1.6: Communication Between Components
  7. 1.7: Why This Model Matters
  8. 1.8: Connecting Back to Previous Books
  9. 1.9: What Comes Next

Next Chapter Preview

Chapter 2: Looper, Handler, and MessageQueue

  1. 2.1: The Message Loop as a Runtime Primitive
  2. 2.2: Handler as a Scheduling Interface
  3. 2.3: MessageQueue – The Scheduling Core
  4. 2.4: Main Thread Looper and System Stability
  5. 2.5: HandlerThread and Background Loopers
  6. 2.6: Relation to Book 2 Concurrency Model in Android
  7. 2.7: Mental Model Summary
  8. Next Chapter Preview

Chapter 3: Context, Resources, and APK Loading

  1. 3.1: Context Hierarchy
  2. 3.2: Resources and AssetManager
  3. 3.3: APK Structure
  4. 3.4: Class Loaders in Android
  5. 3.5: Resource IDs and Theme Resolution
  6. Putting It All Together
  7. Mental Model
  8. Summary
  9. Next Chapter Preview

Chapter 4: JNI Fundamentals

  1. 4.1: Why JNI (Java Native Interface) Exists
  2. 4.2: Declaring Native Methods
  3. 4.3: The JNIEnv Pointer
  4. 4.4: JNI Types
  5. 4.5: Local vs Global References
  6. Closing Perspective
  7. Chapter Preview: Calling Java from Native Code

Chapter 5: Calling Java from Native Code

  1. 5.1: Finding Classes, Methods, and Fields
  2. 5.2: Making Callbacks into Java
  3. 5.3: Exception Handling in JNI
  4. 5.4: Caching Method IDs and Performance
  5. Threading Considerations
  6. Putting It All Together
  7. Mental Model
  8. Closing Thoughts
  9. Next Chapter Preview

Chapter 6: Calling Native from Java Under the Hood

  1. 6.1: ART’s Native Method Resolution
  2. 6.2: The JNI_OnLoad Entry Point
  3. 6.3: Explicit Registration with RegisterNatives
  4. 6.4: Efficient Buffer Passing and Zero-Copy
  5. 6.5: Native Crash Debugging
  6. Closing Perspective
  7. Next Chapter Preview

Chapter 7: The Full Graphics Stack

  1. 7.1: Skia Rendering Engine
  2. 7.2: BufferQueue Deep Dive
  3. 7.3: SurfaceFlinger Composition Model
  4. 7.4: Damage Region and Partial Updates
  5. 7.5: Hardware Composer (HWC2)
  6. Putting It All Together
  7. Why This Matters
  8. Looking Ahead

Chapter 8: GPU Pipeline and Frame Delivery

  1. 8.1: OpenGL ES and Vulkan Contexts in Android
  2. 8.2: Command Buffer Submission Flow
  3. 8.3: Triple Buffering vs Double Buffering
  4. 8.4: Why draw() Does Not Render Immediately
  5. 8.5: Frame Tracing with Perfetto
  6. Putting It All Together
  7. Common Failure Modes
  8. Closing Thoughts
  9. Next Chapter Preview

Chapter 9: Input System Deep Architecture

  1. 9.1: Linux Input Subsystem
  2. 9.2: EventHub
  3. 9.3: InputReader → InputDispatcher Pipeline
  4. 9.4: Focus System in WindowManagerService
  5. 9.5: Touch Targeting and Hit Testing
  6. 9.6: Why Input Latency Is Structural
  7. Closing Thoughts
  8. What Comes Next

Chapter 10: WindowManager and Surface Control

  1. 10.1: Window Tokens and Hierarchy
  2. 10.2: ViewRootImpl and WindowManagerService Contract
  3. 10.3: Surface Lifecycle
  4. 10.4: Z-ordering and Layering Model
  5. 10.5: How Multiple Apps Share the Display
  6. Mental Model: Window as a Contract
  7. Closing Thoughts
  8. Next Chapter Preview

Chapter 11: Location as a Complete System Service

  1. 11.1: Hardware Layer
  2. 11.2: Linux Kernel Drivers
  3. 11.3: Hardware Abstraction Layer (HAL)
  4. 11.4: Native System Services
  5. 11.5: System Server and LocationManagerService
  6. 11.6: Fusion Algorithms
  7. 11.7: Binder IPC Path
  8. 11.8: App-Level API
  9. 11.9: Sensor Interaction
  10. 11.10: Power and Scheduling
  11. 11.11: Security and Permissions
  12. Putting It All Together
  13. Mental Model
  14. Chapter Summary
  15. Next Chapter Preview

Chapter 12: System Stability Engineering

  1. 12.1: Watchdogs and Detecting System Stalls
  2. 12.2: ANR Deep Cause Chain Analysis
  3. 12.3: Tombstones : Understanding Native Crashes
  4. 12.4: Recovery Mode : Automatic Repair Mechanisms
  5. 12.5: Graceful Degradation : Surviving Partial Failure
  6. Closing Perspective
  7. Looking Ahead

Chapter 13: Cross-Layer Debugging

  1. 13.1: Why Cross-Layer Debugging Exists
  2. 13.2: The Unified Observability Stack
  3. 13.3: Logcat as a Multi-Layer Timeline
  4. 13.4: Perfetto as a Cross-Layer Truth Source
  5. 13.5: Binder Transaction Tracing Across Layers
  6. 13.6: GPU and Frame Pipeline Correlation
  7. 13.7: Memory and CPU Coupling
  8. 13.8: Cross-Layer Failure Patterns
  9. 13.9: Structured Debugging Workflow
  10. 13.10: Example Case Study: Location Causing System Lag
  11. 13.11: Mental Model Summary
  12. Chapter 14 Preview: Capstone System Diagnosis

Chapter 14: Capstone System Diagnosis

  1. 14.1: The System View of a Failure
  2. 14.2: Case Study 1 – Location Battery Drain
  3. 14.3: Case Study 2 – Location Causing UI Jank
  4. 14.4: Unified Debugging Method
  5. 14.5: Mental Model Consolidation

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub