Skip to content

Commit

Permalink
Merge console and debug logging settings (#3474)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bluemarvin committed Jun 8, 2020
1 parent 9abea56 commit 26d72cf
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 51 deletions.
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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(
Expand Down
Expand Up @@ -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)
Expand All @@ -41,17 +40,16 @@ 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)
}

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())
Expand Down
Expand Up @@ -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);
Expand All @@ -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()) {
Expand All @@ -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);
};
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 0 additions & 6 deletions app/src/main/res/layout/options_developer.xml
Expand Up @@ -43,12 +43,6 @@
android:layout_height="wrap_content"
app:description="@string/developer_options_remote_debugging" />

<org.mozilla.vrbrowser.ui.views.settings.SwitchSetting
android:id="@+id/show_console_switch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:description="@string/developer_options_show_console" />

<org.mozilla.vrbrowser.ui.views.settings.SwitchSetting
android:id="@+id/performance_monitor_switch"
android:layout_width="match_parent"
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/res/values/strings.xml
Expand Up @@ -363,10 +363,6 @@
and is used to toggle remote debugging of website content in the application. -->
<string name="developer_options_remote_debugging">Enable Remote Debugging</string>

<!-- This string labels an On/Off switch in the 'Developer Options' dialog
and is used to toggle redirecting JavaScript Console output to the Android Logcat (i.e., `adb logcat`). -->
<string name="developer_options_show_console">Redirect Console to Logcat</string>

<!-- This string labels an On/Off switch in the developer options dialog
and is used to customize background environments of the app. -->
<string name="developer_options_env_override">Enable Environment Override</string>
Expand Down

0 comments on commit 26d72cf

Please sign in to comment.