自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
实现作用域供应商日志记录
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Android 11 添加了新的 HAL IDumpstateDevice(版本 1.1)。此 HAL 指明了新的方法,以便更严格地对标准 bug 报告中包含的供应商日志进行分区,并允许用户 build 开启和关闭供应商日志记录(用户 build 的默认设置为关闭)。通过这种方式,原始设备制造商 (OEM) 可以更好地控制在特定类型的 bug 报告中包含哪些内容。
如果 OEM 选择实现此可选 HAL,则此功能会影响 OEM。SoC 可能会受到影响,具体取决于 OEM 选择与此 HAL 公开的内容。运营商预计不会受到任何影响。
bug 报告中包含的内容取决于您认为与调试相关的信息,但一般来说,越详细越好。
示例和来源
(已废弃的)1.0 版本 IDumpstateDevice 的默认实现,展示了使用 dumpstate util 库的示例: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 OS 设备的 WEAR)。
实现转储转储 HAL 是可选的。所有搭载 Android 11 的新设备都必须实现 DumpstateDevice 1.1(如果这些设备实现了 Dumpstate HAL)。在 Android 11 之前已实现 IDumpstateDevice 1.0 的设备升级到 1.1 会相对容易,我们强烈建议这样做,因为这样可以大大减少 bug 报告中包含的无关隐私信息量。
此功能还取决于 Android 11 中 Android frameworks/native/cmds/dumpstate
下包含的核心转储状态变化。
实现此 HAL 可能需要对某些系统属性、文件等进行一些 SEPolicy 更改才能正常运行,并且需要与供应商协调以将所有相关信息转储到 bug 报告中。
自定义
设备用户可以使用开发者设置开启或关闭供应商日志记录功能。
关闭该功能后,dumpstateBoard_1_1
可能仍会输出由 OEM 确定的最小基本信息。关闭供应商日志记录后,IDumpstateDevice::dumpstateBoard
只会向错误报告添加必要的信息,而开启该功能则会包含 OEM 选择的任何信息。
您可以修改 dumpstate.cpp
(用于调用 UnDumpstateDevice HAL 方法),例如为了增加 dumpstateBoard
的超时。不过,dumpstate.cpp
的核心逻辑应保持不变。
超时可以是任何值,但不应大幅增加完成 bug 报告所需的时间。特别是,DumpstateMode::CONNECTIVITY
具有极高的敏感性,需要尽快运行以收集所有相关的调制解调器/WLAN/网络日志。
验证
针对 IDumpstateDevice 实现有 VTS 测试,常规 BugreportManager
功能有功能单元测试。
建议的手动测试用例为 frameworks/base/core/tests/bugreports/src/android/server/bugreports/BugreportManagerTest.java
。
本页面上的内容和代码示例受内容许可部分所述许可的限制。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,["# 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`."]]