自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
自訂裝置開發
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
本頁面說明如果您要為自己的裝置設定版本,可能需要執行的幾項工作。
建立自訂閃光燈設定
Fastboot 指令是在名為 fastboot-info.txt
的構件中定義。如果您建構多個目標,$OUT_DIR 中就會有多個 fastboot-info.txt
檔案。$ANDROID_PRODUCT_OUT
會指向您建立的最新目標。本頁面列出 fastboot 執行的工作,並可使用 m fastboot_info
重新產生。您可以修改 fastboot-info.txt
檔案,引入自訂閃爍邏輯。
fastboot-info.txt
檔案支援下列指令:
flash %s
:閃爍指定的分區。可選用的引數包括 --slot-other,
filename_path, and
--apply-vbmeta`。
update-super
:更新超級分區。
if-wipe
:如果指定了清除作業,則會依條件執行其他元件。
erase %s
:清除指定的分割區 (只能與 if-wipe
搭配使用 -> 例如 if-wipe erase cache
)。
判斷閃光燈鎖定狀態
如果您要為裝置建構自訂的 flashboot 守護程序 (flashbootd),就必須能夠取得系統啟動載入程式和系統啟動載入程式鎖定狀態。getFlashLockState()
@SystemApi
會傳輸系統啟動載入程式的狀態,而 PersistentDataBlockManager.getFlashLockState()
系統 API 會在相容的裝置上傳回系統啟動載入程式的鎖定狀態。
傳回值 |
健康狀況 |
FLASH_LOCK_UNKNOWN |
只有升級至 Android 7.x 以上版本的裝置會傳回此值,這些裝置先前不支援系統啟動載入程式變更,因此無法取得刷新鎖定狀態 (如果支援刷新鎖定/解鎖功能)。
- 搭載 Android 7.x 以上版本的新裝置必須處於
FLASH_LOCK_LOCKED 或 FLASH_LOCK_UNLOCKED 狀態。
- 升級至 Android 7.x 以上版本的裝置如果不支援閃燈解鎖/鎖定功能,應會傳回
FLASH_LOCK_LOCKED 狀態。
|
FLASH_LOCK_LOCKED |
由任何不支援閃爍鎖定/解鎖 (也就是裝置一律處於鎖定狀態) 的裝置,或任何支援閃爍鎖定/解鎖且處於鎖定狀態的裝置傳回。 |
FLASH_LOCK_UNLOCKED |
由任何支援閃爍鎖定/解鎖功能且處於解鎖狀態的裝置傳回。 |
製造商應測試裝置在系統啟動載入程式鎖定和解鎖的情況下傳回的值。舉例來說,Android 開放原始碼計畫包含參考實作項目,可根據 ro.boot.flash.locked
啟動屬性傳回值。程式碼範例位於以下目錄中:
frameworks/base/services/core/java/com/android/server/PersistentDataBlockService.java
frameworks/base/core/java/android/service/persistentdata/PersistentDataBlockManager.java
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。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,["# Custom device development\n\nThis page explains several tasks you might need to perform if you're\nsetting up a build for your own device.\n\nCreate a custom flash configuration\n-----------------------------------\n\nFastboot instructions are defined in an artifact called `fastboot-info.txt`. If\nyou build multiple targets, you'll have multiple `fastboot-info.txt` files in\nthe \u003cvar translate=\"no\"\u003e$OUT_DIR\u003c/var\u003e. And, `$ANDROID_PRODUCT_OUT` points to the\nmost current target you built. This page list the tasks for fastboot to execute\nand can be regenerated using `m fastboot_info`. You can introduce custom\nflashing logic by modifying the `fastboot-info.txt` file.\n\nThe `fastboot-info.txt` file supports these commands:\n\n- `flash %s`: Flashes a given partition. Optional arguments include `--slot-other,`\u003cvar translate=\"no\"\u003efilename_path\u003c/var\u003e`, and`--apply-vbmeta\\`.\n- `update-super`: Updates the super partition.\n- `if-wipe`: Conditionally runs some other component if a wipe is specified.\n- `erase %s`: Erases a given partition (can only be used in conjunction with `if-wipe` -\\\u003e eg. `if-wipe erase cache`).\n\nDetermine flash lock state\n--------------------------\n\nIf you're building a custom flashboot daemon (flashbootd) for a device, you need\nto be able to obtain bootloader and bootloader lock state. The\n`getFlashLockState()` `@SystemApi` transmits the bootloader\nstate and the `PersistentDataBlockManager.getFlashLockState()` system\nAPI returns the bootloader's lock status on compliant devices.\n\n| Return value | Conditions |\n|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `FLASH_LOCK_UNKNOWN` | Returned only by devices upgrading to Android 7.x or higher that didn't previously support the bootloader changes required to get the flash lock status if they supported flashing lock/unlock capability. - New devices running Android 7.x or higher must be in either a `FLASH_LOCK_LOCKED` or `FLASH_LOCK_UNLOCKED` state. - Devices upgrading to Android 7.x or higher that don't support flashing unlock/lock capability should return a `FLASH_LOCK_LOCKED` state. |\n| `FLASH_LOCK_LOCKED` | Returned by any device that doesn't support flashing lock/unlock (that is, the device is always locked), or any device that supports flashing lock/unlock and is in the locked state. |\n| `FLASH_LOCK_UNLOCKED` | Returned by any device that supports flashing lock/unlock and is in the unlocked state. |\n\nManufacturers should test the values returned by devices with locked and\nunlocked bootloaders. For example, AOSP\ncontains a reference implementation that returns a value based on the\n`ro.boot.flash.locked` boot property. Example code is located in the\nfollowing directories:\n\n- `frameworks/base/services/core/java/com/android/server/PersistentDataBlockService.java`\n- `frameworks/base/core/java/android/service/persistentdata/PersistentDataBlockManager.java`"]]