自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
Android 效能最佳化
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
請按照本節中的說明操作,確保 Android 裝置能盡量減少資源用量並提升效能。並善用「評估效能」一文中所述的多項測試和工具,充分發揮 Android 的效益。
APK 快取
本文說明 APK 快取解決方案的設計,可在支援 A/B 分區的裝置上快速安裝預先載入的應用程式。原始設備製造商 (OEM) 可將預先載入內容和熱門應用程式放入新 A/B 分割裝置上空白的 B 分割區中儲存的 APK 快取,而不影響任何面向使用者的資料空間。
啟動時間
Android 8.0 支援多項元件的多項改善功能,可縮短啟動時間。本文件提供合作夥伴指南,說明如何改善特定 Android 裝置的啟動時間。
健康度
Android 9 包含 android.hardware.health
HAL 2.0,這是從 health@1.0 HAL 升級而來的重大版本。這個新的 HAL 可讓架構和供應商程式碼之間的區隔更清楚,讓供應商在健康資訊報告中自訂的自由度更高,並提供更多裝置健康資訊 (不只限於電池)。
lowmemorykiller
使用者空間 lmkd
程序會實作相同的功能,但已使用現有的核心機制來偵測及估算記憶體壓力。它會使用核心產生的 vmpressure 事件,取得有關記憶體壓力程度的通知。
設定檔引導最佳化
Android 建構系統支援在具有藍圖建構規則的原生 Android 模組上使用 Clang 的設定檔導向最佳化 (PGO)。
工作快照
工作快照是 Android O 中推出的基礎架構,可結合近期縮圖的螢幕截圖,以及 Window Manager 的已儲存表面。「近期」縮圖代表「近期」檢視畫面中工作項目的最後狀態。
預先寫入記錄
Android 9 推出了名為 Compatibility WAL (預先寫入記錄) 的 SQLiteDatabase 特殊模式,可讓資料庫使用 journal_mode=WAL
,同時保留每個資料庫最多保留一個連線的行為。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","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"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],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."]]