From 150755800eb79d9891ec1c01f70b4186116120ad Mon Sep 17 00:00:00 2001 From: Jonathan Almeida Date: Wed, 26 Aug 2020 17:47:23 -0400 Subject: [PATCH] [fenix] Disabling StrictMode policy for Top Sites changes --- .../java/org/mozilla/fenix/components/Core.kt | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/components/Core.kt b/app/src/main/java/org/mozilla/fenix/components/Core.kt index 4b3d23d030..3b0a5bdb85 100644 --- a/app/src/main/java/org/mozilla/fenix/components/Core.kt +++ b/app/src/main/java/org/mozilla/fenix/components/Core.kt @@ -7,6 +7,7 @@ package org.mozilla.fenix.components import GeckoProvider import android.content.Context import android.content.res.Configuration +import android.os.StrictMode import io.sentry.Sentry import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope @@ -58,6 +59,7 @@ import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.R import org.mozilla.fenix.downloads.DownloadService import org.mozilla.fenix.ext.components +import org.mozilla.fenix.ext.resetPoliciesAfter import org.mozilla.fenix.ext.settings import org.mozilla.fenix.media.MediaService import org.mozilla.fenix.search.telemetry.ads.AdsTelemetry @@ -266,31 +268,33 @@ class Core(private val context: Context, private val crashReporter: CrashReporti val topSiteStorage by lazy { val defaultTopSites = mutableListOf>() - if (!context.settings().defaultTopSitesAdded) { - defaultTopSites.add( - Pair( - context.getString(R.string.default_top_site_google), - SupportUtils.GOOGLE_URL - ) - ) - - if (LocaleManager.getSelectedLocale(context).language == "en") { + StrictMode.allowThreadDiskReads().resetPoliciesAfter { + if (!context.settings().defaultTopSitesAdded) { defaultTopSites.add( Pair( - context.getString(R.string.pocket_pinned_top_articles), - SupportUtils.POCKET_TRENDING_URL + context.getString(R.string.default_top_site_google), + SupportUtils.GOOGLE_URL ) ) - } - defaultTopSites.add( - Pair( - context.getString(R.string.default_top_site_wikipedia), - SupportUtils.WIKIPEDIA_URL + if (LocaleManager.getSelectedLocale(context).language == "en") { + defaultTopSites.add( + Pair( + context.getString(R.string.pocket_pinned_top_articles), + SupportUtils.POCKET_TRENDING_URL + ) + ) + } + + defaultTopSites.add( + Pair( + context.getString(R.string.default_top_site_wikipedia), + SupportUtils.WIKIPEDIA_URL + ) ) - ) - context.settings().defaultTopSitesAdded = true + context.settings().defaultTopSitesAdded = true + } } DefaultTopSitesStorage(