Commit 24a9832f authored by Eric Seckler's avatar Eric Seckler Committed by Commit Bot

android: Replace developer options feature flag with hidden activation

Enables the developer options on <= Dev builds by default and adds a way
to activate them on Beta/Stable channels via 7 taps on the chrome
version in the preferences, in android-like style.

Bug: 898512
Change-Id: Ife44df843e45d660485fb464209964c957a9c887
Reviewed-on: https://chromium-review.googlesource.com/c/1349309
Commit-Queue: Eric Seckler <eseckler@chromium.org>
Reviewed-by: default avatarSami Kyöstilä <skyostil@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#613034}
parent b19fca31
...@@ -202,7 +202,6 @@ public abstract class ChromeFeatureList { ...@@ -202,7 +202,6 @@ public abstract class ChromeFeatureList {
"ContextualSuggestionsIPHReverseScroll"; "ContextualSuggestionsIPHReverseScroll";
public static final String CUSTOM_CONTEXT_MENU = "CustomContextMenu"; public static final String CUSTOM_CONTEXT_MENU = "CustomContextMenu";
public static final String CUSTOM_FEEDBACK_UI = "CustomFeedbackUi"; public static final String CUSTOM_FEEDBACK_UI = "CustomFeedbackUi";
public static final String DEVELOPER_PREFERENCES = "DeveloperPreferences";
public static final String DONT_PREFETCH_LIBRARIES = "DontPrefetchLibraries"; public static final String DONT_PREFETCH_LIBRARIES = "DontPrefetchLibraries";
public static final String DOWNLOAD_HOME_SHOW_STORAGE_INFO = "DownloadHomeShowStorageInfo"; public static final String DOWNLOAD_HOME_SHOW_STORAGE_INFO = "DownloadHomeShowStorageInfo";
public static final String DOWNLOAD_PROGRESS_INFOBAR = "DownloadProgressInfoBar"; public static final String DOWNLOAD_PROGRESS_INFOBAR = "DownloadProgressInfoBar";
......
...@@ -15,18 +15,27 @@ import android.text.format.DateUtils; ...@@ -15,18 +15,27 @@ import android.text.format.DateUtils;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeVersionInfo; import org.chromium.chrome.browser.ChromeVersionInfo;
import org.chromium.chrome.browser.preferences.PrefServiceBridge.AboutVersionStrings; import org.chromium.chrome.browser.preferences.PrefServiceBridge.AboutVersionStrings;
import org.chromium.chrome.browser.preferences.developer.DeveloperPreferences;
import org.chromium.ui.widget.Toast;
import java.util.Calendar; import java.util.Calendar;
/** /**
* Settings fragment that displays information about Chrome. * Settings fragment that displays information about Chrome.
*/ */
public class AboutChromePreferences extends PreferenceFragment { public class AboutChromePreferences
extends PreferenceFragment implements Preference.OnPreferenceClickListener {
private static final int TAPS_FOR_DEVELOPER_PREFERENCES = 7;
private static final String PREF_APPLICATION_VERSION = "application_version"; private static final String PREF_APPLICATION_VERSION = "application_version";
private static final String PREF_OS_VERSION = "os_version"; private static final String PREF_OS_VERSION = "os_version";
private static final String PREF_LEGAL_INFORMATION = "legal_information"; private static final String PREF_LEGAL_INFORMATION = "legal_information";
private int mDeveloperHitCountdown = DeveloperPreferences.shouldShowDeveloperPreferences()
? -1
: TAPS_FOR_DEVELOPER_PREFERENCES;
private Toast mToast;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -37,6 +46,7 @@ public class AboutChromePreferences extends PreferenceFragment { ...@@ -37,6 +46,7 @@ public class AboutChromePreferences extends PreferenceFragment {
AboutVersionStrings versionStrings = prefServiceBridge.getAboutVersionStrings(); AboutVersionStrings versionStrings = prefServiceBridge.getAboutVersionStrings();
Preference p = findPreference(PREF_APPLICATION_VERSION); Preference p = findPreference(PREF_APPLICATION_VERSION);
p.setSummary(getApplicationVersion(getActivity(), versionStrings.getApplicationVersion())); p.setSummary(getApplicationVersion(getActivity(), versionStrings.getApplicationVersion()));
p.setOnPreferenceClickListener(this);
p = findPreference(PREF_OS_VERSION); p = findPreference(PREF_OS_VERSION);
p.setSummary(versionStrings.getOSVersion()); p.setSummary(versionStrings.getOSVersion());
p = findPreference(PREF_LEGAL_INFORMATION); p = findPreference(PREF_LEGAL_INFORMATION);
...@@ -66,4 +76,44 @@ public class AboutChromePreferences extends PreferenceFragment { ...@@ -66,4 +76,44 @@ public class AboutChromePreferences extends PreferenceFragment {
return context.getString(R.string.version_with_update_time, version, return context.getString(R.string.version_with_update_time, version,
updateTimeString); updateTimeString);
} }
@Override
public boolean onPreferenceClick(Preference preference) {
if (mDeveloperHitCountdown > 0) {
mDeveloperHitCountdown--;
if (mDeveloperHitCountdown == 0) {
DeveloperPreferences.setDeveloperPreferencesEnabled();
// Show a toast that the developer preferences were enabled.
if (mToast != null) {
mToast.cancel();
}
mToast = Toast.makeText(
getActivity(), R.string.prefs_developer_enabled, Toast.LENGTH_LONG);
mToast.show();
} else if (mDeveloperHitCountdown > 0
&& mDeveloperHitCountdown < (TAPS_FOR_DEVELOPER_PREFERENCES - 2)) {
// Show a countdown toast.
if (mToast != null) {
mToast.cancel();
}
mToast = Toast.makeText(getActivity(),
getActivity().getResources().getQuantityString(
R.plurals.prefs_developer_enable_countdown, mDeveloperHitCountdown,
mDeveloperHitCountdown),
Toast.LENGTH_SHORT);
mToast.show();
}
} else if (mDeveloperHitCountdown < 0) {
// Show a toast that the developer preferences are already enabled.
if (mToast != null) {
mToast.cancel();
}
mToast = Toast.makeText(
getActivity(), R.string.prefs_developer_already_enabled, Toast.LENGTH_LONG);
mToast.show();
}
return true;
}
} }
...@@ -21,6 +21,7 @@ import org.chromium.chrome.browser.contextual_suggestions.ContextualSuggestionsE ...@@ -21,6 +21,7 @@ import org.chromium.chrome.browser.contextual_suggestions.ContextualSuggestionsE
import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings; import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings;
import org.chromium.chrome.browser.partnercustomizations.HomepageManager; import org.chromium.chrome.browser.partnercustomizations.HomepageManager;
import org.chromium.chrome.browser.preferences.datareduction.DataReductionPreferences; import org.chromium.chrome.browser.preferences.datareduction.DataReductionPreferences;
import org.chromium.chrome.browser.preferences.developer.DeveloperPreferences;
import org.chromium.chrome.browser.search_engines.TemplateUrl; import org.chromium.chrome.browser.search_engines.TemplateUrl;
import org.chromium.chrome.browser.search_engines.TemplateUrlService; import org.chromium.chrome.browser.search_engines.TemplateUrlService;
import org.chromium.chrome.browser.signin.SigninManager; import org.chromium.chrome.browser.signin.SigninManager;
...@@ -158,11 +159,6 @@ public class MainPreferences extends PreferenceFragment ...@@ -158,11 +159,6 @@ public class MainPreferences extends PreferenceFragment
getPreferenceScreen().removePreference(findPreference(PREF_DOWNLOADS)); getPreferenceScreen().removePreference(findPreference(PREF_DOWNLOADS));
} }
// Developer preferences are only shown when the feature is enabled.
if (!ChromeFeatureList.isEnabled(ChromeFeatureList.DEVELOPER_PREFERENCES)) {
getPreferenceScreen().removePreference(findPreference(PREF_DEVELOPER));
}
// This checks whether Autofill Assistant is enabled. // This checks whether Autofill Assistant is enabled.
if (!ChromeFeatureList.isEnabled(ChromeFeatureList.AUTOFILL_ASSISTANT)) { if (!ChromeFeatureList.isEnabled(ChromeFeatureList.AUTOFILL_ASSISTANT)) {
getPreferenceScreen().removePreference(findPreference(PREF_AUTOFILL_ASSISTANT)); getPreferenceScreen().removePreference(findPreference(PREF_AUTOFILL_ASSISTANT));
...@@ -216,6 +212,12 @@ public class MainPreferences extends PreferenceFragment ...@@ -216,6 +212,12 @@ public class MainPreferences extends PreferenceFragment
removePreferenceIfPresent(PREF_CONTEXTUAL_SUGGESTIONS); removePreferenceIfPresent(PREF_CONTEXTUAL_SUGGESTIONS);
} }
if (DeveloperPreferences.shouldShowDeveloperPreferences()) {
addPreferenceIfAbsent(PREF_DEVELOPER);
} else {
removePreferenceIfPresent(PREF_DEVELOPER);
}
ChromeBasePreference dataReduction = ChromeBasePreference dataReduction =
(ChromeBasePreference) findPreference(PREF_DATA_REDUCTION); (ChromeBasePreference) findPreference(PREF_DATA_REDUCTION);
dataReduction.setSummary(DataReductionPreferences.generateSummary(getResources())); dataReduction.setSummary(DataReductionPreferences.generateSummary(getResources()));
......
...@@ -7,13 +7,32 @@ package org.chromium.chrome.browser.preferences.developer; ...@@ -7,13 +7,32 @@ package org.chromium.chrome.browser.preferences.developer;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceFragment; import android.preference.PreferenceFragment;
import org.chromium.base.ContextUtils;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.preferences.PreferenceUtils; import org.chromium.chrome.browser.preferences.PreferenceUtils;
import org.chromium.components.version_info.Channel;
import org.chromium.components.version_info.VersionConstants;
/** /**
* Settings fragment containing preferences aimed at Chrome and web developers. * Settings fragment containing preferences aimed at Chrome and web developers.
*/ */
public class DeveloperPreferences extends PreferenceFragment { public class DeveloperPreferences extends PreferenceFragment {
private static final String PREF_DEVELOPER_ENABLED = "developer";
public static boolean shouldShowDeveloperPreferences() {
// Always enabled on canary, dev and local builds, otherwise can be enabled by tapping the
// Chrome version in Settings>About multiple times.
if (VersionConstants.CHANNEL <= Channel.DEV) return true;
return ContextUtils.getAppSharedPreferences().getBoolean(PREF_DEVELOPER_ENABLED, false);
}
public static void setDeveloperPreferencesEnabled() {
ContextUtils.getAppSharedPreferences()
.edit()
.putBoolean(PREF_DEVELOPER_ENABLED, true)
.apply();
}
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
......
...@@ -1394,10 +1394,19 @@ Your Google account may have other forms of browsing history like searches and a ...@@ -1394,10 +1394,19 @@ Your Google account may have other forms of browsing history like searches and a
Download occurs only on Wi-Fi Download occurs only on Wi-Fi
</message> </message>
<!-- Developer preferences --> <!-- Developer preferences (not translated, since not aimed at end-users) -->
<message name="IDS_PREFS_DEVELOPER" desc="Title for the Developer preferences page in Chrome settings, which is hidden for regular uses and shows settings and tools aimed at Chrome and web developers. [CHAR-LIMIT=32]"> <message name="IDS_PREFS_DEVELOPER" translateable="false" desc="Title for the Developer preferences page in Chrome settings, which is hidden for regular uses and shows settings and tools aimed at Chrome and web developers. [CHAR-LIMIT=32]">
Developer options Developer options
</message> </message>
<message name="IDS_PREFS_DEVELOPER_ENABLE_COUNTDOWN" translateable="false" desc="The toast shown when the Developer preferences will be enabled after a few more taps on the Chrome version.">
{TAPS, plural, =1 {%1$d more tap to enable Developer options.} other {%1$d more taps to enable Developer options.}}
</message>
<message name="IDS_PREFS_DEVELOPER_ENABLED" translateable="false" desc="The toast shown when the Developer preferences are enabled (i.e. shown in settings).">
Developer options are now enabled.
</message>
<message name="IDS_PREFS_DEVELOPER_ALREADY_ENABLED" translateable="false" desc="The toast shown when the Developer preferences were already enabled previously and the user taps on the Chrome version.">
Developer options are already enabled.
</message>
<!-- Tracing preferences (not translated, since part of developer preferences) --> <!-- Tracing preferences (not translated, since part of developer preferences) -->
<message name="IDS_PREFS_TRACING" translateable="false" desc="Title for the Tracing preferences page in Chrome settings, which allows configuring and recording a Chrome performance trace. [CHAR-LIMIT=32]"> <message name="IDS_PREFS_TRACING" translateable="false" desc="Title for the Tracing preferences page in Chrome settings, which allows configuring and recording a Chrome performance trace. [CHAR-LIMIT=32]">
......
...@@ -38,7 +38,6 @@ import org.chromium.base.test.util.DisableIf; ...@@ -38,7 +38,6 @@ import org.chromium.base.test.util.DisableIf;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeActivity; import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.ChromeSwitches; import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.preferences.ButtonPreference; import org.chromium.chrome.browser.preferences.ButtonPreference;
import org.chromium.chrome.browser.preferences.Preferences; import org.chromium.chrome.browser.preferences.Preferences;
...@@ -49,7 +48,6 @@ import org.chromium.chrome.browser.tracing.TracingController; ...@@ -49,7 +48,6 @@ import org.chromium.chrome.browser.tracing.TracingController;
import org.chromium.chrome.browser.tracing.TracingNotificationManager; import org.chromium.chrome.browser.tracing.TracingNotificationManager;
import org.chromium.chrome.test.ChromeActivityTestRule; import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.util.browser.Features;
import org.chromium.chrome.test.util.browser.notifications.MockNotificationManagerProxy; import org.chromium.chrome.test.util.browser.notifications.MockNotificationManagerProxy;
import org.chromium.content_public.browser.test.util.Criteria; import org.chromium.content_public.browser.test.util.Criteria;
import org.chromium.content_public.browser.test.util.CriteriaHelper; import org.chromium.content_public.browser.test.util.CriteriaHelper;
...@@ -147,7 +145,6 @@ public class TracingPreferencesTest { ...@@ -147,7 +145,6 @@ public class TracingPreferencesTest {
@Test @Test
@MediumTest @MediumTest
@Feature({"Preferences"}) @Feature({"Preferences"})
@Features.EnableFeatures(ChromeFeatureList.DEVELOPER_PREFERENCES)
@DisableIf.Build(sdk_is_less_than = 21, message = "crbug.com/899894") @DisableIf.Build(sdk_is_less_than = 21, message = "crbug.com/899894")
public void testRecordTrace() throws Exception { public void testRecordTrace() throws Exception {
Context context = ContextUtils.getApplicationContext(); Context context = ContextUtils.getApplicationContext();
...@@ -250,7 +247,6 @@ public class TracingPreferencesTest { ...@@ -250,7 +247,6 @@ public class TracingPreferencesTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"Preferences"}) @Feature({"Preferences"})
@Features.EnableFeatures(ChromeFeatureList.DEVELOPER_PREFERENCES)
public void testNotificationsDisabledMessage() throws Exception { public void testNotificationsDisabledMessage() throws Exception {
mMockNotificationManager.setNotificationsEnabled(false); mMockNotificationManager.setNotificationsEnabled(false);
...@@ -276,7 +272,6 @@ public class TracingPreferencesTest { ...@@ -276,7 +272,6 @@ public class TracingPreferencesTest {
@Test @Test
@MediumTest @MediumTest
@Feature({"Preferences"}) @Feature({"Preferences"})
@Features.EnableFeatures(ChromeFeatureList.DEVELOPER_PREFERENCES)
public void testSelectCategories() throws Exception { public void testSelectCategories() throws Exception {
// We need a renderer so that its tracing categories will be populated. // We need a renderer so that its tracing categories will be populated.
mActivityTestRule.startMainActivityOnBlankPage(); mActivityTestRule.startMainActivityOnBlankPage();
...@@ -340,7 +335,6 @@ public class TracingPreferencesTest { ...@@ -340,7 +335,6 @@ public class TracingPreferencesTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"Preferences"}) @Feature({"Preferences"})
@Features.EnableFeatures(ChromeFeatureList.DEVELOPER_PREFERENCES)
public void testSelectMode() throws Exception { public void testSelectMode() throws Exception {
Context context = ContextUtils.getApplicationContext(); Context context = ContextUtils.getApplicationContext();
Preferences activity = Preferences activity =
......
...@@ -106,7 +106,6 @@ const base::Feature* kFeaturesExposedToJava[] = { ...@@ -106,7 +106,6 @@ const base::Feature* kFeaturesExposedToJava[] = {
&kContextualSearchUnityIntegration, &kContextualSearchUnityIntegration,
&kCustomContextMenu, &kCustomContextMenu,
&kCustomFeedbackUi, &kCustomFeedbackUi,
&kDeveloperPreferences,
&kDontPrefetchLibraries, &kDontPrefetchLibraries,
&kDownloadProgressInfoBar, &kDownloadProgressInfoBar,
&kDownloadHomeV2, &kDownloadHomeV2,
...@@ -288,9 +287,6 @@ const base::Feature kCustomContextMenu{"CustomContextMenu", ...@@ -288,9 +287,6 @@ const base::Feature kCustomContextMenu{"CustomContextMenu",
const base::Feature kCustomFeedbackUi{"CustomFeedbackUi", const base::Feature kCustomFeedbackUi{"CustomFeedbackUi",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kDeveloperPreferences{"DeveloperPreferences",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kDontPrefetchLibraries{"DontPrefetchLibraries", const base::Feature kDontPrefetchLibraries{"DontPrefetchLibraries",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
......
...@@ -43,7 +43,6 @@ extern const base::Feature kContextualSearchTapDisableOverride; ...@@ -43,7 +43,6 @@ extern const base::Feature kContextualSearchTapDisableOverride;
extern const base::Feature kContextualSearchUnityIntegration; extern const base::Feature kContextualSearchUnityIntegration;
extern const base::Feature kCustomContextMenu; extern const base::Feature kCustomContextMenu;
extern const base::Feature kCustomFeedbackUi; extern const base::Feature kCustomFeedbackUi;
extern const base::Feature kDeveloperPreferences;
extern const base::Feature kDontPrefetchLibraries; extern const base::Feature kDontPrefetchLibraries;
extern const base::Feature kDownloadAutoResumptionThrottling; extern const base::Feature kDownloadAutoResumptionThrottling;
extern const base::Feature kDownloadProgressInfoBar; extern const base::Feature kDownloadProgressInfoBar;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment