自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
Android 性能优化
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
请按照本部分中的说明操作,以确保您的 Android 设备能够最大限度地减少资源消耗并优化性能。您可以使用评估性能中所述的多种测试和工具来充分利用 Android。
APK 缓存
本文档介绍了如何设计 APK 缓存解决方案,以在支持 A/B 分区的设备上快速安装预加载的应用。OEM 可以将预加载应用和热门应用放置在 APK 缓存中(对于采用 A/B 分区的新设备而言,这种缓存会存储在通常为空的 B 分区中),而且这样不会影响面向用户的任何数据空间。
启动时间
Android 8.0 支持一系列组件的多项改进,因而可以缩短启动时间。本文档提供了有关缩短特定 Android 设备的启动时间的合作伙伴指南。
运行状况
Android 9 引入了从 health@1.0 HAL 升级的主要版本 android.hardware.health
HAL 2.0。这一新版 HAL 使框架代码和供应商代码之间的区别更加清楚,供应商对运行状况信息报告进行自定义的自由度更高,并提供了更多设备运行状况信息(不仅包括电池信息)。
lowmemorykiller
用户空间 lmkd
进程可实现相同的功能,但它是通过现有的内核机制来检测和估测内存压力。该进程使用内核生成的 vmpressure 事件来获取关于内存压力级别的通知。
配置文件引导的优化
Android 编译系统支持在具有蓝图编译规则的原生 Android 模块上使用 Clang 的配置文件引导优化 (PGO)。
任务快照
任务快照是在 Android O 中引入的基础架构,可将窗口管理器中的最近任务缩略图和已保存 Surface 这两者的屏幕截图进行合并。最近任务缩略图会在“最近”视图中呈现任务的最后状态。
预写式日志记录
Android 9 引入了 SQLiteDatabase 的一种特殊模式,称为“兼容性 WAL(预写日志记录)”,它允许数据库使用 journal_mode=WAL
,同时保留每个数据库最多创建一个连接的行为。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-26。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-03-26。"],[],[],null,["# Android performance optimization\n\nFollow the instructions in this section to ensure your Android devices\nminimize resource use and optimize performance. And take advantage of the many\ntests and tools described in\n[Evaluating Performance](/docs/core/tests/debug/eval_perf) as part of\nyour work getting the most out of Android.\n\nAPK caching\n-----------\n\nThis document describes design of an APK caching solution for rapid installation\nof preloaded apps on a device that supports A/B partitions. OEMs can place\npreloads and popular apps in the APK cache stored in the mostly empty B\npartition on new A/B-partitioned devices without impacting any user-facing data\nspace.\n\nBoot times\n----------\n\nAndroid 8.0 allows for reduced boot times by supporting several improvements\nacross a range of components. This document provides partner guidance for\nimproving boot times for specific Android devices.\n\nHealth\n------\n\nAndroid 9 includes `android.hardware.health` HAL 2.0, a major version upgrade\nfrom health@1.0 HAL. This new HAL offers cleaner separation between framework\nand vendor code, greater degrees of freedom for vendor customization in health\ninformation reports, and more device health information than just battery.\n\nlowmemorykiller\n---------------\n\nThe userspace `lmkd` process implements the same functionality but with already\nexisting kernel mechanisms to detect and estimate memory pressure. It uses\nvmpressure events generated by the kernel to get notifications about memory\npressure levels.\n\nProfile-guided optimization\n---------------------------\n\nThe Android build system supports using Clang's profile-guided optimization\n(PGO) on native Android modules that have blueprint build rules.\n\nTask Snapshots\n--------------\n\nTask Snapshots is infrastructure introduced in Android O that combines\nscreenshots for Recents Thumbnails as well as Saved Surfaces from Window\nManager. Recents Thumbnails represent the last state of a task in the Recents\nview.\n\nWrite-ahead logging\n-------------------\n\nAndroid 9 introduces a special mode of SQLiteDatabase called Compatibility WAL\n(write-ahead logging) that allows a database to use `journal_mode=WAL` while\npreserving the behavior of keeping a maximum of one connection per database."]]