Hardware-Aware Conditional Code in Android Apps
Marco Alecci, Jordan Samhi, Li Li, Tegawendé F. Bissyandé, Jacques Klein
Abstract
Android OS runs on a highly diverse set of devices, spanning entry-level phones and flagships with substantially different hardware characteristics, including memory capacity, processors, displays, cameras, and sensors. Through APIs, apps can query device information at runtime, such as memory, hardware features, and manufacturer, among other device properties, allowing developers to execute different code paths on different devices. Existing studies cover only specific compatibility bugs or brand-specific behavior; however, the broader use of hardware information in app logic has not been comprehensively explored. We address this question with a large-scale empirical study of hardware-related if statements in Android apps. We statically analyze 50,000 apps to identify the if statements whose conditions depend on the values of hardware-related APIs, and extract their conditions together with the code of their branches. Our results show that 95% of successfully analyzed apps contain at least one such statement, with an average of 74 per app, which suggests that hardware-related logic is widespread. We then apply an LLM-assisted open-coding process to the extracted code to build a structured taxonomy of the purposes behind hardware-related conditional code. The resulting characterization shows that developers use hardware information for feature availability checks, UI adaptation, emulator detection, device tiering, and resource management, among others.
Create a lesson
Metadata
- Comments
- 21 pages
Related papers
EmbedGym: Letting Coding Agents Develop and Debug Embedded Firmware Without Physical Hardware
Shared title terminologycs.SEMinghui Zhao, Yiming Li, Sophie Zhu et al.
SynMOE: A Syntax-Aware MOE-Guided Approach for PEFT-Based Code Intelligence Learning
Shared title terminologycs.SEShuo Liu, Hao Ning, Jacky Keung et al.
Beyond Surface Metrics: Multi-Condition Requirements in Enterprise Maintenance and AI Coding Benchmarks
Shared title terminologycs.SEHeeyong Eun
RepGen: Reproducing Deep Learning Bugs through Context-Aware Code Generation and Verification
Shared title terminologycs.SEMehil B Shah, Mohammad Masudur Rahman, Foutse Khomh
When Relevant Code Is Wrong: Runtime-Aware Context for AI Coding Agents
Shared title terminologycs.SEWesley K. G. Assunção, Ramesh Periyathambi
Building a Unified Inline Code Editing Model for GitHub Copilot
Shared title terminologycs.SEMicrosoft CodeAI Team, Microsoft VS Code Team, Julia Gong et al.