Skip to content

Commit

Permalink
For mozilla-mobile#13959: rename to attachListenerToDisablePenaltyDea…
Browse files Browse the repository at this point in the history
…th for clarity.
  • Loading branch information
mcomella committed Sep 28, 2020
1 parent c03c7ef commit 2c1befa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/org/mozilla/fenix/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
private lateinit var navigationToolbar: Toolbar

final override fun onCreate(savedInstanceState: Bundle?) {
StrictModeManager.changeStrictModePolicies(supportFragmentManager)
StrictModeManager.attachListenerToDisablePenaltyDeath(supportFragmentManager)
// There is disk read violations on some devices such as samsung and pixel for android 9/10
StrictMode.allowThreadDiskReads().resetPoliciesAfter {
super.onCreate(savedInstanceState)
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/mozilla/fenix/StrictModeManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ object StrictModeManager {
}

/**
* Revert strict mode to disable penalty. Tied to fragment lifecycle since strict mode
* Revert strict mode to disable penalty based on fragment lifecycle since strict mode
* needs to switch to penalty logs. Using the fragment life cycle allows decoupling from any
* specific fragment.
*/
fun changeStrictModePolicies(fragmentManager: FragmentManager) {
fun attachListenerToDisablePenaltyDeath(fragmentManager: FragmentManager) {
fragmentManager.registerFragmentLifecycleCallbacks(object :
FragmentManager.FragmentLifecycleCallbacks() {
override fun onFragmentResumed(fm: FragmentManager, f: Fragment) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class StrictModeManagerTest {
fun `test changeStrictModePolicies`() {
val callbacks = slot<FragmentManager.FragmentLifecycleCallbacks>()

StrictModeManager.changeStrictModePolicies(fragmentManager)
StrictModeManager.attachListenerToDisablePenaltyDeath(fragmentManager)
verify { fragmentManager.registerFragmentLifecycleCallbacks(capture(callbacks), false) }
confirmVerified(fragmentManager)

Expand Down

0 comments on commit 2c1befa

Please sign in to comment.