Add three new developer settings

- Show hw screen updates: show where apps udpate the screen when running with
  hw acceleration
- Profile hw rendering: add extra profiling info to dumpsys gfxinfo for
  performance tracking
- Debug layout: show layout info on screen

Change-Id: I6f7cad762d65ec3be2debfb4a88c25d35bf11079
This commit is contained in:
Romain Guy
2012-04-27 15:27:54 -07:00
parent bd4bac327b
commit c1fa3e64b8
3 changed files with 104 additions and 37 deletions

View File

@@ -3589,11 +3589,21 @@
<!-- UI debug setting: show screen updates summary [CHAR LIMIT=50] --> <!-- UI debug setting: show screen updates summary [CHAR LIMIT=50] -->
<string name="show_screen_updates_summary">Flash areas of screen when they update</string> <string name="show_screen_updates_summary">Flash areas of screen when they update</string>
<!-- UI debug setting: show where screen updates happen with GPU rendering? [CHAR LIMIT=25] -->
<string name="show_hw_screen_updates">Show GPU screen updates</string>
<!-- UI debug setting: show GPU rendering screen updates summary [CHAR LIMIT=50] -->
<string name="show_hw_screen_updates_summary">Flash areas of screen when they update with the GPU</string>
<!-- UI debug setting: disable use of overlays? [CHAR LIMIT=25] --> <!-- UI debug setting: disable use of overlays? [CHAR LIMIT=25] -->
<string name="disable_overlays">Disable overlays</string> <string name="disable_overlays">Disable overlays</string>
<!-- UI debug setting: disable use of overlays summary [CHAR LIMIT=50] --> <!-- UI debug setting: disable use of overlays summary [CHAR LIMIT=50] -->
<string name="disable_overlays_summary">Don\'t use overlays for screen compositing</string> <string name="disable_overlays_summary">Don\'t use overlays for screen compositing</string>
<!-- UI debug setting: show layout bounds information [CHAR LIMIT=25] -->
<string name="debug_layout">Show layout bounds</string>
<!-- UI debug setting: show layout bounds information summary [CHAR LIMIT=50] -->
<string name="debug_layout_summary">Display information about boumds, padding, etc.</string>
<!-- UI debug setting: show how CPU is being used? [CHAR LIMIT=25] --> <!-- UI debug setting: show how CPU is being used? [CHAR LIMIT=25] -->
<string name="show_cpu_usage">Show CPU usage</string> <string name="show_cpu_usage">Show CPU usage</string>
<!-- UI debug setting: show cpu usage summary [CHAR LIMIT=50] --> <!-- UI debug setting: show cpu usage summary [CHAR LIMIT=50] -->
@@ -3604,6 +3614,11 @@
<!-- UI debug setting: force hardware acceleration summary [CHAR LIMIT=50] --> <!-- UI debug setting: force hardware acceleration summary [CHAR LIMIT=50] -->
<string name="force_hw_ui_summary">Use 2D hardware acceleration in applications</string> <string name="force_hw_ui_summary">Use 2D hardware acceleration in applications</string>
<!-- UI debug setting: profile time taken by hardware acceleration to render apps [CHAR LIMIT=25] -->
<string name="track_frame_time">Profile GPU rendering</string>
<!-- UI debug setting: profile hardware acceleration summary [CHAR LIMIT=50] -->
<string name="track_frame_time_summary">Measure rendering time in adb shell dumpsys gfxinfo</string>
<!-- UI debug setting: scaling factor for window animations [CHAR LIMIT=25] --> <!-- UI debug setting: scaling factor for window animations [CHAR LIMIT=25] -->
<string name="window_animation_scale_title">Window animation scale</string> <string name="window_animation_scale_title">Window animation scale</string>

View File

@@ -88,6 +88,11 @@
android:title="@string/show_touches" android:title="@string/show_touches"
android:summary="@string/show_touches_summary"/> android:summary="@string/show_touches_summary"/>
<CheckBoxPreference
android:key="debug_layout"
android:title="@string/debug_layout"
android:summary="@string/debug_layout_summary"/>
<CheckBoxPreference <CheckBoxPreference
android:key="show_screen_updates" android:key="show_screen_updates"
android:title="@string/show_screen_updates" android:title="@string/show_screen_updates"
@@ -108,6 +113,16 @@
android:title="@string/force_hw_ui" android:title="@string/force_hw_ui"
android:summary="@string/force_hw_ui_summary"/> android:summary="@string/force_hw_ui_summary"/>
<CheckBoxPreference
android:key="show_hw_screen_udpates"
android:title="@string/show_hw_screen_updates"
android:summary="@string/show_hw_screen_updates_summary"/>
<CheckBoxPreference
android:key="track_frame_time"
android:title="@string/track_frame_time"
android:summary="@string/track_frame_time_summary"/>
<ListPreference <ListPreference
android:key="window_animation_scale" android:key="window_animation_scale"
android:title="@string/window_animation_scale_title" android:title="@string/window_animation_scale_title"

View File

@@ -49,7 +49,9 @@ import android.preference.Preference.OnPreferenceChangeListener;
import android.provider.Settings; import android.provider.Settings;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.Gravity; import android.view.Gravity;
import android.view.HardwareRenderer;
import android.view.IWindowManager; import android.view.IWindowManager;
import android.view.View;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.Switch; import android.widget.Switch;
@@ -79,6 +81,9 @@ public class DevelopmentSettings extends PreferenceFragment
private static final String DISABLE_OVERLAYS_KEY = "disable_overlays"; private static final String DISABLE_OVERLAYS_KEY = "disable_overlays";
private static final String SHOW_CPU_USAGE_KEY = "show_cpu_usage"; private static final String SHOW_CPU_USAGE_KEY = "show_cpu_usage";
private static final String FORCE_HARDWARE_UI_KEY = "force_hw_ui"; private static final String FORCE_HARDWARE_UI_KEY = "force_hw_ui";
private static final String TRACK_FRAME_TIME_KEY = "track_frame_time";
private static final String SHOW_HW_SCREEN_UPDATES_KEY = "show_hw_screen_udpates";
private static final String DEBUG_LAYOUT_KEY = "debug_layout";
private static final String WINDOW_ANIMATION_SCALE_KEY = "window_animation_scale"; private static final String WINDOW_ANIMATION_SCALE_KEY = "window_animation_scale";
private static final String TRANSITION_ANIMATION_SCALE_KEY = "transition_animation_scale"; private static final String TRANSITION_ANIMATION_SCALE_KEY = "transition_animation_scale";
private static final String ANIMATOR_DURATION_SCALE_KEY = "animator_duration_scale"; private static final String ANIMATOR_DURATION_SCALE_KEY = "animator_duration_scale";
@@ -113,6 +118,9 @@ public class DevelopmentSettings extends PreferenceFragment
private CheckBoxPreference mDisableOverlays; private CheckBoxPreference mDisableOverlays;
private CheckBoxPreference mShowCpuUsage; private CheckBoxPreference mShowCpuUsage;
private CheckBoxPreference mForceHardwareUi; private CheckBoxPreference mForceHardwareUi;
private CheckBoxPreference mTrackFrameTime;
private CheckBoxPreference mShowHwScreenUpdates;
private CheckBoxPreference mDebugLayout;
private ListPreference mWindowAnimationScale; private ListPreference mWindowAnimationScale;
private ListPreference mTransitionAnimationScale; private ListPreference mTransitionAnimationScale;
private ListPreference mAnimatorDurationScale; private ListPreference mAnimatorDurationScale;
@@ -141,45 +149,25 @@ public class DevelopmentSettings extends PreferenceFragment
addPreferencesFromResource(R.xml.development_prefs); addPreferencesFromResource(R.xml.development_prefs);
mEnableAdb = (CheckBoxPreference) findPreference(ENABLE_ADB); mEnableAdb = findAndInitCheckboxPref(ENABLE_ADB);
mAllPrefs.add(mEnableAdb); mKeepScreenOn = findAndInitCheckboxPref(KEEP_SCREEN_ON);
mResetCbPrefs.add(mEnableAdb); mAllowMockLocation = findAndInitCheckboxPref(ALLOW_MOCK_LOCATION);
mKeepScreenOn = (CheckBoxPreference) findPreference(KEEP_SCREEN_ON);
mAllPrefs.add(mKeepScreenOn);
mResetCbPrefs.add(mKeepScreenOn);
mAllowMockLocation = (CheckBoxPreference) findPreference(ALLOW_MOCK_LOCATION);
mAllPrefs.add(mAllowMockLocation);
mResetCbPrefs.add(mAllowMockLocation);
mPassword = (PreferenceScreen) findPreference(LOCAL_BACKUP_PASSWORD); mPassword = (PreferenceScreen) findPreference(LOCAL_BACKUP_PASSWORD);
mAllPrefs.add(mPassword); mAllPrefs.add(mPassword);
mDebugAppPref = findPreference(DEBUG_APP_KEY); mDebugAppPref = findPreference(DEBUG_APP_KEY);
mAllPrefs.add(mDebugAppPref); mAllPrefs.add(mDebugAppPref);
mWaitForDebugger = (CheckBoxPreference) findPreference(WAIT_FOR_DEBUGGER_KEY); mWaitForDebugger = findAndInitCheckboxPref(WAIT_FOR_DEBUGGER_KEY);
mAllPrefs.add(mWaitForDebugger); mStrictMode = findAndInitCheckboxPref(STRICT_MODE_KEY);
mResetCbPrefs.add(mWaitForDebugger); mPointerLocation = findAndInitCheckboxPref(POINTER_LOCATION_KEY);
mShowTouches = findAndInitCheckboxPref(SHOW_TOUCHES_KEY);
mStrictMode = (CheckBoxPreference) findPreference(STRICT_MODE_KEY); mShowScreenUpdates = findAndInitCheckboxPref(SHOW_SCREEN_UPDATES_KEY);
mAllPrefs.add(mStrictMode); mDisableOverlays = findAndInitCheckboxPref(DISABLE_OVERLAYS_KEY);
mResetCbPrefs.add(mStrictMode); mShowCpuUsage = findAndInitCheckboxPref(SHOW_CPU_USAGE_KEY);
mPointerLocation = (CheckBoxPreference) findPreference(POINTER_LOCATION_KEY); mForceHardwareUi = findAndInitCheckboxPref(FORCE_HARDWARE_UI_KEY);
mAllPrefs.add(mPointerLocation); mTrackFrameTime = findAndInitCheckboxPref(TRACK_FRAME_TIME_KEY);
mResetCbPrefs.add(mPointerLocation); mShowHwScreenUpdates = findAndInitCheckboxPref(SHOW_HW_SCREEN_UPDATES_KEY);
mShowTouches = (CheckBoxPreference) findPreference(SHOW_TOUCHES_KEY); mDebugLayout = findAndInitCheckboxPref(DEBUG_LAYOUT_KEY);
mAllPrefs.add(mShowTouches);
mResetCbPrefs.add(mShowTouches);
mShowScreenUpdates = (CheckBoxPreference) findPreference(SHOW_SCREEN_UPDATES_KEY);
mAllPrefs.add(mShowScreenUpdates);
mResetCbPrefs.add(mShowScreenUpdates);
mDisableOverlays = (CheckBoxPreference) findPreference(DISABLE_OVERLAYS_KEY);
mAllPrefs.add(mDisableOverlays);
mResetCbPrefs.add(mDisableOverlays);
mShowCpuUsage = (CheckBoxPreference) findPreference(SHOW_CPU_USAGE_KEY);
mAllPrefs.add(mShowCpuUsage);
mResetCbPrefs.add(mShowCpuUsage);
mForceHardwareUi = (CheckBoxPreference) findPreference(FORCE_HARDWARE_UI_KEY);
mAllPrefs.add(mForceHardwareUi);
mResetCbPrefs.add(mForceHardwareUi);
mWindowAnimationScale = (ListPreference) findPreference(WINDOW_ANIMATION_SCALE_KEY); mWindowAnimationScale = (ListPreference) findPreference(WINDOW_ANIMATION_SCALE_KEY);
mAllPrefs.add(mWindowAnimationScale); mAllPrefs.add(mWindowAnimationScale);
mWindowAnimationScale.setOnPreferenceChangeListener(this); mWindowAnimationScale.setOnPreferenceChangeListener(this);
@@ -217,6 +205,16 @@ public class DevelopmentSettings extends PreferenceFragment
removeHdcpOptionsForProduction(); removeHdcpOptionsForProduction();
} }
private CheckBoxPreference findAndInitCheckboxPref(String key) {
CheckBoxPreference pref = (CheckBoxPreference) findPreference(key);
if (pref == null) {
throw new IllegalArgumentException("Cannot find preference with key = " + key);
}
mAllPrefs.add(pref);
mResetCbPrefs.add(pref);
return pref;
}
@Override @Override
public void onActivityCreated(Bundle savedInstanceState) { public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
@@ -296,6 +294,9 @@ public class DevelopmentSettings extends PreferenceFragment
updateFlingerOptions(); updateFlingerOptions();
updateCpuUsageOptions(); updateCpuUsageOptions();
updateHardwareUiOptions(); updateHardwareUiOptions();
updateTrackFrameTimeOptions();
updateShowHwScreenUpdatesOptions();
updateDebugLayoutOptions();
updateAnimationScaleOptions(); updateAnimationScaleOptions();
updateImmediatelyDestroyActivitiesOptions(); updateImmediatelyDestroyActivitiesOptions();
updateAppProcessLimitOptions(); updateAppProcessLimitOptions();
@@ -357,7 +358,7 @@ public class DevelopmentSettings extends PreferenceFragment
} }
} }
private void resetDebuggerOptions() { private static void resetDebuggerOptions() {
try { try {
ActivityManagerNative.getDefault().setDebugApp( ActivityManagerNative.getDefault().setDebugApp(
null, false, true); null, false, true);
@@ -393,7 +394,7 @@ public class DevelopmentSettings extends PreferenceFragment
// 0: not explicitly set one way or another // 0: not explicitly set one way or another
// 1: on // 1: on
// 2: off // 2: off
private int currentStrictModeActiveIndex() { private static int currentStrictModeActiveIndex() {
if (TextUtils.isEmpty(SystemProperties.get(StrictMode.VISUAL_PROPERTY))) { if (TextUtils.isEmpty(SystemProperties.get(StrictMode.VISUAL_PROPERTY))) {
return 0; return 0;
} }
@@ -501,6 +502,36 @@ public class DevelopmentSettings extends PreferenceFragment
SystemProperties.set(HARDWARE_UI_PROPERTY, mForceHardwareUi.isChecked() ? "true" : "false"); SystemProperties.set(HARDWARE_UI_PROPERTY, mForceHardwareUi.isChecked() ? "true" : "false");
} }
private void updateTrackFrameTimeOptions() {
mTrackFrameTime.setChecked(
SystemProperties.getBoolean(HardwareRenderer.PROFILE_PROPERTY, false));
}
private void writeTrackFrameTimeOptions() {
SystemProperties.set(HardwareRenderer.PROFILE_PROPERTY,
mTrackFrameTime.isChecked() ? "true" : "false");
}
private void updateShowHwScreenUpdatesOptions() {
mShowHwScreenUpdates.setChecked(
SystemProperties.getBoolean(HardwareRenderer.DEBUG_DIRTY_REGIONS_PROPERTY, false));
}
private void writeShowHwScreenUpdatesOptions() {
SystemProperties.set(HardwareRenderer.DEBUG_DIRTY_REGIONS_PROPERTY,
mShowHwScreenUpdates.isChecked() ? "true" : "false");
}
private void updateDebugLayoutOptions() {
mDebugLayout.setChecked(
SystemProperties.getBoolean(View.DEBUG_LAYOUT_PROPERTY, false));
}
private void writeDebugLayoutOptions() {
SystemProperties.set(View.DEBUG_LAYOUT_PROPERTY,
mDebugLayout.isChecked() ? "true" : "false");
}
private void updateCpuUsageOptions() { private void updateCpuUsageOptions() {
mShowCpuUsage.setChecked(Settings.System.getInt(getActivity().getContentResolver(), mShowCpuUsage.setChecked(Settings.System.getInt(getActivity().getContentResolver(),
Settings.System.SHOW_PROCESSES, 0) != 0); Settings.System.SHOW_PROCESSES, 0) != 0);
@@ -697,6 +728,12 @@ public class DevelopmentSettings extends PreferenceFragment
writeShowAllANRsOptions(); writeShowAllANRsOptions();
} else if (preference == mForceHardwareUi) { } else if (preference == mForceHardwareUi) {
writeHardwareUiOptions(); writeHardwareUiOptions();
} else if (preference == mTrackFrameTime) {
writeTrackFrameTimeOptions();
} else if (preference == mShowHwScreenUpdates) {
writeShowHwScreenUpdatesOptions();
} else if (preference == mDebugLayout) {
writeDebugLayoutOptions();
} }
return false; return false;