From 76affca714fc9a6b0096fa8385777fed4e5e9ae4 Mon Sep 17 00:00:00 2001 From: "Randall E. Barker" Date: Fri, 16 Aug 2019 08:48:48 -0700 Subject: [PATCH] Add debug logging switch to release build developer options (#1574) --- .../vrbrowser/browser/SettingsStore.java | 11 +++++++ .../browser/engine/SessionStore.java | 3 ++ .../browser/engine/SessionUtils.java | 2 -- .../settings/DeveloperOptionsView.java | 30 +++++++++++++++++-- app/src/main/res/layout/options_developer.xml | 6 ++++ app/src/main/res/values/non_L10n.xml | 1 + app/src/main/res/values/strings.xml | 8 ++++- 7 files changed, 56 insertions(+), 5 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java b/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java index 08e3cf6d1..9a132be78 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java @@ -72,6 +72,7 @@ SettingsStore getInstance(final @NonNull Context aContext) { public final static int FOVEATED_WEBVR_DEFAULT_LEVEL = 0; private final static long CRASH_RESTART_DELTA = 2000; public final static boolean AUTOPLAY_ENABLED = false; + public final static boolean DEBUG_LOGGING_DEFAULT = false; // Enable telemetry by default (opt-out). public final static boolean CRASH_REPORTING_DEFAULT = false; @@ -554,5 +555,15 @@ public void setSpeechDataCollectionReviewed(boolean isEnabled) { editor.putBoolean(mContext.getString(R.string.settings_key_speech_data_collection_reviewed), isEnabled); editor.commit(); } + + public boolean isDebugLogginEnabled() { + return mPrefs.getBoolean(mContext.getString(R.string.settings_key_debug_logging), DEBUG_LOGGING_DEFAULT); + } + + public void setDebugLoggingEnabled(boolean isEnabled) { + SharedPreferences.Editor editor = mPrefs.edit(); + editor.putBoolean(mContext.getString(R.string.settings_key_debug_logging), isEnabled); + editor.commit(); + } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionStore.java b/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionStore.java index 9d0949d29..4fd966bfc 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionStore.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionStore.java @@ -79,6 +79,9 @@ public void setContext(Context context, Bundle aExtras) { if (BuildConfig.DEBUG) { runtimeSettingsBuilder.arguments(new String[] { "-purgecaches" }); + runtimeSettingsBuilder.debugLogging(true); + } else { + runtimeSettingsBuilder.debugLogging(SettingsStore.getInstance(context).isDebugLogginEnabled()); } mRuntime = GeckoRuntime.create(context, runtimeSettingsBuilder.build()); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionUtils.java b/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionUtils.java index 6cdb8c8e4..a5ed3e1be 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionUtils.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionUtils.java @@ -40,8 +40,6 @@ public static void vrPrefsWorkAround(Context aContext, Bundle aExtras) { out.write("pref(\"media.webspeech.synth.enabled\", false);\n".getBytes()); // Prevent autozoom when giving a form field focus. out.write("pref(\"formhelper.autozoom\", false);\n".getBytes()); - String geckoLogLevel = BuildConfig.DEBUG ? "Debug" : "Warn"; - out.write(("pref(\"geckoview.logging\", \"" + geckoLogLevel + "\");\n").getBytes()); // Uncomment this to enable WebRender. WARNING NOT READY FOR USAGE. // out.write("pref(\"gfx.webrender.all\", true);\n".getBytes()); int msaa = SettingsStore.getInstance(aContext).getMSAALevel(); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DeveloperOptionsView.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DeveloperOptionsView.java index 8b13d58fa..b656aef12 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DeveloperOptionsView.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DeveloperOptionsView.java @@ -11,6 +11,7 @@ import androidx.databinding.DataBindingUtil; +import org.mozilla.vrbrowser.BuildConfig; import org.mozilla.vrbrowser.R; import org.mozilla.vrbrowser.browser.SettingsStore; import org.mozilla.vrbrowser.browser.engine.SessionStore; @@ -56,6 +57,12 @@ private void initialize(Context aContext) { mBinding.performanceMonitorSwitch.setOnCheckedChangeListener(mPerformanceListener); setPerformance(SettingsStore.getInstance(getContext()).isPerformanceMonitorEnabled(), false); + if (BuildConfig.DEBUG) { + mBinding.debugLoggingSwitch.setVisibility(View.GONE); + } else { + setDebugLogging(SettingsStore.getInstance(getContext()).isDebugLogginEnabled(), false); + } + if (!isServoAvailable()) { mBinding.servoSwitch.setVisibility(View.GONE); @@ -81,6 +88,10 @@ private void initialize(Context aContext) { setPerformance(value, doApply); }; + private SwitchSetting.OnCheckedChangeListener mDebugLogginListener = (compoundButton, value, doApply) -> { + setDebugLogging(value, doApply); + }; + private SwitchSetting.OnCheckedChangeListener mServoListener = (compoundButton, b, doApply) -> { setServo(b, true); }; @@ -89,7 +100,6 @@ private void initialize(Context aContext) { boolean restart = false; if (mBinding.remoteDebuggingSwitch.isChecked() != SettingsStore.REMOTE_DEBUGGING_DEFAULT) { setRemoteDebugging(SettingsStore.REMOTE_DEBUGGING_DEFAULT, true); - restart = true; } if (mBinding.showConsoleSwitch.isChecked() != SettingsStore.CONSOLE_LOGS_DEFAULT) { @@ -106,7 +116,12 @@ private void initialize(Context aContext) { setPerformance(SettingsStore.PERFORMANCE_MONITOR_DEFAULT, true); } - if (restart && mDelegate != null) { + if (mBinding.debugLoggingSwitch.isChecked() != SettingsStore.DEBUG_LOGGING_DEFAULT) { + setDebugLogging(SettingsStore.DEBUG_LOGGING_DEFAULT, true); + restart = true; + } + + if (restart) { showRestartDialog(); } }; @@ -157,6 +172,17 @@ private void setPerformance(boolean value, boolean doApply) { } } + private void setDebugLogging(boolean value, boolean doApply) { + mBinding.debugLoggingSwitch.setOnCheckedChangeListener(null); + mBinding.debugLoggingSwitch.setValue(value, false); + mBinding.debugLoggingSwitch.setOnCheckedChangeListener(mDebugLogginListener); + + if (doApply) { + SettingsStore.getInstance(getContext()).setDebugLoggingEnabled(value); + showRestartDialog(); + } + } + private void setServo(boolean value, boolean doApply) { mBinding.servoSwitch.setOnCheckedChangeListener(null); mBinding.servoSwitch.setValue(value, false); diff --git a/app/src/main/res/layout/options_developer.xml b/app/src/main/res/layout/options_developer.xml index 8d4f33273..62199012c 100644 --- a/app/src/main/res/layout/options_developer.xml +++ b/app/src/main/res/layout/options_developer.xml @@ -60,6 +60,12 @@ android:layout_height="wrap_content" app:description="@string/developer_options_performance_monitor" /> + + settings_browser_world_width settings_browser_world_height settings_key_notifications + settings_key_debug_logging https://github.com/MozillaReality/FirefoxReality/wiki/Environments https://www.mozilla.org/privacy/firefox/ https://mixedreality.mozilla.org/fxr/report?src=browser-fxr&label=browser-firefox-reality&url=%1$s diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9ca1e4a59..e43a443e9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -275,12 +275,18 @@ A dialog should appear with a field labeled with the text, 'Enable Multiprocess'. --> Enable Multiprocess - Enable Performance Monitor + + Enable Debug Logging + Enable Servo