如何使用 adb 命令 show/hide 将 GPU 渲染分析为条形图?

How to show/hide Profile GPU rendering as bars using adb command?

我正在尝试使用脚本自动执行我在开发时定期执行的一些任务。其中之一是打开和关闭 GPU 配置文件渲染。但是,我找不到 show/hide 的 adb 命令。

Profile GPU Rendering 复选框 Developer Options 控制 debug.hwui.profile 系统 属性 的值:

/**
  * System property used to enable or disable hardware rendering profiling.
  * The default value of this property is assumed to be false.
  *
  * When profiling is enabled, the adb shell dumpsys gfxinfo command will
  * output extra information about the time taken to execute by the last
  * frames.
  *
  * Possible values:
  * "true", to enable profiling
  * "visual_bars", to enable profiling and visualize the results on screen
  * "false", to disable profiling
  *
  * @see #PROFILE_PROPERTY_VISUALIZE_BARS
  *
  * @hide
  */
public static final String PROFILE_PROPERTY = "debug.hwui.profile";

因此您可以使用 setprop debug.hwui.profile visual_bars 命令启用分析并使用 setprop debug.hwui.profile false 禁用它。