For #6464: Replace use of BuildConfig.DEBUG with ReleaseChannel.channel.isDebug.
This fixes performance issues where StrictMode would greatly slow down startup in the forPerformanceTest variants.master
parent
ac97dd72b1
commit
cf143489e1
|
@ -6,7 +6,7 @@ import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import mozilla.components.browser.engine.gecko.glean.GeckoAdapter
|
import mozilla.components.browser.engine.gecko.glean.GeckoAdapter
|
||||||
import mozilla.components.lib.crash.handler.CrashHandlerService
|
import mozilla.components.lib.crash.handler.CrashHandlerService
|
||||||
import org.mozilla.fenix.BuildConfig
|
import org.mozilla.fenix.Config
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.utils.Settings
|
||||||
import org.mozilla.geckoview.GeckoRuntime
|
import org.mozilla.geckoview.GeckoRuntime
|
||||||
import org.mozilla.geckoview.GeckoRuntimeSettings
|
import org.mozilla.geckoview.GeckoRuntimeSettings
|
||||||
|
@ -36,7 +36,7 @@ object GeckoProvider {
|
||||||
.crashHandler(CrashHandlerService::class.java)
|
.crashHandler(CrashHandlerService::class.java)
|
||||||
.useContentProcessHint(true)
|
.useContentProcessHint(true)
|
||||||
.telemetryDelegate(GeckoAdapter())
|
.telemetryDelegate(GeckoAdapter())
|
||||||
.debugLogging(BuildConfig.DEBUG)
|
.debugLogging(Config.channel.isDebug)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
if (!Settings.getInstance(context).shouldUseAutoSize) {
|
if (!Settings.getInstance(context).shouldUseAutoSize) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import mozilla.components.browser.engine.gecko.glean.GeckoAdapter
|
import mozilla.components.browser.engine.gecko.glean.GeckoAdapter
|
||||||
import mozilla.components.lib.crash.handler.CrashHandlerService
|
import mozilla.components.lib.crash.handler.CrashHandlerService
|
||||||
import org.mozilla.fenix.BuildConfig
|
import org.mozilla.fenix.Config
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.utils.Settings
|
||||||
import org.mozilla.geckoview.GeckoRuntime
|
import org.mozilla.geckoview.GeckoRuntime
|
||||||
import org.mozilla.geckoview.GeckoRuntimeSettings
|
import org.mozilla.geckoview.GeckoRuntimeSettings
|
||||||
|
@ -36,7 +36,7 @@ object GeckoProvider {
|
||||||
.crashHandler(CrashHandlerService::class.java)
|
.crashHandler(CrashHandlerService::class.java)
|
||||||
.useContentProcessHint(true)
|
.useContentProcessHint(true)
|
||||||
.telemetryDelegate(GeckoAdapter())
|
.telemetryDelegate(GeckoAdapter())
|
||||||
.debugLogging(BuildConfig.DEBUG)
|
.debugLogging(Config.channel.isDebug)
|
||||||
.aboutConfigEnabled(true)
|
.aboutConfigEnabled(true)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
|
|
@ -278,7 +278,7 @@ open class FenixApplication : Application() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun enableStrictMode() {
|
private fun enableStrictMode() {
|
||||||
if (BuildConfig.DEBUG) {
|
if (Config.channel.isDebug) {
|
||||||
StrictMode.setThreadPolicy(
|
StrictMode.setThreadPolicy(
|
||||||
StrictMode.ThreadPolicy.Builder()
|
StrictMode.ThreadPolicy.Builder()
|
||||||
.detectAll()
|
.detectAll()
|
||||||
|
|
|
@ -5,44 +5,44 @@
|
||||||
package org.mozilla.fenix.ext
|
package org.mozilla.fenix.ext
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import org.mozilla.fenix.BuildConfig
|
import org.mozilla.fenix.Config
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will print to `Log.d()` only when [BuildConfig.DEBUG] is enabled.
|
* Will print to `Log.d()` only for debug release channels.
|
||||||
*
|
*
|
||||||
* Meant to be used for logs that should not be visible in the production app.
|
* Meant to be used for logs that should not be visible in the production app.
|
||||||
*/
|
*/
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
inline fun logDebug(tag: String, message: String) {
|
inline fun logDebug(tag: String, message: String) {
|
||||||
if (BuildConfig.DEBUG) Log.d(tag, message)
|
if (Config.channel.isDebug) Log.d(tag, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will print to `Log.w()` only when [BuildConfig.DEBUG] is enabled.
|
* Will print to `Log.w()` only for debug release channels.
|
||||||
*
|
*
|
||||||
* Meant to be used for logs that should not be visible in the production app.
|
* Meant to be used for logs that should not be visible in the production app.
|
||||||
*/
|
*/
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
inline fun logWarn(tag: String, message: String) {
|
inline fun logWarn(tag: String, message: String) {
|
||||||
if (BuildConfig.DEBUG) Log.w(tag, message)
|
if (Config.channel.isDebug) Log.w(tag, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will print to `Log.w()` only when [BuildConfig.DEBUG] is enabled.
|
* Will print to `Log.w()` only for debug release channels.
|
||||||
*
|
*
|
||||||
* Meant to be used for logs that should not be visible in the production app.
|
* Meant to be used for logs that should not be visible in the production app.
|
||||||
*/
|
*/
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
inline fun logWarn(tag: String, message: String, err: Throwable) {
|
inline fun logWarn(tag: String, message: String, err: Throwable) {
|
||||||
if (BuildConfig.DEBUG) Log.w(tag, message, err)
|
if (Config.channel.isDebug) Log.w(tag, message, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will print to `Log.e()` only when [BuildConfig.DEBUG] is enabled.
|
* Will print to `Log.e()` only for debug release channels.
|
||||||
*
|
*
|
||||||
* Meant to be used for logs that should not be visible in the production app.
|
* Meant to be used for logs that should not be visible in the production app.
|
||||||
*/
|
*/
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
inline fun logErr(tag: String, message: String, err: Throwable) {
|
inline fun logErr(tag: String, message: String, err: Throwable) {
|
||||||
if (BuildConfig.DEBUG) Log.e(tag, message, err)
|
if (Config.channel.isDebug) Log.e(tag, message, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
package org.mozilla.fenix.ext
|
package org.mozilla.fenix.ext
|
||||||
|
|
||||||
import org.mozilla.fenix.TestApplication
|
import org.mozilla.fenix.TestApplication
|
||||||
|
@ -10,14 +14,13 @@ import io.mockk.mockkStatic
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.mozilla.fenix.BuildConfig
|
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner::class)
|
@RunWith(RobolectricTestRunner::class)
|
||||||
@Config(application = TestApplication::class)
|
@Config(application = TestApplication::class)
|
||||||
|
|
||||||
class LogTest {
|
class LogTest {
|
||||||
|
|
||||||
val numCalls = if (BuildConfig.DEBUG) 1 else 0
|
val numCalls = if (org.mozilla.fenix.Config.channel.isDebug) 1 else 0
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
|
|
Loading…
Reference in New Issue