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

Commit 76affca

Browse files
authored
Add debug logging switch to release build developer options (#1574)
1 parent 0881c56 commit 76affca

File tree

7 files changed

+56
-5
lines changed

7 files changed

+56
-5
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ SettingsStore getInstance(final @NonNull Context aContext) {
7272
public final static int FOVEATED_WEBVR_DEFAULT_LEVEL = 0;
7373
private final static long CRASH_RESTART_DELTA = 2000;
7474
public final static boolean AUTOPLAY_ENABLED = false;
75+
public final static boolean DEBUG_LOGGING_DEFAULT = false;
7576

7677
// Enable telemetry by default (opt-out).
7778
public final static boolean CRASH_REPORTING_DEFAULT = false;
@@ -554,5 +555,15 @@ public void setSpeechDataCollectionReviewed(boolean isEnabled) {
554555
editor.putBoolean(mContext.getString(R.string.settings_key_speech_data_collection_reviewed), isEnabled);
555556
editor.commit();
556557
}
558+
559+
public boolean isDebugLogginEnabled() {
560+
return mPrefs.getBoolean(mContext.getString(R.string.settings_key_debug_logging), DEBUG_LOGGING_DEFAULT);
561+
}
562+
563+
public void setDebugLoggingEnabled(boolean isEnabled) {
564+
SharedPreferences.Editor editor = mPrefs.edit();
565+
editor.putBoolean(mContext.getString(R.string.settings_key_debug_logging), isEnabled);
566+
editor.commit();
567+
}
557568
}
558569

app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionStore.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ public void setContext(Context context, Bundle aExtras) {
7979

8080
if (BuildConfig.DEBUG) {
8181
runtimeSettingsBuilder.arguments(new String[] { "-purgecaches" });
82+
runtimeSettingsBuilder.debugLogging(true);
83+
} else {
84+
runtimeSettingsBuilder.debugLogging(SettingsStore.getInstance(context).isDebugLogginEnabled());
8285
}
8386

8487
mRuntime = GeckoRuntime.create(context, runtimeSettingsBuilder.build());

app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionUtils.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ public static void vrPrefsWorkAround(Context aContext, Bundle aExtras) {
4040
out.write("pref(\"media.webspeech.synth.enabled\", false);\n".getBytes());
4141
// Prevent autozoom when giving a form field focus.
4242
out.write("pref(\"formhelper.autozoom\", false);\n".getBytes());
43-
String geckoLogLevel = BuildConfig.DEBUG ? "Debug" : "Warn";
44-
out.write(("pref(\"geckoview.logging\", \"" + geckoLogLevel + "\");\n").getBytes());
4543
// Uncomment this to enable WebRender. WARNING NOT READY FOR USAGE.
4644
// out.write("pref(\"gfx.webrender.all\", true);\n".getBytes());
4745
int msaa = SettingsStore.getInstance(aContext).getMSAALevel();

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

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import androidx.databinding.DataBindingUtil;
1313

14+
import org.mozilla.vrbrowser.BuildConfig;
1415
import org.mozilla.vrbrowser.R;
1516
import org.mozilla.vrbrowser.browser.SettingsStore;
1617
import org.mozilla.vrbrowser.browser.engine.SessionStore;
@@ -56,6 +57,12 @@ private void initialize(Context aContext) {
5657
mBinding.performanceMonitorSwitch.setOnCheckedChangeListener(mPerformanceListener);
5758
setPerformance(SettingsStore.getInstance(getContext()).isPerformanceMonitorEnabled(), false);
5859

60+
if (BuildConfig.DEBUG) {
61+
mBinding.debugLoggingSwitch.setVisibility(View.GONE);
62+
} else {
63+
setDebugLogging(SettingsStore.getInstance(getContext()).isDebugLogginEnabled(), false);
64+
}
65+
5966
if (!isServoAvailable()) {
6067
mBinding.servoSwitch.setVisibility(View.GONE);
6168

@@ -81,6 +88,10 @@ private void initialize(Context aContext) {
8188
setPerformance(value, doApply);
8289
};
8390

91+
private SwitchSetting.OnCheckedChangeListener mDebugLogginListener = (compoundButton, value, doApply) -> {
92+
setDebugLogging(value, doApply);
93+
};
94+
8495
private SwitchSetting.OnCheckedChangeListener mServoListener = (compoundButton, b, doApply) -> {
8596
setServo(b, true);
8697
};
@@ -89,7 +100,6 @@ private void initialize(Context aContext) {
89100
boolean restart = false;
90101
if (mBinding.remoteDebuggingSwitch.isChecked() != SettingsStore.REMOTE_DEBUGGING_DEFAULT) {
91102
setRemoteDebugging(SettingsStore.REMOTE_DEBUGGING_DEFAULT, true);
92-
restart = true;
93103
}
94104

95105
if (mBinding.showConsoleSwitch.isChecked() != SettingsStore.CONSOLE_LOGS_DEFAULT) {
@@ -106,7 +116,12 @@ private void initialize(Context aContext) {
106116
setPerformance(SettingsStore.PERFORMANCE_MONITOR_DEFAULT, true);
107117
}
108118

109-
if (restart && mDelegate != null) {
119+
if (mBinding.debugLoggingSwitch.isChecked() != SettingsStore.DEBUG_LOGGING_DEFAULT) {
120+
setDebugLogging(SettingsStore.DEBUG_LOGGING_DEFAULT, true);
121+
restart = true;
122+
}
123+
124+
if (restart) {
110125
showRestartDialog();
111126
}
112127
};
@@ -157,6 +172,17 @@ private void setPerformance(boolean value, boolean doApply) {
157172
}
158173
}
159174

175+
private void setDebugLogging(boolean value, boolean doApply) {
176+
mBinding.debugLoggingSwitch.setOnCheckedChangeListener(null);
177+
mBinding.debugLoggingSwitch.setValue(value, false);
178+
mBinding.debugLoggingSwitch.setOnCheckedChangeListener(mDebugLogginListener);
179+
180+
if (doApply) {
181+
SettingsStore.getInstance(getContext()).setDebugLoggingEnabled(value);
182+
showRestartDialog();
183+
}
184+
}
185+
160186
private void setServo(boolean value, boolean doApply) {
161187
mBinding.servoSwitch.setOnCheckedChangeListener(null);
162188
mBinding.servoSwitch.setValue(value, false);

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@
6060
android:layout_height="wrap_content"
6161
app:description="@string/developer_options_performance_monitor" />
6262

63+
<org.mozilla.vrbrowser.ui.views.settings.SwitchSetting
64+
android:id="@+id/debug_logging_switch"
65+
android:layout_width="match_parent"
66+
android:layout_height="wrap_content"
67+
app:description="@string/developer_options_debug_logging" />
68+
6369
<org.mozilla.vrbrowser.ui.views.settings.SwitchSetting
6470
android:id="@+id/servo_switch"
6571
android:layout_width="match_parent"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
<string name="settings_key_browser_world_width" translatable="false">settings_browser_world_width</string>
4545
<string name="settings_key_browser_world_height" translatable="false">settings_browser_world_height</string>
4646
<string name="settings_key_notifications" translatable="false">settings_key_notifications</string>
47+
<string name="settings_key_debug_logging" translatable="false">settings_key_debug_logging</string>
4748
<string name="environment_override_help_url" translatable="false">https://github.com/MozillaReality/FirefoxReality/wiki/Environments</string>
4849
<string name="private_policy_url" translatable="false">https://www.mozilla.org/privacy/firefox/</string>
4950
<string name="private_report_url" translatable="false">https://mixedreality.mozilla.org/fxr/report?src=browser-fxr&amp;label=browser-firefox-reality&amp;url=%1$s</string>

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,18 @@
275275
A dialog should appear with a field labeled with the text, 'Enable Multiprocess'. -->
276276
<string name="developer_options_multiprocess">Enable Multiprocess</string>
277277

278-
<!-- This string labels and On/Off switch in the developer options dialog and is used to toggle
278+
<!-- This string labels an On/Off switch in the developer options dialog and is used to toggle
279279
the performance monitor. The Performance monitor is used to detect pages that cause the
280280
browser to run below a target framerate and pauses the page to restore performance.
281281
-->
282282
<string name="developer_options_performance_monitor">Enable Performance Monitor</string>
283283

284+
<!-- This string labels an On/Off switch in the developer options dialog and is used to toggle
285+
debug logging. Debug logging provides runtime diagnostic information that may be collected
286+
to help diagnose and fix problems with the application.
287+
-->
288+
<string name="developer_options_debug_logging">Enable Debug Logging</string>
289+
284290
<!-- The string labels an On/Off switch in the developer options dialog and is used to toggle enabling Servo. -->
285291
<string name="developer_options_servo">Enable Servo</string>
286292

0 commit comments

Comments
 (0)