自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
實作範圍限定的供應商記錄功能
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Android 11 新增了一個 HAL,即 IDumpstateDevice (1.1 版)。這個 HAL 會公開新方法,以便更精確地設定標準錯誤報告中供應商記錄的範圍,並允許使用者版本開啟或關閉供應商記錄 (使用者版本的預設值為關閉)。這可讓原始設備製造商進一步控管特定類型的錯誤報告中包含的內容。
如果原始設備製造商 (OEM) 選擇實作這個選用 HAL,這項功能就會對他們造成影響。視原始設備製造商選擇透過此 HAL 公開哪些內容而定,SoC 可能會受到影響。運營商不會受到任何影響。
您在錯誤報告中加入的內容取決於您認為哪些資訊與偵錯作業相關,但一般來說,越詳細越好。
範例和來源
我們提供 1.0 版 (已淘汰) IDumpstateDevice 的預設實作方式,其中顯示了使用 dumpstate 實用程式庫的範例:frameworks/native/cmds/dumpstate/DumpstateUtil.h
。1.1 HAL 也有 Cuttlefish 實作:device/google/cuttlefish/guest/monitoring/dumpstate_ext/*
。
原始碼位於以下位置:
實作
如要實作此 HAL,請實作 android.hardware.dumpstate@1.1::IDumpstateDevice
HAL 介面。DumpstateMode
值有很多種可能,但單一裝置可能不支援所有值 (例如 WEAR 和非 Wear OS 裝置)。
實作 dumpstate HAL 為選用項目。所有搭載 Android 11 的新裝置,如果實作 Dumpstate HAL,則必須實作 IDumpstateDevice 1.1。如果裝置在 Android 11 之前已實作 IDumpstateDevice 1.0,則升級至 1.1 應會相對容易,且強烈建議您這麼做,因為這麼做可大幅減少錯誤報告中包含的額外私人資訊。
這項功能取決於核心傾印狀態變更,這些變更也包含在 Android 11 中,位於 frameworks/native/cmds/dumpstate
下方。
實作此 HAL 時,可能需要對某些系統屬性、檔案等進行一些 SEPolicy 變更,才能讓一切正常運作,並且需要與供應商協調,將所有相關資訊轉儲至錯誤報告。
自訂
裝置使用者可以使用開發人員設定切換供應商記錄功能。關閉之後,dumpstateBoard_1_1
仍可能會依據原始設備製造商 (OEM) 的決定,輸出必要的最低資訊。關閉供應商記錄功能後,IDumpstateDevice::dumpstateBoard
只會在錯誤報告中加入必要資訊,如果開啟此功能,則會納入原始設備製造商 (OEM) 選擇的所有資訊。
舉例來說,您可以修改 dumpstate.cpp
(會呼叫 IDumpstateDevice HAL 方法),藉此增加 dumpstateBoard
完成作業的逾時時間。不過,dumpstate.cpp
的核心邏輯應保持不變。
逾時值可以是任何值,但不應大幅增加錯誤回報完成所需的時間。特別是 DumpstateMode::CONNECTIVITY
對時間非常敏感,需要盡可能快速執行,才能收集所有相關的數據機/Wi-Fi/網路記錄。
驗證
我們為 IDumpstateDevice 實作項目提供了 VTS 測試,並且針對一般 BugreportManager
功能提供了功能單元測試。
建議的手動測試案例為 frameworks/base/core/tests/bugreports/src/android/server/bugreports/BugreportManagerTest.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,["# Implement scoped vendor logging\n\nAndroid 11 adds a new HAL, IDumpstateDevice (version\n1.1). This HAL exposes new methods to more tightly scope vendor logs that are\nincluded in standard bug reports, as well as to allow user builds to turn vendor\nlogging on and off (the default for user builds is off). This gives OEMs more\ncontrol over what gets included in particular types of bug reports.\n\nThis feature impacts OEMs if they choose to implement this optional HAL. SoCs\nmight be impacted, depending on what the OEM chooses to expose with this HAL.\nThere's no expected impact to carriers.\n\nWhat you include in bug reports depends on which information you find relevant\nfor debugging, but generally more verbose is better.\n\nExamples and source\n-------------------\n\nThere's a default implementation of the (deprecated) 1.0 version of\nIDumpstateDevice that shows an example of using the dumpstate util library:\n`frameworks/native/cmds/dumpstate/DumpstateUtil.h`. There's also a Cuttlefish\nimplementation of the 1.1 HAL:\n`device/google/cuttlefish/guest/monitoring/dumpstate_ext/*`.\n\nThe source code is located here:\n\n- The HAL files are under [`hardware/interfaces/dumpstate/1.1/`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/dumpstate/1.1/).\n- The dumpstate native code that controls bug report contents is under [`frameworks/native/cmds/dumpstate/`](https://android.googlesource.com/platform/frameworks/native/+/refs/heads/android16-release/cmds/dumpstate/).\n\nImplementation\n--------------\n\nTo implement this HAL, implement the\n`android.hardware.dumpstate@1.1::IDumpstateDevice` HAL interface. There are many\npossible `DumpstateMode` values, but not all are likely to be supported by a\nsingle device (for example, WEAR for non-Wear OS devices).\n\nImplementing the dumpstate HAL is optional. All new devices launching with\nAndroid 11 MUST implement IDumpstateDevice 1.1 if they\nimplement the Dumpstate\nHAL. Devices that have already implemented IDumpstateDevice 1.0 prior to Android\n11 should be relatively easy to upgrade to 1.1, and\ndoing so is strongly recommended, as it greatly reduces the amount of extraneous\nprivate information included in bug reports.\n\nThis feature depends on the core dumpstate changes also included with Android\n11, located under `frameworks/native/cmds/dumpstate`.\n\nImplementing this HAL will likely require some SEPolicy changes to certain\nsystem properties, files, etc. to get things fully working, and will require\ncoordination with vendors to dump all relevant information into bug reports.\n\nCustomization\n-------------\n\nThe device user can toggle vendor logging on or off using developer settings.\nWhen it's turned off, `dumpstateBoard_1_1` may still output minimal essential\ninformation as determined by the OEM. Turning vendor logging off makes\n`IDumpstateDevice::dumpstateBoard` add only essential information to a bug\nreport, while turning it on includes whatever information the OEM chooses.\n\nYou can modify `dumpstate.cpp` (which calls the IDumpstateDevice HAL methods),\nfor example, to increase the timeout given for `dumpstateBoard` to complete.\nHowever, the core logic of `dumpstate.cpp` should remain unchanged.\n\nTimeouts can be any value, but they shouldn't dramatically increase the time\nthat a bug report takes to complete. In particular,\n`DumpstateMode::CONNECTIVITY` is highly time sensitive and needs to run as fast\nas possible to collect all relevant modem/Wi-Fi/networking logs.\n\nValidation\n----------\n\nThere's a VTS test for the IDumpstateDevice implementation, and there are\nfunctional unit tests for general `BugreportManager` functionality.\n\nThe recommended manual test case is\n`frameworks/base/core/tests/bugreports/src/android/server/bugreports/BugreportManagerTest.java`."]]