android

Running Android Apps on HarmonyOS: An Evolving Story

For those accustomed to the vast Android app ecosystem, the question of running those apps on Huawei’s HarmonyOS is a natural one. However, the answer is complex and changing, particularly with the arrival of HarmonyOS NEXT. This post breaks down the current situation.

The Past: Android Compatibility (To Varying Degrees)

Older versions of HarmonyOS (before “NEXT”) had some level of compatibility with Android apps. This was possible because HarmonyOS was initially based on the Android Open Source Project (AOSP). While it wasn’t a perfect 1:1 compatibility, some Android apps could be run, sometimes even by directly installing APK files.

The Present and Future: HarmonyOS NEXT – Moving Away from Android

The game changer is “HarmonyOS NEXT.” Huawei is making a fundamental shift. HarmonyOS NEXT is designed to be incompatible with Android apps. This is a crucial point. Huawei’s strategy focuses on building a fully native HarmonyOS ecosystem. They want developers to create apps specifically for HarmonyOS, not relying on Android compatibility layers.

Methods for Running Android Apps (If Possible – Depends on the Version):

  • EasyAbroad/DroidTong: Some online sources mention “EasyAbroad” or “DroidTong.” These appear to be temporary compatibility solutions or layers. They might allow some Android apps to function, but with potential limitations (e.g., issues with notifications, needing to import files). These are not guaranteed solutions, especially on newer HarmonyOS versions.
  • APK Installation: Manually installing APK files might have worked on older HarmonyOS versions. This is becoming increasingly irrelevant and unreliable for HarmonyOS NEXT.
  • Emulators/Containers: Running Android within an emulator or container on HarmonyOS is a technical possibility. However, this is not a native compatibility feature and is not the direction Huawei is taking.
  • Cloud Phone: “Cloud phone” might allow remote access to an Android instance, not running apps directly on HarmonyOS.

HarmonyOS Watches and Other Devices:

  • HarmonyOS-based smartwatches generally do not run Android apps. They have their own app ecosystems.
  • Huawei’s AppGallery is the primary source for watch apps, offering categories like:
    • Navigation
    • Music
    • Calendar
    • Health & Fitness

The Key Takeaway:

The trend is clear: HarmonyOS, particularly HarmonyOS NEXT, is moving towards a completely native ecosystem. Huawei wants developers to build apps for HarmonyOS. While workarounds may exist for some Android apps on older versions, these are not the focus.

Running Android Apps on HarmonyOS: An Evolving Story Read More »

Android 16: A Technical Preview for Software Developers

The Android operating system continues its evolution with the upcoming release of version 16, poised to introduce a wave of technical advancements that will shape the mobile landscape for developers and end-users alike. For software entrepreneurs deeply invested in the Android ecosystem and its underlying technologies, understanding the nuances of this new iteration is paramount. This comprehensive technical preview delves into the core changes and features of Android 16, with a particular focus on aspects relevant to those interested in the Linux kernel, C/C++, Rust, and WebAssembly (WASM). We will explore the advantages and disadvantages this release brings to both the development process and the end-user experience, alongside a detailed examination of the new monitoring and observability capabilities.

The Road to Release: Timeline and Key Developer Milestones

Google is adopting a more predictable and potentially accelerated release schedule for major Android versions, with Android 16 targeted for release in the second quarter of 2025. This shift is significantly influenced by the move towards a Trunk Stable development model. This approach allows for continuous integration of features, potentially leading to a more robust and stable final product delivered at a faster pace.

The journey to the stable release involves several key stages, starting with Developer Previews that offer early access to new APIs and features for developers to experiment with and provide feedback. These previews are followed by Beta releases, which are more feature-complete and open to a wider audience for testing. Android 16 has progressed through several beta iterations, with Beta 4 being the most recent major release. This stage signifies that the platform is nearing its final form. A critical milestone for developers is the achievement of Platform Stability, which occurred with Beta 3. This designation indicates that the final internal and external APIs, as well as the app-facing system behaviors, are locked down. This provides developers with the assurance needed to finalize their testing and prepare their applications for the stable release. The official rollout of the stable version is anticipated around June 2025, a timeframe that often aligns with the launch of new Pixel devices.

The Android 16 beta program has primarily been accessible to users with recent Pixel devices, starting from the Pixel 6 series. This includes the latest models and even foldable devices like the Pixel Fold. The newest beta release, Beta 4, has also extended its availability to the recently announced Pixel 9a. Google has outlined a strategy of delivering two Android API releases in 2025. The major release, corresponding to Android 16, is planned for the second quarter, while a subsequent minor release introducing further developer APIs is scheduled for the fourth quarter. Notably, the Q2 release will be the primary one to include planned behavior changes that could impact existing applications.

The accelerated release cadence, facilitated by the Trunk Stable development model, represents a strategic move by Google to expedite the delivery of new features and enhancements to the Android ecosystem. This quicker pace of evolution has the potential to accelerate the adoption of cutting-edge technologies and APIs by developers. The Platform Stability milestone, reached in March, serves as a crucial indicator for developers to concentrate their efforts on final application testing and ensure seamless compatibility with the impending stable release. This predictability in the development cycle is invaluable for developers in planning their resource allocation and product release timelines. However, the initial focus of the beta program on Pixel devices might lead to a slight lag in comprehensive feedback and testing across the broader Android device landscape. This could potentially result in some device-specific issues emerging later in the wider adoption process.

Under the Hood: Technical Innovations for Developers

Android 16 brings a host of technical updates relevant to developers working with core system technologies.

Evolution of the Linux Kernel in Android 16

The foundation of Android, the Linux kernel, continues to evolve with version 16. The experimental Android 16 release is slated to launch with the Linux kernel version 6.12, and will also maintain support for version 6.6. Furthermore, the feature kernel specifically for Android 16 is designated as 6.12. This update to a newer kernel version is significant, as it typically incorporates performance optimizations, introduces new functionalities, and enhances support for a wider range of hardware components. The Android 16 kernel (version 6.12) will also benefit from a substantial support lifetime of four years, extending until July 2029.

Building upon the foundation laid in Android 15, Android 16 further explores the integration of a Linux environment directly on the device. Android 15 introduced an optional Linux session for Pixel devices. It is important to note that this is not a direct portal to the underlying Android kernel but rather a Debian virtual machine operating on top of the Android Virtualization Framework. This provides a sandboxed Linux environment, offering developers access to a familiar command-line interface and the potential to run Linux-based development tools directly on their Android devices. There is anticipation that this feature could become more broadly available on sufficiently robust Android phones with the advent of Android 16.

Historically, major kernel updates for older Android devices have been infrequent. Therefore, the potential update to kernel 6.1 for certain older Pixel devices is a noteworthy development. This suggests a possible shift towards more regular kernel updates for at least some segments of the Android ecosystem.

The adoption of Linux kernel 6.12 in Android 16 underscores Google’s commitment to maintaining an up-to-date core system. This can lead to tangible benefits for developers through improved performance, enhanced power efficiency, and better compatibility with the latest hardware innovation. Developers can potentially leverage new kernel features and more comprehensive driver support for their applications. The introduction of a built-in Linux terminal, even in a virtualized form, marks a significant step towards providing developers with a more familiar and powerful command-line environment directly within Android. This could potentially streamline various development and debugging workflows. The historical infrequency of major kernel updates for older devices highlights the complexities of managing kernel versions across the diverse Android ecosystem. The update mentioned for some older Pixels indicates a potential move towards more frequent kernel updates, at least for Google’s own devices, which could extend their usability and performance.

C/C++ Development in the Android 16 Ecosystem

Android 16 continues to provide strong support for C/C++ development through the well-established Android NDK. The NDK remains a cornerstone for developers who require the performance benefits of native code or need to integrate existing C/C++ libraries into their Android applications. The Java Native Interface (JNI) continues to serve as the bridge, enabling seamless communication between the Java/Kotlin code that typically forms the application’s UI and logic, and the underlying native C/C++ libraries.

Android Studio, the official IDE for Android development, offers comprehensive and integrated support for C/C++ projects. This includes features for creating new projects with native code support, configuring build processes using both CMake and the legacy ndk-build system, and debugging native code using the LLDB debugger. Within Android Studio projects, native source files, headers, and build scripts are typically organized within a dedicated cpp directory, providing a structured approach to native development.

The Android NDK itself is under continuous development, with an active roadmap outlining future enhancements. Key areas of focus include ongoing updates to the Clang compiler and the libc++ standard library, ensuring developers have access to the latest language features and performance improvements. There is also exploration into the use of C++ Modules, a feature designed to improve build times and enhance code organization in large C++ projects. Furthermore, efforts are underway to enhance the documentation and provide more helpful code samples for developers utilizing the NDK.

Android 15 introduced support for 16KB memory pages as a platform-wide optimization aimed at improving performance. Android 16 includes a crucial compatibility mode that allows applications built for the older 4KB page size to continue running on devices configured with 16KB pages. However, developers who utilize native C/C++ code should be aware that to fully leverage the benefits of the 16KB page size and to avoid potential compatibility issues, it might be necessary to rebuild their applications using newer versions of the NDK (specifically r28 or later).

The sustained and robust support for C/C++ through the NDK in Android 16 underscores its enduring importance within the Android development ecosystem for tasks demanding high performance or requiring access to low-level system functionalities. The tight integration of C/C++ development tools within Android Studio significantly enhances the accessibility of native development for a broader range of developers. The platform-level transition to 16KB memory pages, while offering overall performance benefits, necessitates that developers working with native code pay close attention to their build configurations and ensure their code is compatible with this change to achieve optimal performance and prevent potential issues. The ongoing development initiatives outlined in the NDK roadmap, particularly the focus on toolchain updates and the potential introduction of C++ Modules, demonstrate a clear commitment to continually improve the C/C++ development experience on the Android platform and enable the adoption of modern C++ standards.

Rust: A Growing Presence in Android System Development

Rust is increasingly becoming a significant language within Android system development, primarily due to its strong emphasis on memory safety. This characteristic helps to mitigate many of the common security vulnerabilities often associated with languages like C/C++. Rust’s ownership and borrowing system provides memory safety without the overhead of a garbage collector.

A notable development in Android 16 is the introduction of support for running media codecs within the application’s process, as opposed to the traditional sandboxed process. This optimization is designed to reduce CPU usage and improve the efficiency of media playback, particularly for the widely used AAC codec. However, to ensure security, this in-process execution is only permitted for media codecs that are implemented in memory-safe languages such as Rust. While Android 16 provides the underlying support for this feature, its immediate activation depends on vendors rewriting their existing codecs in Rust.

Google has been actively providing resources to aid developers in adopting Rust for Android development. This includes a series of blog posts that offer insights into the rationale behind introducing Rust as a platform language, the process of integrating Rust into the Android Open Source Project (AOSP), and strategies for achieving interoperability between Rust and C++ codebases. Furthermore, the Android NDK roadmap includes the ambitious goal of achieving Tier 1 support for Rust. This would signify a deeper level of integration and more comprehensive support for Rust development within the Android ecosystem.

The mandatory requirement of using a memory-safe language like Rust for in-process media codecs in Android 16 highlights a strong commitment by Google to bolster the security and reliability of fundamental multimedia components. By leveraging Rust’s memory safety features, this move has the potential to contribute to a more secure and stable Android experience for end-users. The reliance on vendors to undertake the task of rewriting codecs in Rust for the in-process feature to become fully functional suggests a gradual and phased adoption of Rust within the Android system. Developers might need to await these vendor-driven updates to fully realize the anticipated performance and efficiency gains. The long-term objective of achieving Tier 1 Rust support within the NDK clearly indicates a strategic direction for the Android platform to embrace Rust as a key language for both system-level and application development. This could potentially attract a wider community of Rust developers to the Android ecosystem and foster the creation of a broader range of memory-safe Android software.

WebAssembly (WASM): Expanding Horizons on the Android Platform

WebAssembly (WASM) is a binary instruction format for a stack-based virtual machine. It enables near-native performance for applications running in web browsers and other environments. Its key advantages include portability, allowing code to run across different platforms, and high performance, approaching that of native code in many scenarios.

The Android NDK team is actively exploring the potential of using WASM as a portable intermediate representation (IR) for compiling native code. This approach could potentially simplify the complexities of cross-platform development and enable optimizations tailored to the specific architecture of the device at the point of installation from the Play Store. However, there are ongoing discussions and considerations surrounding the performance implications and the overall complexity of deeply integrating WASM within the NDK.

Beyond potential NDK integration, WASM runtimes like WasmEdge already exist for Android. These runtimes allow developers to execute WASM modules within their Android applications, including both those built with the NDK and standard APK-based apps. This capability enables the integration of high-performance code written in a variety of languages, such as Rust and C++, into Android projects.

It’s also important to note that Android’s WebView component offers support for WebAssembly. This means that web-based applications running within a WebView on Android devices can already leverage the performance benefits of WASM.

While primarily known for its role in web development, WASM’s potential as a portable execution format is being seriously considered within the Android ecosystem, particularly in the context of the NDK. This could pave the way for novel approaches to building and distributing native Android applications in the future. The current availability of WASM runtimes for Android provides developers with a practical means to incorporate high-performance, cross-language modules into their applications today, even before any potential deeper integration at the NDK level materializes. This opens up exciting possibilities for code reuse and leveraging specialized libraries developed in different programming languages. Furthermore, the existing support for WASM within WebView signifies that web applications running on Android can already benefit from WASM’s performance advantages, potentially blurring the traditional distinctions between native and web-based mobile development.

Developer Insights

Android 16 presents a compelling set of advantages and some potential challenges for developers.

Advantages

Developers gain access to a range of enhanced APIs in Android 16. These include new APIs for camera functionalities, such as precise color temperature and tint adjustments for professional video recording and hybrid auto-exposure modes in Camera2. Connectivity is improved with robust security features for Wi-Fi location using Wi-Fi 6 802.11az and new generic ranging APIs. For user interface development, there are new APIs for richer haptics, allowing more control over amplitude and frequency , and progress-centric notifications for tracking user journeys. Media capabilities are expanded with the Advanced Professional Video (APV) codec and improvements to the photo picker, including embedded picker and cloud search. Graphics development benefits from custom graphical effects with AGSL. Accessibility is enhanced with improved APIs for UI semantics and support for supplemental descriptions.

Android 16 also brings several performance improvements. The Android Runtime (ART) receives internal updates for better performance and support for additional Java features. JobScheduler quota optimizations aim to improve battery life and app responsiveness. The introduction of 16KB page size compatibility mode helps apps transition to the optimized memory management introduced in Android 15. There are also optimizations for fixed-rate work scheduling for apps targeting Android 16 or higher.

Security features are a key focus in Android 16. These include improved security against Intent redirection attacks , MediaStore version lockdown for apps targeting Android 16 or higher, and safer Intents with security improvements in intent resolution. The introduction of a Key sharing API allows sharing access to Android Keystore keys with other apps. Enhanced Wi-Fi location security with Wi-Fi 6 802.11az provides better protection against Man-in-the-Middle (MITM) attacks. For apps targeting Android 16, a permission declaration will be required to access the local network.

Developers also benefit from modern development tools and enhanced observability features. System-triggered profiling in ProfilingManager allows capturing traces for critical events like cold starts and ANRs. The getStartComponent() method in ApplicationStartInfo helps optimize app startup flows. Better job introspection APIs in JobScheduler provide insights into pending background jobs. Headroom APIs in ADPF offer estimates of available CPU and GPU resources for performance optimization. Adaptive refresh rate APIs simplify leveraging ARR for power efficiency.

Disadvantages

Developers might encounter potential compatibility hurdles with Android 16. Apps targeting Android 16 will have to adapt to the removal of the edge-to-edge opt-out, requiring them to handle window insets. The migration or opt-out for predictive back gestures will be mandatory for targeting Android 16. Orientation, resizability, and aspect ratio restrictions will be ignored on large screen devices for apps targeting Android 16 or higher, necessitating more adaptive layouts. The deprecation of disruptive accessibility announcements might require developers to use alternative approaches.

The increased number of features and APIs might lead to increased system complexity. The more granular health and fitness permissions for apps targeting Android 16 or higher could require adjustments in permission handling. The introduction of new concepts like virtual device owner overrides adds another layer of complexity for certain types of applications.

Android 16 also involves feature deprecations. Disruptive accessibility announcements using announceForAccessibility are deprecated. The elegantTextHeight attribute is deprecated and will be ignored for apps targeting Android 16. The setImportantWhileForeground for jobs is now a no-op.

Developers might face early adoption challenges when working with the initial beta versions of Android 16. Compatibility issues with existing libraries and SDKs might arise. The accelerated release schedule might compress the timeline for annual compatibility testing.

The push towards edge-to-edge display and adaptive layouts for large screens signifies a move towards a more consistent and modern UI paradigm across different Android devices, but necessitates significant UI/UX adjustments for apps not yet adapted. While new features offer enhanced capabilities, the deprecation of older APIs and the increased granularity of permissions could lead to a period of transition and potential rework for existing applications. The early release and platform stability milestones are crucial for developers to proactively address compatibility issues and leverage new features, highlighting the importance of engaging with the beta program.

The End-User Experience: What Android 16 Brings to the Table

Android 16 promises a range of enhancements for end-users, alongside some potential drawbacks.

Benefits

Users can anticipate user interface enhancements in Android 16, potentially including a sharper overall look. Specific UI changes include themed clock colors on the Always-on Display, the return of the dedicated Do Not Disturb shortcut, and the removal of the “Beta” badge from themed icons. User expectations also include potential lock screen customization, improved animations, and a more consistent design across Google’s first-party applications.

Performance and efficiency gains are also expected. JobScheduler optimizations could lead to improved battery life and smoother app performance. The underlying kernel updates are also likely to contribute to better overall system performance. The cloud compilation feature has the potential to significantly speed up app installation times.

Android 16 emphasizes advanced security and privacy. The enhanced Wi-Fi location security with Wi-Fi 6 802.11az offers improved protection against MITM attacks. Furthermore, apps targeting Android 16 will now pre-select app-owned photos and videos in the photo picker, giving users more control over future app access.

End-users will benefit from exciting new functionalities. Live Updates will provide real-time information for ongoing activities like navigation and deliveries directly on the status bar and lock screen. The Advanced Professional Video codec will enable higher-quality video recording and post-production capabilities. UltraHDR image enhancements will result in photos with a wider dynamic range and more vibrant colors. Improved accessibility features include text outlines for better readability and ambient volume controls for LE Audio hearing aids. For users of languages that use vertical writing systems, Android 16 introduces foundational vertical text rendering support. Additionally, the ability to record the content displayed on an external monitor is a new and useful feature.

Drawbacks

As with any major OS update, Android 16 might come with potential system requirements that could leave older devices unable to upgrade. Users participating in the beta program, and even those who upgrade to the initial stable release, might encounter potential bugs and instability. Furthermore, changes to familiar features or user interface elements could be disruptive or less intuitive for some users. For instance, the temporary absence of the “Screen-off Fingerprint Unlock” toggle in a beta release, even though the functionality remained, could cause confusion.

The focus on features like Live Updates and improved media capabilities indicates a continued drive towards enhancing user engagement and multimedia experiences on Android. While new security features are beneficial, they might also require users to adapt to new permission models and potentially face temporary inconveniences if features are buggy in early releases. User expectations for features like enhanced customization and AI integration suggest areas where future Android releases could further improve the end-user experience.

Monitoring and Observability: Gaining Deeper Insights into Your Applications

Android 16 introduces several new features and APIs specifically designed to enhance monitoring and observability for developers.

New Monitoring Features and APIs in Android 16

System-triggered profiling is a significant addition to the ProfilingManager. This allows applications to register their interest in specific system-level events, such as cold starts (reportFullyDrawn) and Application Not Responding (ANR) errors. When these triggers occur, the system can automatically initiate and record a performance trace on behalf of the application, providing valuable data for identifying performance bottlenecks without requiring manual intervention.

The ApplicationStartInfo API is enhanced with the getStartComponent() method. This new functionality enables developers to pinpoint the specific component within their application that initiated the startup process. This detailed information can be instrumental in optimizing the application’s startup flow and reducing launch times.

Android 16 brings improvements to job introspection within the JobScheduler. The new getPendingJobReasons(int jobId) API returns a comprehensive list of reasons why a particular background job might be in a pending state, taking into account both explicit constraints set by the developer and implicit constraints imposed by the system. Additionally, JobScheduler#getPendingJobReasonsHistory(int jobId) provides a history of recent changes to the reasons for a job being pending. These APIs offer developers better visibility into the scheduling of their background tasks, aiding in debugging and optimization.

The SystemHealthManager in Android 16 introduces headroom APIs in the Android Dynamic Performance Framework (ADPF). Specifically, getCpuHeadroom and getGpuHeadroom APIs provide estimates of the available CPU and GPU resources on the device. This information is particularly valuable for games and other resource-intensive applications, allowing them to dynamically adjust their resource usage to potentially improve performance and avoid thermal throttling.

Finally, Android 16 includes new and restored adaptive refresh rate (ARR) APIs. The hasArrSupport() and getSuggestedFrameRate(int) APIs, along with the restored getSupportedRefreshRates(), simplify how applications can leverage adaptive refresh rates on supported hardware. This can lead to significant power savings by allowing the display refresh rate to match the content’s frame rate.

Advanced Observability Techniques for Performance Optimization and Issue Resolution

These new monitoring features in Android 16 provide developers with powerful tools to gain deeper insights into their applications. System-triggered profiling can be used to automatically capture performance data during critical phases like cold starts, allowing developers to identify and address bottlenecks that impact the initial user experience. The ability to pinpoint the starting component of an application can guide targeted optimization efforts to streamline the launch process. The enhanced job introspection APIs provide the necessary visibility to understand why background tasks might not be executing as expected, enabling developers to optimize their scheduling and improve battery life. Resource headroom APIs empower developers of demanding applications to make informed decisions about resource allocation, potentially leading to smoother performance and better thermal management. Leveraging the adaptive refresh rate APIs can contribute to a more efficient use of device power.

Developers can effectively utilize these new APIs in conjunction with Android Studio’s integrated profiling tools for a more comprehensive analysis of their application’s performance. Furthermore, exploring third-party observability solutions like Grafana can provide valuable insights into application performance trends over time through data visualization and analysis. Tools like Instabug can complement these technical insights by providing user feedback and bug reports directly from production environments.

The new monitoring and observability features in Android 16 demonstrate a strong focus on empowering developers with better tools to understand and optimize their applications’ performance and resource usage. The system-triggered profiling capability addresses a key limitation of previous profiling tools by allowing developers to capture critical app lifecycle events that were previously difficult to monitor. The introduction of headroom APIs in ADPF suggests a growing emphasis on optimizing the performance of demanding applications like games, potentially leading to smoother user experiences and better battery life on high-performance devices.

Conclusion: Embracing the Future of Android with Version 16

Android 16 represents a significant step forward in the evolution of the Android platform, introducing a wealth of technical innovations and refinements. For software entrepreneurs with a keen interest in the underlying technologies, this release offers exciting new capabilities and areas to explore, from the updated Linux kernel to the continued advancements in C/C++, the growing adoption of Rust, and the ongoing exploration of WebAssembly.

Developers will benefit from a rich set of enhanced APIs, performance improvements, robust security features, and modern monitoring tools that provide deeper insights into their applications. However, they must also be prepared to address potential compatibility hurdles, navigate increased system complexity, and adapt to feature deprecations. Early engagement with the beta program and continuous testing will be crucial for a smooth transition.

End-users can look forward to a more refined user interface, enhanced performance and efficiency, stronger security and privacy protections, and exciting new functionalities like Live Updates and improved media capabilities. While potential system requirements and initial bugs are factors to consider, the overall direction of Android 16 points towards a more capable and user-friendly mobile experience.

As the Android platform continues to evolve with version 16, it presents significant opportunities for innovation and growth within the mobile ecosystem. Software entrepreneurs who embrace these changes and proactively adapt to the new landscape will be well-positioned to leverage the power of Android and deliver cutting-edge experiences to their users.

Table 1: Android 16 Release Timeline

MilestoneExpected Date/StatusKey Focus
Developer Preview 1November 2024Early baseline build, developer feedback on APIs
Developer Preview 2December 2024Incremental update with more features and API changes
Beta 1January 2025Initial beta-quality release, broader testing
Beta 2February 2025Further feature refinement and stability improvements
Beta 3 (Platform Stability)March 2025Final APIs and app-facing behaviors locked
Beta 4April 2025Final major beta version, bug fixes
Stable ReleaseJune 2025 (Expected)Public rollout of the final version

Table 2: Key Monitoring and Observability Features in Android 16

Feature NameDescriptionBenefit for Developers
System-triggered profilingAllows apps to register for system-level triggers (e.g., cold starts, ANRs) to automatically record traces.Enables easier identification of performance bottlenecks during critical app lifecycle events without manual intervention.
Start component in ApplicationStartInfoProvides the specific component type that triggered an app start.Helps optimize app startup flows by identifying the initiating component.
Better job introspectionNew APIs in JobScheduler provide detailed reasons for pending background jobs and their history.Aids in debugging and optimizing background task scheduling, leading to improved battery life and app responsiveness.
Headroom APIs in ADPFgetCpuHeadroom and getGpuHeadroom APIs estimate available CPU and GPU resources.Allows resource-intensive apps (e.g., games) to dynamically adjust resource usage, potentially improving performance and reducing thermal throttling.
Adaptive refresh rate APIsNew and restored APIs simplify leveraging adaptive refresh rates.Enables apps to better align rendering with the display’s refresh rate, reducing power consumption and improving visual smoothness.
References

https://www.androidpolice.com/android-16-beta-4-released/#:~:text=The%20official%20word%20is%20simply,I%2FO%202025%20in%20May.

https://developer.android.com/about/versions/16

Android 16 Release Date, Upcoming Features, Changes, Requirements, Schedules, Latest Leaks And More, Everything You Need To Know | Times Now

Android 16: A Technical Preview for Software Developers Read More »

Google’s Initiatives to Restrict Energy-Hungry Android Applications

1. Introduction

The proliferation of mobile devices has made energy efficiency a paramount concern for users and platform providers alike. In the Android ecosystem, where a vast array of applications compete for device resources, the impact of energy-intensive applications on battery life is a significant factor influencing user satisfaction. An entrepreneur with expertise spanning eBPF, Android internals, Linux Kernel, C/C++, Rust, and WASM is uniquely positioned to understand and potentially contribute to this evolving landscape. Recent initiatives by Google to restrict applications that excessively consume energy underscore the platform’s commitment to improving the overall user experience by addressing battery drain issues. This report aims to provide a comprehensive analysis of these initiatives, their technical underpinnings, implications for various development approaches, and the resulting entrepreneurial opportunities and challenges.

The increasing demand from users for extended battery life is a fundamental driving force behind Google’s recent actions. Users consistently prioritize battery performance as a critical aspect of their smartphone experience, and dissatisfaction in this area can lead to negative feedback and app abandonment. As the custodian of the Android platform, Google has a strong incentive to ensure a positive and efficient user experience across its ecosystem. Furthermore, Google’s recent focus on restricting energy-hungry applications may signal a move towards stricter enforcement of energy efficiency standards within the Play Store. By introducing metrics like “excessive wake locks” and potentially others in the future, Google is providing developers with tangible indicators of energy inefficiency. Repeated failure to address these issues could potentially impact an application’s discoverability and erode user trust in the long term. This proactive approach suggests a broader strategy to curate the Android app ecosystem towards better resource management.

2. Google’s Initiatives to Combat Energy-Hungry Apps

Recent information from the Android developer community highlights Google’s proactive stance against Android applications that exhibit excessive energy consumption. A notable initiative is the introduction of a new metric within the Google Play Console beta, specifically targeting “excessive wake locks”. Wake locks are system-level mechanisms that prevent a device from entering an idle, low-power state. While some applications legitimately require wake locks for essential functions like playing music or tracking location, their improper or prolonged use, particularly in the background, can significantly deplete a device’s battery.

The newly introduced metric in the Play Console flags applications that hold wake locks for more than three hours within a 24-hour period, specifically when the application is running in the background and does not have an active foreground service. Google has identified excessive background wake lock usage as a major source of complaints from Android users regarding battery drain. By providing this new tool, Google aims to empower developers with a clearer method to identify and rectify these issues before they negatively impact a substantial number of users. While one referenced news article was inaccessible, the information available suggests a clear intention from Google to improve the overall Android user experience by actively addressing battery drain caused by poorly behaving applications. This focus on providing developers with actionable metrics indicates a platform-level commitment to energy efficiency.

Google’s emphasis on wake locks as an initial target suggests that this particular behavior is considered a significant and readily quantifiable contributor to unnecessary energy drain. Wake locks directly interfere with the device’s ability to enter power-saving modes, leading to continuous activity of the CPU and potentially other hardware components. Monitoring the duration for which applications hold these locks offers a straightforward method for identifying applications that are preventing the device from idling when it should. The integration of this metric into the Play Console points towards a data-driven approach to enforcing battery efficiency standards. By providing developers with concrete data on their application’s wake lock usage, Google is establishing a benchmark for acceptable behavior. This data can also be leveraged by Google internally to identify applications that are significantly impacting device battery life across the platform. It is plausible that this initiative targeting wake locks represents an initial step in a broader strategy to monitor and potentially restrict other aspects of energy consumption by Android applications in the future. Google might expand its monitoring to encompass other factors such as excessive CPU usage, network activity when in the background, and prolonged use of sensors like GPS, further tightening the platform’s grip on energy efficiency.

3. Technical Underpinnings: How Android Identifies Energy Consumption

Android employs a multifaceted approach to identify applications that consume excessive energy, providing various tools and APIs for both system-level monitoring and developer-driven analysis. Android Studio includes a Power Profiler, a tool designed to visually represent power consumption on connected devices. Introduced in Android Studio Hedgehog, this profiler features the On Device Power Rails Monitor (ODPM), which segments power consumption data by hardware subsystems known as “Power Rails”. These power rails include components like the CPU (divided into Big, Little, and Mid cores), GPU, memory, cellular, display, GPS, and Wi-Fi, among others. The Power Profiler allows developers to correlate the power consumption of these individual components with the actions occurring within their application, both in the foreground and background. This capability is particularly useful for scenarios like optimizing network requests or comparing the power efficiency of different implementations of the same feature. It’s important to note that ODPM measures power consumption at the device level, not specifically for any single application, requiring developers to correlate this data with their app’s behavior. The ODPM feature is available on Pixel 6 and later Pixel devices running Android 10 (API level 29) and higher. The Power Profiler can also be utilized for A/B testing different features or implementations to determine which consumes less power.

Another crucial tool in Android’s energy monitoring arsenal is Battery Historian. This tool provides a comprehensive view of a device’s battery consumption over time, visualizing power-related events from system logs in an HTML format. Battery Historian offers both a system-wide perspective and an app-specific view, enabling developers to pinpoint battery-draining behaviors within their own applications. The tool can reveal data such as an application’s estimated power usage, network information, wake lock usage, active services, and process information. By examining the timeline of events, developers can identify patterns like overly frequent wakeup alarms, continuous GPS usage, or excessive scheduling of jobs and syncs. The data for Battery Historian is collected using the adb shell dumpsys batterystats command, which dumps raw battery data from the device to the development machine. Battery Historian itself can be installed and run using Docker.

The Android framework also provides the BatteryManager API, which allows applications to programmatically query the device for various battery-related information. This API enables developers to retrieve details such as the current battery level, charging status, and voltage. Notably, it also provides access to the BATTERY_PROPERTY_CURRENT_NOW property, which indicates the current draw of the battery in microamps. In Android 14, new APIs were introduced within the BatteryManager class to access battery health information, including the charging cycle count, charging status, battery manufacture date, and estimated battery health percentage. However, accessing some of this detailed information, such as the battery health statistics, may require specific permissions like BATTERY_STATS, which has a protection level that typically requires either system privileges or manual granting via ADB.

Beyond these primary tools and APIs, Android utilizes the Batterystats tool directly to collect raw battery data on the device. Hardware-based power measurement tools can also be employed for more precise energy consumption analysis, often involving specialized equipment connected to the device. Furthermore, third-party applications like AccuBattery and Wakelock Detector have emerged within the Android ecosystem to provide users and developers with additional insights into battery usage and potential drain sources.

Android’s comprehensive system for monitoring energy consumption, spanning from low-level kernel statistics to developer-centric profiling tools, enables both platform-level optimizations by Google and detailed analysis by individual application developers. The increasing sophistication of tools like the On Device Power Rails Monitor, which provides a breakdown of power usage by specific hardware subsystems, signifies a growing emphasis on granular energy consumption analysis. By allowing developers to examine the power usage of individual components, they can more accurately identify the elements within their applications that contribute most significantly to battery drain and implement targeted optimizations. The introduction of battery health APIs in Android 14 hints at a potential future where the operating system might leverage this information to further refine its management of application behavior and offer more detailed feedback to users regarding battery usage patterns and overall device health.

4. Impact on Native Applications: C/C++ and Rust

Applications developed using native languages like C/C++ and Rust can achieve high performance, making them suitable for tasks that demand significant computational resources, such as gaming and simulations. However, these applications also carry the potential for inefficient resource management if not carefully developed, which can lead to increased energy consumption. In native code, developers bear a greater responsibility for memory management, and inefficient practices can result in higher CPU utilization and consequently, greater battery drain. Furthermore, while the Android NDK allows the use of C/C++ code, it does not provide access to the entirety of the Android framework APIs, potentially limiting the ability to leverage certain power-saving features directly.

Android has been increasingly adopting Rust as a memory-safe alternative to C/C++ within the platform itself. Rust’s design principles prioritize memory safety without compromising performance, aligning well with the goals of both security and energy efficiency. This trend might indirectly encourage developers to consider Rust for performance-critical and battery-sensitive components of their applications. However, regardless of the native language used, applications with intensive tasks or background processing will be subject to Android’s energy restrictions, including those imposed by App Standby Buckets. These buckets categorize applications based on their usage frequency, with less frequently used apps facing stricter limitations on background execution, jobs, alarms, and network access. This means that native applications performing heavy computations or data synchronization in the background might be significantly impacted if the user does not regularly interact with them.

A significant challenge for native applications, particularly those relying on background services, is the variability in battery optimization strategies implemented by different Android device manufacturers. Devices with heavily customized ROMs may have aggressive power-saving measures that can prematurely terminate background services, even those using mechanisms like START_STICKY or WorkManager. This fragmentation of the Android ecosystem necessitates careful consideration and potentially device-specific workarounds for developers aiming for consistent background execution behavior.

To mitigate the impact of energy restrictions, developers of native Android applications should prioritize efficient algorithm design, careful management of threads and background tasks, optimized data structures and memory allocation, and the judicious use of wake locks only when absolutely necessary. Leveraging Android’s scheduling mechanisms like WorkManager is crucial for deferrable background tasks, allowing the system to optimize their execution based on factors like network connectivity and charging status. Ultimately, developers must carefully balance the performance benefits of native code with the need to minimize energy consumption to ensure a positive user experience and avoid potential restrictions imposed by the platform.

Table 1: App Standby Buckets and Restrictions

Bucket NameRestrictions on JobsRestrictions on AlarmsRestrictions on Network AccessRestrictions on High-Priority FCM Messages
ActiveNo restrictionNo restrictionNo restrictionNo restriction
Working SetLimited to 10 minutes every 3 hoursLimited to 1 per hourLimited to 10 min/3 hoursHigh priority: 5/day
FrequentLimited to 10 minutes every 6 hoursLimited to 1 per hourLimited to 10 min/6 hoursHigh priority: 2/day
RareLimited to 10 minutes every 24 hoursLimited to 1 per hourDisabledHigh priority: 1/day
RestrictedOnce per dayOne alarm per day, either an exact or inexact alarmDisabledHigh priority: 5/day

Note: Restrictions may vary slightly across Android versions.

5. The Role of the Linux Kernel in Power Management

The Android operating system’s power management framework is built upon the foundation of the Linux kernel, with Google introducing its own specialized power management system tailored for the unique demands of mobile devices. While Android leverages the core power management capabilities of the Linux kernel, it implements additional layers and mechanisms to achieve aggressive power saving, recognizing the critical importance of battery life in the mobile context.

A central concept in Android’s power management is the use of wake locks. These are requests from applications and services to keep the CPU or other system resources active. The Android power management architecture mandates that applications request CPU resources using wake locks through the Application Framework and native Linux libraries If no active wake locks are held, Android will aggressively shut down the CPU to conserve power. Different types of wake locks cater to varying application needs, including PARTIAL_WAKE_LOCK (CPU on, screen/keyboard off), SCREEN_DIM_WAKE_LOCK, SCREEN_BRIGHT_WAKE_LOCK, and FULL_WAKE_LOCK (CPU, screen, and keyboard all on). The Application Framework layer provides a dedicated Power Management (PM) API that applications interact with to acquire and release wake locks, with these requests ultimately being communicated to the power driver within the Linux kernel.

Android’s power management policies are generally more aggressive in saving power compared to the typical focus on performance in standard Linux kernel configurations. The kernel itself includes platform drivers responsible for low-level suspend and resume operations required by specific hardware. Android also incorporates features like “early suspend,” a kernel-level mechanism that allows certain drivers to perform actions just before the system enters a low-power state. The Android Common Kernel (ACK) represents a set of kernel branches maintained by Google that are downstream of kernel.org and include patches of interest to the Android community, often incorporating power management enhancements.

Google’s initiatives to restrict energy-hungry applications are intrinsically linked to these underlying kernel-level power management features. The “excessive wake locks” metric directly targets the kernel’s wake lock mechanism, identifying applications that hold these locks for prolonged periods. It is likely that other restrictions implemented by Google leverage the kernel’s ability to control CPU frequency scaling, manage network interface states, and regulate access to sensors, all in the interest of optimizing battery life. Understanding the intricate relationship between the Android framework and the Linux kernel’s power management is therefore essential for developers, particularly those working with native code, who aim to create truly energy-efficient applications. They must be cognizant of how their application’s actions at the framework level translate into resource requests at the kernel level and how these requests are managed by the operating system’s power management policies.

Table 2: Types of Wake Locks

Wake Lock SettingImpact on CPUImpact on ScreenImpact on KeyboardTypical Use Case
PARTIAL_WAKE_LOCKOnOffOffBackground tasks not requiring user interaction
SCREEN_DIM_WAKE_LOCKOnDimmedOffDownloading data while dimming the screen
SCREEN_BRIGHT_WAKE_LOCKOnBrightOffShowing a video or actively using the screen
FULL_WAKE_LOCKOnBrightBrightRarely used, keeps all components active

6. WebAssembly (WASM) on Android: Navigating Energy Restrictions

WebAssembly (WASM) has emerged as a compelling technology for enhancing the performance of web applications, and its use on Android platforms presents both opportunities and challenges in the context of energy restrictions. Studies have indicated that WASM can offer better performance and potentially lower energy consumption compared to JavaScript for certain computationally intensive workloads. Faster execution times can translate to reduced overall CPU usage, which in turn can lead to lower battery drain.

However, applications utilizing WASM on Android will still be subject to the platform’s energy management policies. If a WASM application running within a web browser engages in excessive background processing, holds wake locks for extended periods, or exhibits high network activity while in the background, it could face the same restrictions as any other web application on the platform. The Android operating system primarily manages resources at the application level, meaning that WASM code running within a browser tab is subject to the same limitations as the browser application itself. This includes restrictions imposed by App Standby Buckets based on the user’s interaction with the browser.

For scenarios where WASM modules are integrated directly into native Android applications using JIT runtimes, developers will need to carefully consider how the WASM runtime interacts with Android’s power management features. The native code embedding the WASM engine will be responsible for managing system resources such as wake locks and background task scheduling. Ensuring responsible resource usage from the native layer will be crucial to avoid triggering energy restrictions. The sandboxed nature of WASM might present unique considerations for energy monitoring, as the operating system may need to account for the resource usage within the WASM runtime environment. Furthermore, it’s important to acknowledge that battery restrictions on Android can vary depending on the specific device and the customizations implemented by the device manufacturer.

Despite these considerations, WASM’s potential for improved performance could be advantageous in the context of energy restrictions. By executing certain tasks more efficiently than JavaScript, WASM applications might be able to complete their work more quickly and return the device to a low-power state sooner, potentially helping them remain within acceptable energy consumption limits. Developers considering WASM for their Android applications should therefore focus on leveraging its performance benefits to minimize overall resource usage and adhere to Android’s guidelines for background processing and wake lock management.

7. Developer Perspectives and Challenges

The Android developer community generally acknowledges the importance of optimizing applications for battery efficiency and has been actively discussing the implications of Google’s energy-saving initiatives. A common concern revolves around the potential impact of stricter restrictions on the functionality of applications that legitimately require background processing or continuous location tracking. Developers of fitness trackers, messaging applications, and location-based services, for instance, often rely on background tasks to deliver core features and are seeking guidance on how to balance functionality with the need for energy conservation.

Discussions within the community frequently address the use of foreground services as a mechanism to perform essential background work while keeping the user informed through notifications. However, there is an understanding that foreground services can be resource-intensive and should be used judiciously, with clear justification for their necessity. Developers are also sharing best practices for optimizing battery usage, such as scheduling tasks efficiently using WorkManager, minimizing network calls, and avoiding unnecessary wake locks.

The introduction of Android Vitals metrics in the Google Play Console, which highlight battery usage issues, has been met with both appreciation for the transparency and concern about the increased pressure to meet certain energy efficiency standards for application success. Developers are now more aware of how their applications are performing in terms of battery consumption and are looking for strategies to address any issues identified. However, the community also voices challenges related to inconsistencies in battery optimization behavior across different Android versions and devices, particularly those with heavily customized ROMs from various manufacturers. Applications might exhibit different background execution patterns on stock Android compared to devices from manufacturers like Xiaomi or Huawei, making it difficult for developers to optimize effectively for the entire ecosystem.

Some developers have reported specific issues related to battery drain caused by certain third-party SDKs or unexpected behavior within their own application code, prompting discussions on debugging and identifying the root causes of excessive energy consumption. Overall, while there is a general agreement on the importance of battery optimization, the Android developer community is navigating the complexities of balancing application functionality with stricter energy efficiency requirements, seeking clearer guidelines and more consistent platform behavior to ensure a predictable and positive user experience across the diverse Android landscape.

8. Entrepreneurial Landscape: Opportunities and Challenges

The increasing emphasis on energy efficiency in the Android ecosystem presents a range of entrepreneurial opportunities for individuals with expertise in areas such as eBPF, Android internals, native development (C/C++, Rust), and WASM. One promising avenue involves developing specialized tools or libraries that leverage the power of eBPF for fine-grained, system-level power usage analysis and optimization. eBPF’s ability to perform in-kernel analysis with minimal overhead could enable the creation of advanced monitoring tools that provide deeper insights into power consumption than standard Android APIs.

Another opportunity lies in creating specialized SDKs or components using Rust that offer high performance coupled with improved energy efficiency for specific use cases, such as data processing, graphics rendering, or cryptographic operations Given Rust’s focus on memory safety and performance, such components could be highly valuable for developers looking to optimize critical parts of their applications. Building advanced battery monitoring and analysis tools specifically for developers could also be a viable venture. These tools could potentially integrate with existing IDEs or CI/CD pipelines, providing developers with continuous feedback on the energy impact of their code changes. Consulting services focused on helping companies optimize their Android applications for energy efficiency, leveraging deep expertise in native development and Android internals, could also be in high demand.

Furthermore, the potential of WASM for delivering better performance and battery life for web-based applications on Android opens up opportunities for developing innovative solutions in this space. Creating tools that help developers navigate the complexities of background task scheduling and battery optimization across different Android versions and OEM customizations represents another potential area for entrepreneurial endeavors. Finally, developing battery saver applications with advanced features, potentially utilizing eBPF for more intelligent power management strategies, could also find a market.

However, this landscape also presents several challenges. The Android power management system is intricate, requiring deep technical expertise to navigate effectively. The Android platform is constantly evolving, with new features and restrictions being introduced regularly, necessitating continuous learning and adaptation. Accessing low-level system information or directly controlling device behavior might be limited due to Android’s security model. New tools and technologies will need to differentiate themselves from existing Android profiling tools and battery saver applications to gain traction. Convincing developers or businesses to adopt new tools or integrate new technologies into their development workflows can also be a significant hurdle. Despite these challenges, the increasing focus on energy efficiency in Android creates a significant opportunity for innovative solutions that can help developers build better, more power-efficient applications.

9. Conclusion

Google’s recent initiatives to restrict energy-hungry Android applications underscore a growing platform-level commitment to improving battery life and overall user experience. The introduction of metrics like “excessive wake locks” in the Play Console signals a move towards data-driven enforcement of energy efficiency. These changes will undoubtedly impact Android app development, particularly for applications that rely heavily on background processing and continuous resource utilization. Developers will need to be more mindful of their applications’ energy footprint and proactively optimize their code to adhere to these evolving standards.

For entrepreneurs with expertise in areas like eBPF, native development, and Android internals, this shift presents significant opportunities. The need for specialized tools, libraries, and consulting services to help developers navigate the complexities of Android’s power management system and build more energy-efficient applications is likely to grow. Technologies like eBPF and Rust offer the potential for developing innovative solutions that go beyond the capabilities of standard Android APIs. While challenges such as platform complexity, fragmentation, and the need for differentiation exist, the increasing focus on energy efficiency in the Android ecosystem creates a fertile ground for innovation and entrepreneurial endeavors in this space. The future of Android app development will likely be shaped by a greater emphasis on resource optimization, and those with the right technical skills and entrepreneurial vision are well-positioned to contribute to and benefit from this evolution.

10. References

https://www.androidauthority.com/google-play-console-wake-metric-3545099

https://developer.android.com/about/versions/pie/power

https://developer.android.com/studio/profile/power-profiler

Google declares war on excessively energy-consuming Android apps | heise online

Android is getting smarter about spotting battery-hungry apps

https://developer.android.com/topic/performance/power/battery-historian

https://blog.scottlogic.com/2024/05/01/measuring-android-energy-use.html

https://www.kernel.org/doc/ols/2012/ols2012-mansoor.pdf

Google’s Initiatives to Restrict Energy-Hungry Android Applications Read More »