Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit 26d72cf

Browse files
authored
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.
1 parent 9abea56 commit 26d72cf

5 files changed

Lines changed: 6 additions & 51 deletions

File tree

app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.mozilla.geckoview.ContentBlocking;
2020
import org.mozilla.geckoview.GeckoSessionSettings;
2121
import org.mozilla.telemetry.TelemetryHolder;
22+
import org.mozilla.vrbrowser.BuildConfig;
2223
import org.mozilla.vrbrowser.R;
2324
import org.mozilla.vrbrowser.VRBrowserActivity;
2425
import org.mozilla.vrbrowser.telemetry.GleanMetricsService;
@@ -62,7 +63,6 @@ SettingsStore getInstance(final @NonNull Context aContext) {
6263

6364
// Developer options default values
6465
public final static boolean REMOTE_DEBUGGING_DEFAULT = false;
65-
public final static boolean CONSOLE_LOGS_DEFAULT = false;
6666
public final static boolean ENV_OVERRIDE_DEFAULT = false;
6767
public final static boolean UI_HARDWARE_ACCELERATION_DEFAULT = true;
6868
public final static boolean UI_HARDWARE_ACCELERATION_DEFAULT_WAVEVR = false;
@@ -89,7 +89,7 @@ SettingsStore getInstance(final @NonNull Context aContext) {
8989
public final static float CYLINDER_DENSITY_ENABLED_DEFAULT = 4680.0f;
9090
private final static long CRASH_RESTART_DELTA = 2000;
9191
public final static boolean AUTOPLAY_ENABLED = false;
92-
public final static boolean DEBUG_LOGGING_DEFAULT = false;
92+
public final static boolean DEBUG_LOGGING_DEFAULT = BuildConfig.DEBUG;
9393
public final static boolean POP_UPS_BLOCKING_DEFAULT = true;
9494
public final static boolean WEBXR_ENABLED_DEFAULT = true;
9595
public final static boolean TELEMETRY_STATUS_UPDATE_SENT_DEFAULT = false;
@@ -214,16 +214,6 @@ public void setRemoteDebuggingEnabled(boolean isEnabled) {
214214
editor.commit();
215215
}
216216

217-
public boolean isConsoleLogsEnabled() {
218-
return mPrefs.getBoolean(
219-
mContext.getString(R.string.settings_key_console_logs), CONSOLE_LOGS_DEFAULT);
220-
}
221-
222-
public void setConsoleLogsEnabled(boolean isEnabled) {
223-
SharedPreferences.Editor editor = mPrefs.edit();
224-
editor.putBoolean(mContext.getString(R.string.settings_key_console_logs), isEnabled);
225-
editor.commit();
226-
}
227217

228218
public boolean isDrmContentPlaybackEnabled() {
229219
return mPrefs.getBoolean(

app/src/common/shared/org/mozilla/vrbrowser/browser/engine/EngineProvider.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ object EngineProvider {
3232
.antiTracking(policy.antiTrackingPolicy)
3333
.enhancedTrackingProtectionLevel(SettingsStore.getInstance(context).trackingProtectionLevel)
3434
.build())
35-
builder.consoleOutput(SettingsStore.getInstance(context).isConsoleLogsEnabled)
3635
builder.displayDensityOverride(SettingsStore.getInstance(context).displayDensity)
3736
builder.remoteDebuggingEnabled(SettingsStore.getInstance(context).isRemoteDebuggingEnabled)
3837
builder.displayDpiOverride(SettingsStore.getInstance(context).displayDpi)
@@ -41,17 +40,16 @@ object EngineProvider {
4140
builder.useMultiprocess(true)
4241
builder.inputAutoZoomEnabled(false)
4342
builder.doubleTapZoomingEnabled(false)
43+
builder.debugLogging(SettingsStore.getInstance(context).isDebugLoggingEnabled)
44+
builder.consoleOutput(SettingsStore.getInstance(context).isDebugLoggingEnabled)
4445

4546
if (SettingsStore.getInstance(context).transparentBorderWidth > 0) {
4647
builder.useMaxScreenDepth(true)
4748
}
4849

4950
if (BuildConfig.DEBUG) {
5051
builder.arguments(arrayOf("-purgecaches"))
51-
builder.debugLogging(true)
5252
builder.aboutConfigEnabled(true)
53-
} else {
54-
builder.debugLogging(SettingsStore.getInstance(context).isDebugLoggingEnabled)
5553
}
5654

5755
runtime = GeckoRuntime.create(context, builder.build())

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DeveloperOptionsView.java

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ protected void updateUI() {
5555
mBinding.remoteDebuggingSwitch.setOnCheckedChangeListener(mRemoteDebuggingListener);
5656
setRemoteDebugging(SettingsStore.getInstance(getContext()).isRemoteDebuggingEnabled(), false);
5757

58-
mBinding.showConsoleSwitch.setOnCheckedChangeListener(mConsoleLogsListener);
59-
setConsoleLogs(SettingsStore.getInstance(getContext()).isConsoleLogsEnabled(), false);
58+
mBinding.debugLoggingSwitch.setOnCheckedChangeListener(mDebugLogginListener);
59+
setDebugLogging(SettingsStore.getInstance(getContext()).isDebugLoggingEnabled(), false);
6060

6161
mBinding.performanceMonitorSwitch.setOnCheckedChangeListener(mPerformanceListener);
6262
setPerformance(SettingsStore.getInstance(getContext()).isPerformanceMonitorEnabled(), false);
@@ -70,13 +70,10 @@ protected void updateUI() {
7070
setBypassCacheOnReload(SettingsStore.getInstance(getContext()).isBypassCacheOnReloadEnabled(), false);
7171

7272
if (BuildConfig.DEBUG) {
73-
mBinding.debugLoggingSwitch.setVisibility(View.GONE);
7473
mBinding.multiE10sSwitch.setOnCheckedChangeListener(mMultiE10sListener);
7574
setMultiE10s(SettingsStore.getInstance(getContext()).isMultiE10s(), false);
7675
} else {
7776
mBinding.multiE10sSwitch.setVisibility(View.GONE);
78-
mBinding.debugLoggingSwitch.setOnCheckedChangeListener(mDebugLogginListener);
79-
setDebugLogging(SettingsStore.getInstance(getContext()).isDebugLoggingEnabled(), false);
8077
}
8178

8279
if (!isServoAvailable()) {
@@ -92,10 +89,6 @@ protected void updateUI() {
9289
setRemoteDebugging(value, doApply);
9390
};
9491

95-
private SwitchSetting.OnCheckedChangeListener mConsoleLogsListener = (compoundButton, value, doApply) -> {
96-
setConsoleLogs(value, doApply);
97-
};
98-
9992
private SwitchSetting.OnCheckedChangeListener mPerformanceListener = (compoundButton, value, doApply) -> {
10093
setPerformance(value, doApply);
10194
};
@@ -126,10 +119,6 @@ protected void updateUI() {
126119
setRemoteDebugging(SettingsStore.REMOTE_DEBUGGING_DEFAULT, true);
127120
}
128121

129-
if (mBinding.showConsoleSwitch.isChecked() != SettingsStore.CONSOLE_LOGS_DEFAULT) {
130-
setConsoleLogs(SettingsStore.CONSOLE_LOGS_DEFAULT, true);
131-
}
132-
133122
if (mBinding.servoSwitch.isChecked() != SettingsStore.SERVO_DEFAULT) {
134123
setServo(SettingsStore.SERVO_DEFAULT, true);
135124
}
@@ -169,18 +158,6 @@ private void setRemoteDebugging(boolean value, boolean doApply) {
169158
}
170159
}
171160

172-
private void setConsoleLogs(boolean value, boolean doApply) {
173-
mBinding.showConsoleSwitch.setOnCheckedChangeListener(null);
174-
mBinding.showConsoleSwitch.setValue(value, doApply);
175-
mBinding.showConsoleSwitch.setOnCheckedChangeListener(mConsoleLogsListener);
176-
177-
SettingsStore.getInstance(getContext()).setConsoleLogsEnabled(value);
178-
179-
if (doApply) {
180-
SessionStore.get().setConsoleOutputEnabled(value);
181-
}
182-
}
183-
184161
private void setUIHardwareAcceleration(boolean value, boolean doApply) {
185162
mBinding.hardwareAccelerationSwitch.setOnCheckedChangeListener(null);
186163
mBinding.hardwareAccelerationSwitch.setValue(value, false);

app/src/main/res/layout/options_developer.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@
4343
android:layout_height="wrap_content"
4444
app:description="@string/developer_options_remote_debugging" />
4545

46-
<org.mozilla.vrbrowser.ui.views.settings.SwitchSetting
47-
android:id="@+id/show_console_switch"
48-
android:layout_width="match_parent"
49-
android:layout_height="wrap_content"
50-
app:description="@string/developer_options_show_console" />
51-
5246
<org.mozilla.vrbrowser.ui.views.settings.SwitchSetting
5347
android:id="@+id/performance_monitor_switch"
5448
android:layout_width="match_parent"

app/src/main/res/values/strings.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,6 @@
363363
and is used to toggle remote debugging of website content in the application. -->
364364
<string name="developer_options_remote_debugging">Enable Remote Debugging</string>
365365

366-
<!-- This string labels an On/Off switch in the 'Developer Options' dialog
367-
and is used to toggle redirecting JavaScript Console output to the Android Logcat (i.e., `adb logcat`). -->
368-
<string name="developer_options_show_console">Redirect Console to Logcat</string>
369-
370366
<!-- This string labels an On/Off switch in the developer options dialog
371367
and is used to customize background environments of the app. -->
372368
<string name="developer_options_env_override">Enable Environment Override</string>

0 commit comments

Comments
 (0)