From 26d72cfe517d7f9c8988cd35cb8c1cb34d40bed8 Mon Sep 17 00:00:00 2001 From: "Randall E. Barker" Date: Mon, 8 Jun 2020 06:17:22 -0700 Subject: [PATCH] Merge console and debug logging settings (#3474) Due to the way the settings work in gecko, having two switches doesn't make sense. Having one switch to enable/disable Gecko logging to logcat makes it easier to manage. --- .../vrbrowser/browser/SettingsStore.java | 14 ++-------- .../browser/engine/EngineProvider.kt | 6 ++--- .../settings/DeveloperOptionsView.java | 27 ++----------------- app/src/main/res/layout/options_developer.xml | 6 ----- app/src/main/res/values/strings.xml | 4 --- 5 files changed, 6 insertions(+), 51 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 de61fae3c..bfaee812a 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java @@ -19,6 +19,7 @@ import org.mozilla.geckoview.ContentBlocking; import org.mozilla.geckoview.GeckoSessionSettings; import org.mozilla.telemetry.TelemetryHolder; +import org.mozilla.vrbrowser.BuildConfig; import org.mozilla.vrbrowser.R; import org.mozilla.vrbrowser.VRBrowserActivity; import org.mozilla.vrbrowser.telemetry.GleanMetricsService; @@ -62,7 +63,6 @@ SettingsStore getInstance(final @NonNull Context aContext) { // Developer options default values public final static boolean REMOTE_DEBUGGING_DEFAULT = false; - public final static boolean CONSOLE_LOGS_DEFAULT = false; public final static boolean ENV_OVERRIDE_DEFAULT = false; public final static boolean UI_HARDWARE_ACCELERATION_DEFAULT = true; public final static boolean UI_HARDWARE_ACCELERATION_DEFAULT_WAVEVR = false; @@ -89,7 +89,7 @@ SettingsStore getInstance(final @NonNull Context aContext) { public final static float CYLINDER_DENSITY_ENABLED_DEFAULT = 4680.0f; private final static long CRASH_RESTART_DELTA = 2000; public final static boolean AUTOPLAY_ENABLED = false; - public final static boolean DEBUG_LOGGING_DEFAULT = false; + public final static boolean DEBUG_LOGGING_DEFAULT = BuildConfig.DEBUG; public final static boolean POP_UPS_BLOCKING_DEFAULT = true; public final static boolean WEBXR_ENABLED_DEFAULT = true; public final static boolean TELEMETRY_STATUS_UPDATE_SENT_DEFAULT = false; @@ -214,16 +214,6 @@ public void setRemoteDebuggingEnabled(boolean isEnabled) { editor.commit(); } - public boolean isConsoleLogsEnabled() { - return mPrefs.getBoolean( - mContext.getString(R.string.settings_key_console_logs), CONSOLE_LOGS_DEFAULT); - } - - public void setConsoleLogsEnabled(boolean isEnabled) { - SharedPreferences.Editor editor = mPrefs.edit(); - editor.putBoolean(mContext.getString(R.string.settings_key_console_logs), isEnabled); - editor.commit(); - } public boolean isDrmContentPlaybackEnabled() { return mPrefs.getBoolean( diff --git a/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/EngineProvider.kt b/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/EngineProvider.kt index bcf68bf5c..a1e840cf6 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/EngineProvider.kt +++ b/app/src/common/shared/org/mozilla/vrbrowser/browser/engine/EngineProvider.kt @@ -32,7 +32,6 @@ object EngineProvider { .antiTracking(policy.antiTrackingPolicy) .enhancedTrackingProtectionLevel(SettingsStore.getInstance(context).trackingProtectionLevel) .build()) - builder.consoleOutput(SettingsStore.getInstance(context).isConsoleLogsEnabled) builder.displayDensityOverride(SettingsStore.getInstance(context).displayDensity) builder.remoteDebuggingEnabled(SettingsStore.getInstance(context).isRemoteDebuggingEnabled) builder.displayDpiOverride(SettingsStore.getInstance(context).displayDpi) @@ -41,6 +40,8 @@ object EngineProvider { builder.useMultiprocess(true) builder.inputAutoZoomEnabled(false) builder.doubleTapZoomingEnabled(false) + builder.debugLogging(SettingsStore.getInstance(context).isDebugLoggingEnabled) + builder.consoleOutput(SettingsStore.getInstance(context).isDebugLoggingEnabled) if (SettingsStore.getInstance(context).transparentBorderWidth > 0) { builder.useMaxScreenDepth(true) @@ -48,10 +49,7 @@ object EngineProvider { if (BuildConfig.DEBUG) { builder.arguments(arrayOf("-purgecaches")) - builder.debugLogging(true) builder.aboutConfigEnabled(true) - } else { - builder.debugLogging(SettingsStore.getInstance(context).isDebugLoggingEnabled) } runtime = GeckoRuntime.create(context, builder.build()) 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 225d6ecab..54c047dcd 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 @@ -55,8 +55,8 @@ protected void updateUI() { mBinding.remoteDebuggingSwitch.setOnCheckedChangeListener(mRemoteDebuggingListener); setRemoteDebugging(SettingsStore.getInstance(getContext()).isRemoteDebuggingEnabled(), false); - mBinding.showConsoleSwitch.setOnCheckedChangeListener(mConsoleLogsListener); - setConsoleLogs(SettingsStore.getInstance(getContext()).isConsoleLogsEnabled(), false); + mBinding.debugLoggingSwitch.setOnCheckedChangeListener(mDebugLogginListener); + setDebugLogging(SettingsStore.getInstance(getContext()).isDebugLoggingEnabled(), false); mBinding.performanceMonitorSwitch.setOnCheckedChangeListener(mPerformanceListener); setPerformance(SettingsStore.getInstance(getContext()).isPerformanceMonitorEnabled(), false); @@ -70,13 +70,10 @@ protected void updateUI() { setBypassCacheOnReload(SettingsStore.getInstance(getContext()).isBypassCacheOnReloadEnabled(), false); if (BuildConfig.DEBUG) { - mBinding.debugLoggingSwitch.setVisibility(View.GONE); mBinding.multiE10sSwitch.setOnCheckedChangeListener(mMultiE10sListener); setMultiE10s(SettingsStore.getInstance(getContext()).isMultiE10s(), false); } else { mBinding.multiE10sSwitch.setVisibility(View.GONE); - mBinding.debugLoggingSwitch.setOnCheckedChangeListener(mDebugLogginListener); - setDebugLogging(SettingsStore.getInstance(getContext()).isDebugLoggingEnabled(), false); } if (!isServoAvailable()) { @@ -92,10 +89,6 @@ protected void updateUI() { setRemoteDebugging(value, doApply); }; - private SwitchSetting.OnCheckedChangeListener mConsoleLogsListener = (compoundButton, value, doApply) -> { - setConsoleLogs(value, doApply); - }; - private SwitchSetting.OnCheckedChangeListener mPerformanceListener = (compoundButton, value, doApply) -> { setPerformance(value, doApply); }; @@ -126,10 +119,6 @@ protected void updateUI() { setRemoteDebugging(SettingsStore.REMOTE_DEBUGGING_DEFAULT, true); } - if (mBinding.showConsoleSwitch.isChecked() != SettingsStore.CONSOLE_LOGS_DEFAULT) { - setConsoleLogs(SettingsStore.CONSOLE_LOGS_DEFAULT, true); - } - if (mBinding.servoSwitch.isChecked() != SettingsStore.SERVO_DEFAULT) { setServo(SettingsStore.SERVO_DEFAULT, true); } @@ -169,18 +158,6 @@ private void setRemoteDebugging(boolean value, boolean doApply) { } } - private void setConsoleLogs(boolean value, boolean doApply) { - mBinding.showConsoleSwitch.setOnCheckedChangeListener(null); - mBinding.showConsoleSwitch.setValue(value, doApply); - mBinding.showConsoleSwitch.setOnCheckedChangeListener(mConsoleLogsListener); - - SettingsStore.getInstance(getContext()).setConsoleLogsEnabled(value); - - if (doApply) { - SessionStore.get().setConsoleOutputEnabled(value); - } - } - private void setUIHardwareAcceleration(boolean value, boolean doApply) { mBinding.hardwareAccelerationSwitch.setOnCheckedChangeListener(null); mBinding.hardwareAccelerationSwitch.setValue(value, false); diff --git a/app/src/main/res/layout/options_developer.xml b/app/src/main/res/layout/options_developer.xml index 3d4909eab..4a202e470 100644 --- a/app/src/main/res/layout/options_developer.xml +++ b/app/src/main/res/layout/options_developer.xml @@ -43,12 +43,6 @@ android:layout_height="wrap_content" app:description="@string/developer_options_remote_debugging" /> - - Enable Remote Debugging - - Redirect Console to Logcat - Enable Environment Override