How darkstar085/device_xiaomi_whyred works
Project Type and Purpose
• This is an Android device-support (BSP/board configuration) repository for the Xiaomi Redmi Note 5 Pro (codename “whyred”) running LineageOS/Android.
• It contains device-specific build configs, hardware-abstraction-layer (HAL) modules, init scripts, resource overlays, policy files, proprietary file lists, and scripts to produce a flashable system image tailored to the SDM636 SoC platform.
File-Structure Analysis
• Top-level build files and device definitions:
• Android.bp / Android.mk / device.mk / BoardConfig.mk / product.mk
• configs/, compatibility_matrix.xml, proprietary-files.txt
• setup-makefiles.sh, extract-files.sh, reloade-libs.py
• Hardware Abstraction Layer (HAL) implementations under:
• audio/ (audio_policy, mixer_paths, platform info XMLs)
• gps/ (multiple versions of HIDL GNSS/GPS services, batching, geofence)
• ir/, light/, doze/ (doze service, IR consumer, light HAL)
• libshims/, libqti-perfd-client/ (vendor shims and performance-d client)
• Runtime & overlay artifacts:
• rootdir/ (init scripts, prebuilt shell scripts, fstab, ueventd)
• overlay-lineage/ and overlay/ and rro_overlays/ (resource overlays for frameworks and apps)
• sepolicy/ (SELinux policy modules for system and vendor apps)
• wifi/, keylayout/, idc/ (peripheral configs)
• Scripts & utilities:
• build helpers (reorder-libs.py, releasetools.py, update-sha1sums.py)
• flash_super_dummy.sh under partitions/
Architecture Insights from README
• Confirms device identity, SoC, Android version, and that this is a LineageOS device tree.
Components
a. Layers / Components
1. Build System Layer
• Android build (Soong/Make), device-specific Android.bp, Android.mk, BoardConfig, product.mk
• External scripts: extract-files.sh, setup-makefiles.sh
2. Kernel & Drivers Layer
• Linux kernel for SDM636 (outside this repo, but implied)
• Device drivers for GPS, audio codecs, sensors, light, IR
3. Vendor Binaries & Proprietary Blobs
• Lists in proprietary-files*.txt, shipped as vendor.img partitions
4. HAL Services Layer (HIDL / libbinder)
• audio HAL (audio_effects.xml, audio_policy_configuration.xml)
• gps / gnss HIDL services (versions 1.0,1.1,2.0 directories)
• light HAL service
• IR consumer HAL
• Doze Service (Java + native)
• libshims and performance client libraries
5. Init & Service Manager
• init scripts in rootdir/etc/*.rc, init_sdm660.cpp
• HIDL service registration (.rc files alongside HAL XML)
6. Android Framework Layer
• Framework APIs binding to HAL via HIDL interfaces
• Overlays (rro_overlays, overlay-lineage, overlay) that patch framework/UI resources
7. System Apps & Settings
• Dialer, Settings, SystemUI overlays customizing behavior/perms
8. SELinux Policy
• sepolicy/public, sepolicy/private, vendor policies governing access
b. Relationships & Data Flow
• Build System compiles HAL modules, resource overlays, and packages them with vendor blobs.
• At boot, init parses init.rc, invokes kernel modules, and starts HIDL HAL services.
• Services register with Android’s ServiceManager.
• Framework layers (e.g., AudioService, LocationManager) bind to these HIDL services to provide APIs to apps.
• Apps (Settings, Dialer, SystemUI) consume framework APIs for features like Doze, audio controls, location, IR transmitter.
• SELinux policy enforces access control between apps/framework and HAL processes.
• Overlays modify resource values in framework and system apps at runtime without rebuilding AOSP core.
c. Architectural Patterns & Principles
• Layered architecture: clear separation of kernel drivers, hardware abstraction (HAL), framework, and apps.
• Modular HAL: each hardware domain (audio, gps, light, IR) lives in its own HIDL service module.
• Resource-overlay mechanism for vendor customizations.
• SELinux enclaves to isolate process capabilities.
• Build-time composition using Soong/Make and script-driven blob extraction.
d. Key Technologies & Frameworks
• Android build (Soong + Make)
• HIDL (android.hardware.*@x.y)
• SELinux policies (sepolicy/)
• Resource overlays (RRO)
• Device init (init/*.rc, Android.bp)
• Vendor libraries (libqti-perfd, libshims)
Detail Level
• SELinux policy as a side-constraint layer on the runtime path.