From 3bd52ddf4c6e357b736175c1039d1234b1a99204 Mon Sep 17 00:00:00 2001 From: Dan Sandler Date: Thu, 24 Mar 2016 10:24:27 -0700 Subject: [PATCH 1/2] Developer QS tile: Show Layout. Bug: 27872042 Change-Id: I0df2ffecbf7d2682d89c9b8343590bb04bcc305c --- AndroidManifest.xml | 12 ++++ res/drawable/tile_icon_show_layout.xml | 60 +++++++++++++++++++ .../android/settings/DevelopmentSettings.java | 2 +- .../android/settings/qstile/ShowLayout.java | 46 ++++++++++++++ 4 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 res/drawable/tile_icon_show_layout.xml create mode 100644 src/com/android/settings/qstile/ShowLayout.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml index f6c79572f43..e12afd18bfe 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -2914,5 +2914,17 @@ + + + + + + + diff --git a/res/drawable/tile_icon_show_layout.xml b/res/drawable/tile_icon_show_layout.xml new file mode 100644 index 00000000000..b9b825e01a6 --- /dev/null +++ b/res/drawable/tile_icon_show_layout.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java index 5036b9f20b1..760e2b899f9 100644 --- a/src/com/android/settings/DevelopmentSettings.java +++ b/src/com/android/settings/DevelopmentSettings.java @@ -2078,7 +2078,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment } }; - static class SystemPropPoker extends AsyncTask { + public static class SystemPropPoker extends AsyncTask { @Override protected Void doInBackground(Void... params) { String[] services = ServiceManager.listServices(); diff --git a/src/com/android/settings/qstile/ShowLayout.java b/src/com/android/settings/qstile/ShowLayout.java new file mode 100644 index 00000000000..654cb673f44 --- /dev/null +++ b/src/com/android/settings/qstile/ShowLayout.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.android.settings.qstile; + +import android.os.SystemProperties; +import android.service.quicksettings.Tile; +import android.service.quicksettings.TileService; +import android.view.View; +import com.android.settings.DevelopmentSettings; + +public class ShowLayout extends TileService { + @Override + public void onStartListening() { + super.onStartListening(); + refresh(); + } + + public void refresh() { + getQsTile().setState( + SystemProperties.getBoolean(View.DEBUG_LAYOUT_PROPERTY, false) + ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE); + getQsTile().updateTile(); + } + + @Override + public void onClick() { + SystemProperties.set(View.DEBUG_LAYOUT_PROPERTY, + getQsTile().getState() == Tile.STATE_INACTIVE ? "true" : "false"); + new DevelopmentSettings.SystemPropPoker().execute(); // Settings app magic + refresh(); + } +} From 12c4ba4224a42d54ef671302a09c14ed0d3c09b0 Mon Sep 17 00:00:00 2001 From: Dan Sandler Date: Mon, 28 Mar 2016 11:13:40 -0400 Subject: [PATCH 2/2] Developer QS tile: GPU Profiling. Bug: 27872042 Change-Id: Ia57005df15572b1714af2a3a8cd5b9794fdfb165 --- AndroidManifest.xml | 14 ++- res/drawable/tile_icon_graphics.xml | 52 ++++++++++ .../android/settings/SettingsActivity.java | 11 ++- .../settings/qstile/DevelopmentTiles.java | 95 +++++++++++++++++++ .../android/settings/qstile/ShowLayout.java | 46 --------- 5 files changed, 166 insertions(+), 52 deletions(-) create mode 100644 res/drawable/tile_icon_graphics.xml create mode 100644 src/com/android/settings/qstile/DevelopmentTiles.java delete mode 100644 src/com/android/settings/qstile/ShowLayout.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml index e12afd18bfe..57d3543dd18 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -2916,11 +2916,21 @@ + android:enabled="false"> + + + + + diff --git a/res/drawable/tile_icon_graphics.xml b/res/drawable/tile_icon_graphics.xml new file mode 100644 index 00000000000..84a0a5a7195 --- /dev/null +++ b/res/drawable/tile_icon_graphics.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java index 616fe395460..45a1294c47c 100644 --- a/src/com/android/settings/SettingsActivity.java +++ b/src/com/android/settings/SettingsActivity.java @@ -104,6 +104,7 @@ import com.android.settings.notification.ZenModeSettings; import com.android.settings.notification.ZenModeVisualInterruptionSettings; import com.android.settings.print.PrintJobSettingsFragment; import com.android.settings.print.PrintSettingsFragment; +import com.android.settings.qstile.DevelopmentTiles; import com.android.settings.search.DynamicIndexableContentMonitor; import com.android.settings.search.Index; import com.android.settings.sim.SimSettings; @@ -1067,12 +1068,14 @@ public class SettingsActivity extends SettingsDrawerActivity pm.hasSystemFeature(PackageManager.FEATURE_PRINTING), isAdmin, pm); final boolean showDev = mDevelopmentPreferences.getBoolean( - DevelopmentSettings.PREF_SHOW, - android.os.Build.TYPE.equals("eng")); + DevelopmentSettings.PREF_SHOW, android.os.Build.TYPE.equals("eng")) + && !um.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES); setTileEnabled(new ComponentName(packageName, Settings.DevelopmentSettingsActivity.class.getName()), - showDev && !um.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES), - isAdmin, pm); + showDev, isAdmin, pm); + + // Reveal development-only quick settings tiles + DevelopmentTiles.setTilesEnabled(this, showDev); if (UserHandle.MU_ENABLED && !isAdmin) { // When on restricted users, disable all extra categories (but only the settings ones). diff --git a/src/com/android/settings/qstile/DevelopmentTiles.java b/src/com/android/settings/qstile/DevelopmentTiles.java new file mode 100644 index 00000000000..0d8e7dbec73 --- /dev/null +++ b/src/com/android/settings/qstile/DevelopmentTiles.java @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.android.settings.qstile; + +import android.content.ComponentName; +import android.content.Context; +import android.content.pm.PackageManager; +import android.os.SystemProperties; +import android.service.quicksettings.Tile; +import android.service.quicksettings.TileService; +import android.view.ThreadedRenderer; +import android.view.View; +import com.android.settings.DevelopmentSettings; + +public class DevelopmentTiles { + // List of components that need to be enabled when developer tools are turned on + static final Class[] TILE_CLASSES = new Class[] { + ShowLayout.class, + GPUProfiling.class, + }; + public static void setTilesEnabled(Context context, boolean enable) { + final PackageManager pm = context.getPackageManager(); + for (Class cls : TILE_CLASSES) { + pm.setComponentEnabledSetting(new ComponentName(context, cls), + enable ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED + : PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, + PackageManager.DONT_KILL_APP); + } + } + + /** + * Tile to control the "Show layout bounds" developer setting + */ + public static class ShowLayout extends TileService { + @Override + public void onStartListening() { + super.onStartListening(); + refresh(); + } + + public void refresh() { + final boolean enabled = SystemProperties.getBoolean(View.DEBUG_LAYOUT_PROPERTY, false); + getQsTile().setState(enabled ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE); + getQsTile().updateTile(); + } + + @Override + public void onClick() { + SystemProperties.set(View.DEBUG_LAYOUT_PROPERTY, + getQsTile().getState() == Tile.STATE_INACTIVE ? "true" : "false"); + new DevelopmentSettings.SystemPropPoker().execute(); // Settings app magic + refresh(); + } + } + + /** + * Tile to control the "GPU profiling" developer setting + */ + public static class GPUProfiling extends TileService { + @Override + public void onStartListening() { + super.onStartListening(); + refresh(); + } + + public void refresh() { + final String value = SystemProperties.get(ThreadedRenderer.PROFILE_PROPERTY); + getQsTile().setState(value.equals("visual_bars") + ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE); + getQsTile().updateTile(); + } + + @Override + public void onClick() { + SystemProperties.set(ThreadedRenderer.PROFILE_PROPERTY, + getQsTile().getState() == Tile.STATE_INACTIVE ? "visual_bars" : ""); + new DevelopmentSettings.SystemPropPoker().execute(); // Settings app magic + refresh(); + } + } +} \ No newline at end of file diff --git a/src/com/android/settings/qstile/ShowLayout.java b/src/com/android/settings/qstile/ShowLayout.java deleted file mode 100644 index 654cb673f44..00000000000 --- a/src/com/android/settings/qstile/ShowLayout.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package com.android.settings.qstile; - -import android.os.SystemProperties; -import android.service.quicksettings.Tile; -import android.service.quicksettings.TileService; -import android.view.View; -import com.android.settings.DevelopmentSettings; - -public class ShowLayout extends TileService { - @Override - public void onStartListening() { - super.onStartListening(); - refresh(); - } - - public void refresh() { - getQsTile().setState( - SystemProperties.getBoolean(View.DEBUG_LAYOUT_PROPERTY, false) - ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE); - getQsTile().updateTile(); - } - - @Override - public void onClick() { - SystemProperties.set(View.DEBUG_LAYOUT_PROPERTY, - getQsTile().getState() == Tile.STATE_INACTIVE ? "true" : "false"); - new DevelopmentSettings.SystemPropPoker().execute(); // Settings app magic - refresh(); - } -}