Skip to content

Commit

Permalink
For mozilla-mobile#13959: remove unused penaltyDialog parameter.
Browse files Browse the repository at this point in the history
Additional branching introduces complexity so we should avoid it when
possible. This branch was also unused so it's more likely to have bugs
if we tried to use it after some refactor.
  • Loading branch information
mcomella committed Sep 28, 2020
1 parent f05a542 commit c03c7ef
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions app/src/main/java/org/mozilla/fenix/StrictModeManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,15 @@ object StrictModeManager {
/***
* Enables strict mode for debug purposes. meant to be run only in the main process.
* @param setPenaltyDeath boolean value to decide setting the penaltyDeath as a penalty.
* @param setPenaltyDialog boolean value to decide setting the dialog box as a penalty.
* Note: dialog penalty cannot be set with penaltyDeath
*/
fun enableStrictMode(setPenaltyDeath: Boolean, setPenaltyDialog: Boolean = false) {
fun enableStrictMode(setPenaltyDeath: Boolean) {
if (Config.channel.isDebug) {
val threadPolicy = StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog()
if (setPenaltyDeath && Build.MANUFACTURER !in strictModeExceptionList) {
threadPolicy.penaltyDeath()
}

// dialog penalty cannot be set with penaltyDeath
if (!setPenaltyDeath && setPenaltyDialog) {
threadPolicy.penaltyDialog()
}

StrictMode.setThreadPolicy(threadPolicy.build())

val builder = StrictMode.VmPolicy.Builder()
Expand Down Expand Up @@ -62,7 +54,7 @@ object StrictModeManager {
fragmentManager.registerFragmentLifecycleCallbacks(object :
FragmentManager.FragmentLifecycleCallbacks() {
override fun onFragmentResumed(fm: FragmentManager, f: Fragment) {
enableStrictMode(setPenaltyDeath = false, setPenaltyDialog = false)
enableStrictMode(setPenaltyDeath = false)
fm.unregisterFragmentLifecycleCallbacks(this)
}
}, false)
Expand Down

0 comments on commit c03c7ef

Please sign in to comment.