Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
for #11615 allowed strictMode disk read for violations made by the OS. (
Browse files Browse the repository at this point in the history
  • Loading branch information
sraturi committed Jun 21, 2020
1 parent 56ff4e4 commit 9269a53
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
6 changes: 5 additions & 1 deletion app/src/main/java/org/mozilla/fenix/FenixApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,11 @@ open class FenixApplication : LocaleAwareApplication() {
// are not triggered when also using createConfigurationContext like we do in LocaleManager
// https://issuetracker.google.com/issues/143570309#comment3
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 {
Expand Down
13 changes: 10 additions & 3 deletions app/src/main/java/org/mozilla/fenix/IntentReceiverActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package org.mozilla.fenix
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.os.StrictMode
import androidx.annotation.VisibleForTesting
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch
Expand All @@ -15,6 +16,7 @@ import org.mozilla.fenix.components.IntentProcessorType
import org.mozilla.fenix.components.getType
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.resetPoliciesAfter
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.perf.StartupTimeline
import org.mozilla.fenix.shortcut.NewTabShortcutIntentProcessor
Expand All @@ -26,7 +28,10 @@ class IntentReceiverActivity : Activity() {

@VisibleForTesting
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// StrictMode violation on certain devices such as Samsung
StrictMode.allowThreadDiskReads().resetPoliciesAfter {
super.onCreate(savedInstanceState)
}

MainScope().launch {
// The intent property is nullable, but the rest of the code below
Expand Down Expand Up @@ -57,8 +62,10 @@ class IntentReceiverActivity : Activity() {
intentProcessorType.shouldOpenToBrowser(intent)
)
}

startActivity(intent)
// StrictMode violation on certain devices such as Samsung
StrictMode.allowThreadDiskReads().resetPoliciesAfter {
startActivity(intent)
}
finish() // must finish() after starting the other activity
}

Expand Down
32 changes: 18 additions & 14 deletions app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package org.mozilla.fenix.browser

import android.content.Context
import android.os.Bundle
import android.os.StrictMode
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand Down Expand Up @@ -40,6 +41,7 @@ import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.ext.navigateSafe
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.ext.resetPoliciesAfter
import org.mozilla.fenix.shortcut.FirstTimePwaObserver
import org.mozilla.fenix.trackingprotection.TrackingProtectionOverlay

Expand Down Expand Up @@ -90,22 +92,24 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
browserToolbarView.view.addPageAction(readerModeAction)

readerViewFeature.set(
feature = ReaderViewFeature(
context,
components.core.engine,
components.core.store,
view.readerViewControlsBar
) { available, active ->
if (available) {
components.analytics.metrics.track(Event.ReaderModeAvailable)
}
feature = StrictMode.allowThreadDiskReads().resetPoliciesAfter {
ReaderViewFeature(
context,
components.core.engine,
components.core.store,
view.readerViewControlsBar
) { available, active ->
if (available) {
components.analytics.metrics.track(Event.ReaderModeAvailable)
}

readerModeAvailable = available
readerModeAction.setSelected(active)
readerModeAvailable = available
readerModeAction.setSelected(active)

runIfFragmentIsAttached {
browserToolbarView.view.invalidateActions()
browserToolbarView.toolbarIntegration.invalidateMenu()
runIfFragmentIsAttached {
browserToolbarView.view.invalidateActions()
browserToolbarView.toolbarIntegration.invalidateMenu()
}
}
},
owner = this,
Expand Down

0 comments on commit 9269a53

Please sign in to comment.