> For the complete documentation index, see [llms.txt](https://notes.tejpratapsingh.com/_/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.tejpratapsingh.com/_/android-tips/interview/aosp.md).

# AOSP

### Boot

1. Walk through the complete Android boot sequence from power-on to `system_server` startup.
2. What is the role of the Boot ROM, and how does it verify the next stage bootloader?
3. Explain the differences between U-Boot, Little Kernel (LK), and proprietary bootloaders in AOSP.
4. How does `avb_verify` work in the context of Verified Boot 2.0 (AVB)?
5. What is the purpose of the `boot.img` header, and how do the V3 and V4 formats differ from V1/V2?
6. Describe the process of loading and verifying the `vendor_boot` partition.
7. How does the bootloader pass the kernel command line and device tree (DTB) to the Linux kernel?
8. What is the role of `init` in early userspace, and how does it parse `init.rc` scripts?
9. Explain the difference between early-init, init, and late-init stages in `init.rc`.
10. How does `init` handle the transition from the rootfs ramdisk to the system partition?
11. What is the purpose of the `system/etc/init/` directory and how does it relate to first-stage vs second-stage `init`?
12. How do you debug early boot failures before `logd` and `logcat` are available?
13. Explain how dm-verity is initialized during boot and its impact on I/O performance.
14. What is the purpose of the `vbmeta` partition, and how are rollback indexes used?
15. How does the boot sequence differ between a normal boot and a recovery boot?

***

### Build

1. Explain the AOSP build system architecture: how do `Soong`, `Kati`, and `Ninja` interact?
2. What is the difference between `Android.bp` and `Android.mk`, and when would you still need the latter?
3. How does the `Android.bp` module system handle dependencies between shared libraries and static libraries?
4. Describe the purpose of `AndroidProducts.mk`, `BoardConfig.mk`, and `device.mk` in a device build.
5. How do you add a new HAL implementation to the build without modifying AOSP core repositories?
6. Explain the difference between `eng`, `user`, `userdebug`, and `user` build variants at the build system level.
7. What is the purpose of `sepolicies` in the build, and how are they compiled into the final image?
8. How does the build system generate OTA packages, and what is the role of `releasetools.py`?
9. Describe how to create a custom build target that packages additional prebuilt binaries.
10. What are `apex` modules, and how do they change the traditional system image partitioning?
11. How does the build system handle kernel compilation out-of-tree vs in-tree?
12. Explain the purpose of `PRODUCT_COPY_FILES` vs `PRODUCT_PACKAGES` and their build-time implications.
13. How do you implement a build-time flag that conditionally compiles source code across multiple modules?
14. What is the role of `bionic` in the build, and how does it differ from glibc-based builds?
15. How would you optimize a clean AOSP build time for a large team using distributed build caches?

***

### Framework

1. Explain the Zygote startup process and why it uses a prefork model.
2. What happens during `ZygoteInit` before the first application process is forked?
3. Describe the Binder IPC mechanism: how does a client obtain a reference to a system service?
4. What is the difference between `BpBinder` and `BBinder`, and how does the proxy/stub pattern work in native code?
5. How does `AIDL` differ from `HIDL` and `AIDL` (stable) in terms of interface stability and versioning?
6. Explain the role of `ServiceManager` vs `hwservicemanager` vs `vndservicemanager`.
7. What is the purpose of the `system_server` process, and how is it started from Zygote?
8. Describe the `ActivityThread` initialization sequence when an application process starts.
9. How does the `PackageManagerService` scan and resolve packages during boot?
10. Explain the difference between `system` permissions, `signature` permissions, and `normal` permissions in `AndroidManifest.xml`.
11. How does the `WindowManagerService` manage window layers and surface composition?
12. Describe the input event pipeline from kernel to application: `EventHub`, `InputManagerService`, `InputDispatcher`.
13. What is the role of `SurfaceFlinger` in the display pipeline, and how does it interact with HWC?
14. How does the `PowerManagerService` coordinate with the kernel for suspend/resume and wakelocks?
15. Explain the `JobScheduler` framework and how it interacts with Doze mode and App Standby.
16. What is the difference between a `ContentProvider` running in its own process vs the caller's process?
17. How does the `ActivityManagerService` handle process lifecycle and out-of-memory killing decisions?
18. Describe how `BroadcastReceiver` delivery works, including ordered vs unordered broadcasts and background restrictions.
19. What is the purpose of `Looper`, `Handler`, and `MessageQueue` in the Android threading model?
20. How does the `Resources` framework handle runtime resource overlay (RRO) and static overlay?

***

### System Service

1. How do you implement a new system service that is accessible to third-party applications?
2. What is the difference between a Java system service and a native system service in terms of registration?
3. Explain the `SystemService` base class and the `onStart()`, `onBootPhase()`, and `onUserStarting()` lifecycle methods.
4. How do you ensure thread safety in a system service that receives concurrent Binder calls?
5. Describe the watchdog mechanism (`Watchdog.java`) and how to register a system service with it.
6. How does `ActivityManagerService` enforce background execution limits introduced in recent Android versions?
7. Explain the architecture of `ConnectivityService` and how it manages multiple network agents.
8. How does `LocationManagerService` interact with GNSS HAL and fuse location providers?
9. Describe the power management flow from `PowerManagerService` to the kernel power HAL.
10. How does `BatteryService` monitor battery state and propagate events to the framework?
11. Explain the role of `StorageManagerService` and how it handles adopted storage vs portable storage.
12. How does `AudioService` manage audio focus, routing, and policy decisions across HAL implementations?
13. Describe the `CameraService` architecture and how it handles concurrent camera access from multiple apps.
14. What is the purpose of `SensorService`, and how does it batch sensor events for power efficiency?
15. How does `TelephonyRegistry` dispatch phone state changes to multiple listeners securely?
16. Explain the `VibratorService` and `LightsService` abstractions over their respective HALs.
17. How would you add a custom hardware feature (e.g., a proprietary sensor) and expose it through the framework?
18. Describe how `DevicePolicyManagerService` enforces enterprise policies at the system service level.
19. How does `NetworkManagementService` use `netd` to configure iptables and routing rules?
20. What is the role of `AppOpsService` and how does it provide fine-grained permission auditing beyond runtime permissions?
