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,7 +398,11 @@ 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
super.onConfigurationChanged(config)
// random StrictMode onDiskRead violation even when Fenix is not running in the background.
StrictMode.allowThreadDiskReads().resetPoliciesAfter {
super.onConfigurationChanged(config)
}
} }
companion object { companion object {

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?) {
super.onCreate(savedInstanceState) // StrictMode violation on certain devices such as Samsung
StrictMode.allowThreadDiskReads().resetPoliciesAfter {
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
startActivity(intent) StrictMode.allowThreadDiskReads().resetPoliciesAfter {
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,22 +92,24 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
browserToolbarView.view.addPageAction(readerModeAction) browserToolbarView.view.addPageAction(readerModeAction)
readerViewFeature.set( readerViewFeature.set(
feature = ReaderViewFeature( feature = StrictMode.allowThreadDiskReads().resetPoliciesAfter {
context, ReaderViewFeature(
components.core.engine, context,
components.core.store, components.core.engine,
view.readerViewControlsBar components.core.store,
) { available, active -> view.readerViewControlsBar
if (available) { ) { available, active ->
components.analytics.metrics.track(Event.ReaderModeAvailable) if (available) {
} components.analytics.metrics.track(Event.ReaderModeAvailable)
}
readerModeAvailable = available readerModeAvailable = available
readerModeAction.setSelected(active) readerModeAction.setSelected(active)
runIfFragmentIsAttached { runIfFragmentIsAttached {
browserToolbarView.view.invalidateActions() browserToolbarView.view.invalidateActions()
browserToolbarView.toolbarIntegration.invalidateMenu() browserToolbarView.toolbarIntegration.invalidateMenu()
}
} }
}, },
owner = this, owner = this,