1
0
Fork 0

for #11615 allowed strictMode disk read for violations made by the OS. (#11658)

master
Sachin 2020-06-21 14:54:49 -07:00 committed by GitHub
parent 56ff4e4797
commit 9269a53b21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 18 deletions

View File

@ -398,8 +398,12 @@ open class FenixApplication : LocaleAwareApplication() {
// are not triggered when also using createConfigurationContext like we do in LocaleManager // are not triggered when also using createConfigurationContext like we do in LocaleManager
// https://issuetracker.google.com/issues/143570309#comment3 // https://issuetracker.google.com/issues/143570309#comment3
applicationContext.resources.configuration.uiMode = config.uiMode applicationContext.resources.configuration.uiMode = config.uiMode
// random StrictMode onDiskRead violation even when Fenix is not running in the background.
StrictMode.allowThreadDiskReads().resetPoliciesAfter {
super.onConfigurationChanged(config) super.onConfigurationChanged(config)
} }
}
companion object { companion object {
private const val KINTO_ENDPOINT_PROD = "https://firefox.settings.services.mozilla.com/v1" private const val KINTO_ENDPOINT_PROD = "https://firefox.settings.services.mozilla.com/v1"

View File

@ -7,6 +7,7 @@ package org.mozilla.fenix
import android.app.Activity import android.app.Activity
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.os.StrictMode
import androidx.annotation.VisibleForTesting import androidx.annotation.VisibleForTesting
import kotlinx.coroutines.MainScope import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -15,6 +16,7 @@ import org.mozilla.fenix.components.IntentProcessorType
import org.mozilla.fenix.components.getType import org.mozilla.fenix.components.getType
import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.resetPoliciesAfter
import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.perf.StartupTimeline import org.mozilla.fenix.perf.StartupTimeline
import org.mozilla.fenix.shortcut.NewTabShortcutIntentProcessor import org.mozilla.fenix.shortcut.NewTabShortcutIntentProcessor
@ -26,7 +28,10 @@ class IntentReceiverActivity : Activity() {
@VisibleForTesting @VisibleForTesting
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
// StrictMode violation on certain devices such as Samsung
StrictMode.allowThreadDiskReads().resetPoliciesAfter {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
}
MainScope().launch { MainScope().launch {
// The intent property is nullable, but the rest of the code below // The intent property is nullable, but the rest of the code below
@ -57,8 +62,10 @@ class IntentReceiverActivity : Activity() {
intentProcessorType.shouldOpenToBrowser(intent) intentProcessorType.shouldOpenToBrowser(intent)
) )
} }
// StrictMode violation on certain devices such as Samsung
StrictMode.allowThreadDiskReads().resetPoliciesAfter {
startActivity(intent) startActivity(intent)
}
finish() // must finish() after starting the other activity finish() // must finish() after starting the other activity
} }

View File

@ -6,6 +6,7 @@ package org.mozilla.fenix.browser
import android.content.Context import android.content.Context
import android.os.Bundle import android.os.Bundle
import android.os.StrictMode
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -40,6 +41,7 @@ import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.ext.navigateSafe import org.mozilla.fenix.ext.navigateSafe
import org.mozilla.fenix.ext.requireComponents import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.ext.resetPoliciesAfter
import org.mozilla.fenix.shortcut.FirstTimePwaObserver import org.mozilla.fenix.shortcut.FirstTimePwaObserver
import org.mozilla.fenix.trackingprotection.TrackingProtectionOverlay import org.mozilla.fenix.trackingprotection.TrackingProtectionOverlay
@ -90,7 +92,8 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
browserToolbarView.view.addPageAction(readerModeAction) browserToolbarView.view.addPageAction(readerModeAction)
readerViewFeature.set( readerViewFeature.set(
feature = ReaderViewFeature( feature = StrictMode.allowThreadDiskReads().resetPoliciesAfter {
ReaderViewFeature(
context, context,
components.core.engine, components.core.engine,
components.core.store, components.core.store,
@ -107,6 +110,7 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
browserToolbarView.view.invalidateActions() browserToolbarView.view.invalidateActions()
browserToolbarView.toolbarIntegration.invalidateMenu() browserToolbarView.toolbarIntegration.invalidateMenu()
} }
}
}, },
owner = this, owner = this,
view = view view = view