ePUB is an open, industry-standard format for eBooks. However, support of ePUB and its many features varies across reading devices and applications. Use your device or app settings to customize the presentation to your liking. Settings that you can customize often include font, font size, single or double column, landscape or portrait mode, and figures that you can click or tap to enlarge. For additional information about the settings and features on your reading device or app, visit the device manufacturers Web site.
Many titles include programming code or configuration examples. To optimize the presentation of these elements, view the eBook in single-column, landscape mode and adjust the font size to the smallest setting. In addition to presenting code and configurations in the reflowable text format, we have included images of the code that mimic the presentation found in the print book; therefore, where the reflowable format may compromise the presentation of the code listing, you will see a Click here to view code image link. Click the link to view the print-fidelity code image. To return to the previous page viewed, click the Back button on your device or app.
Inside the Android OS
Building, Customizing, Managing and Operating Android System Services
G. Blake Meike
Larry Schiefer
Boston Columbus New York San Francisco Amsterdam Cape Town
Dubai London Madrid Milan Munich Paris Montreal Toronto Delhi Mexico City
So Paulo Sydney Hong Kong Seoul Singapore Taipei Tokyo
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals.
Android is a trademark of Google, Inc.
The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein.
For information about buying this title in bulk quantities, or for special sales opportunities (which may include electronic versions; custom cover designs; and content particular to your business, training goals, marketing focus, or branding interests), please contact our corporate sales department at or (800) 382-3419.
For government sales inquiries, please contact .
For questions about sales outside the U.S., please contact .
Visit us on the Web: informit.com/aw
Library of Congress Control Number: 2021940286
Copyright 2022 Pearson Education, Inc.
All rights reserved. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, request forms and the appropriate contacts within the Pearson Education Global Rights & Permissions Department, please visit www.pearsoned.com/permissions/.
ISBN-13: 978-0-13-409634-6
ISBN-10: 0-13-409634-7
ScoutAutomatedPrintCode
Editor-in-Chief
Mark Taub
Acquisitions Editor
Malobika Chakraborty
Development Editor
Sheri Replin
Managing Editor
Sandra Schroeder
Senior Project Editor
Lori Lyons
Copy Editor
Paula Lowell
Production Manager
Aswini Kumar/codeMantra
Indexer
Ken Johnson
Proofreader
Donna E. Mulder
Compositor
codeMantra
Blake: For my siblings: Rusty, Annemarie.
Mercy, and Roger. One!
Larry: For Aidan and Ian. Dont ever stop
exploring and learning.
Preface
I started this book nearly 10 years ago. At the time, it seemed obvious to me that Android would be important in the burgeoning Internet of Things (IoT) world. Both Larry and I taught the Android Internals course for the great Marakana (later, New Circle). That class was so popular that both of us got to see a lot of the world while teaching it. I was certain that a book that described the general process of customizing Android for a new device without getting bogged down in details could be a hit.
On the other hand, I recall sitting in the restaurant in Grand Central Station with the editor of one of the books I co-authored (a man I very much respected) as he laid out comparable titles and explained in inexorable detail the chances that such a book would succeed. They were not good.
Sometime later, my co-author on OReillys Programming Android, Zigurd Mednieks, proposed the Android Deep Dive series to Addison-Wesley. The idea was a series of small, replaceable titles, none of which had the overhead of a large book. If a volume became obsolete, it could be replaced or updated without impact to the rest of the series. In this lower-risk environment, my book made sense. It was green-lighted, and I started work on it.
Somewhere around the time I got the first few chapters written, Laura Lewin (the series editor at that time) and Zigurd pitched another book to me. That pitch turned into Android Concurrency. I am very proud of that book, but it took several years to write and completely stalled work on this one.
When I finally returned to this book, I was no longer teaching Internals. Cyanogen had shut down, and both Android and I had moved on. When I picked up the book again, I discovered that Android had changed so much in the interim (ART, Treble, and SE Linux) that each time I caught up, it had already moved on. The book was nearly canceled.
I had the great luck to have Larry Schiefer on board as a technical reviewer. When I finally conceded that the project was swamped and on the verge of drowning, our superstar editor Malobika Chakraborty suggested I take on a co-author. Talk about luck: Larry volunteered! He pulled the book out of its hole, laid down some fantastic knowledge, and made this project relevant again. Im gonna buy him a t-shirt with a big yellow S on it.
Before you dig into the first chapter, let me offer a gentle reminder: This is not a cookbook. The book contains code examples, and they are all available online. They have all compiled successfully and run at least once. That, however, is no guarantee that they will compile and run for you (though we hope they do!). Tool chains change. Android changes. Devices change. Things that work today may well not work at all tomorrow. Our intention is that the content here is a guidebook, not a map.
Good luck!
Blake Meike, May 2021
Example Code
Most of the code shown in examples in this book can be found on GitHub at https://github.com/InsideAndroidOS.