- 语法:
<profileable android:shell=["true" | "false"] android:enabled=["true" | "false"] />
- 包含于:
<application>
- 说明:
- 指定性能分析器如何访问此应用。
- 属性:
android:shell
- 指定设备用户能否通过本地调试工具对此应用进行性能分析。其中包括
android.os.Trace
跟踪 API(Android 11 及更低版本)simpleperf
am profile
命令perfetto profilers
(原生内存、Java 内存、CPU)。
false
,则这些工具和 API 仅在应用处于debuggable
状态时可以正常使用。 可调试的应用会导致性能发生各种明显的下降,对准确衡量时间并无帮助。强烈建议在本地性能测量中使用该元素以获得准确的结果。此元素旨在用于正式发布 build,以便启用本地性能分析功能。它几乎不会引起数据泄露,主机分析工具和 shell 进程都无法读取任何内存数据。只有堆栈轨迹是可读取的,而堆栈轨迹在发布 build 中通常经过混淆处理或缺少符号。
android:enabled
- 指定系统服务或 Shell 工具能否对应用进行性能分析(如果 Shell 工具可以,您还必须设置
android:shell
)。如果设为 false,则根本无法对该应用进行性能分析。默认值为 true。 该属性是 API 级别 30 中的新增属性。
- 引入于:
- API 级别 29
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2022-09-26 UTC.
[]
[]