mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-17 15:26:23 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/2765 - Run places maintenance daily (https://github.com/mozilla-mobile/fenix/pull/5466)
This commit is contained in:
parent
4f159819e2
commit
37a8bd2c89
@ -16,6 +16,7 @@ import kotlinx.coroutines.Deferred
|
|||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.async
|
import kotlinx.coroutines.async
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import mozilla.appservices.Megazord
|
import mozilla.appservices.Megazord
|
||||||
import mozilla.components.concept.push.PushProcessor
|
import mozilla.components.concept.push.PushProcessor
|
||||||
@ -110,6 +111,19 @@ open class FenixApplication : Application() {
|
|||||||
registerActivityLifecycleCallbacks(visibilityLifecycleCallback)
|
registerActivityLifecycleCallbacks(visibilityLifecycleCallback)
|
||||||
|
|
||||||
components.core.sessionManager.register(NotificationSessionObserver(this))
|
components.core.sessionManager.register(NotificationSessionObserver(this))
|
||||||
|
|
||||||
|
if ((System.currentTimeMillis() - this.settings.lastPlacesStorageMaintenance) > ONE_DAY_MILLIS) {
|
||||||
|
runStorageMaintenance()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun runStorageMaintenance() {
|
||||||
|
GlobalScope.launch(Dispatchers.IO) {
|
||||||
|
// Bookmarks and history storage sit on top of the same db file so we only need to
|
||||||
|
// run maintenance on one - arbitrarily using bookmarks.
|
||||||
|
components.core.bookmarksStorage.runMaintenance()
|
||||||
|
}
|
||||||
|
this.settings.lastPlacesStorageMaintenance = System.currentTimeMillis()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun registerRxExceptionHandling() {
|
private fun registerRxExceptionHandling() {
|
||||||
@ -288,9 +302,14 @@ open class FenixApplication : Application() {
|
|||||||
.detectActivityLeaks()
|
.detectActivityLeaks()
|
||||||
.detectFileUriExposure()
|
.detectFileUriExposure()
|
||||||
.penaltyLog()
|
.penaltyLog()
|
||||||
if (SDK_INT >= Build.VERSION_CODES.O) builder = builder.detectContentUriWithoutPermission()
|
if (SDK_INT >= Build.VERSION_CODES.O) builder =
|
||||||
|
builder.detectContentUriWithoutPermission()
|
||||||
if (SDK_INT >= Build.VERSION_CODES.P) builder = builder.detectNonSdkApiUsage()
|
if (SDK_INT >= Build.VERSION_CODES.P) builder = builder.detectNonSdkApiUsage()
|
||||||
StrictMode.setVmPolicy(builder.build())
|
StrictMode.setVmPolicy(builder.build())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val ONE_DAY_MILLIS = 24 * 60 * 60 * 1000
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ import mozilla.components.support.ktx.android.content.PreferencesHolder
|
|||||||
import mozilla.components.support.ktx.android.content.booleanPreference
|
import mozilla.components.support.ktx.android.content.booleanPreference
|
||||||
import mozilla.components.support.ktx.android.content.floatPreference
|
import mozilla.components.support.ktx.android.content.floatPreference
|
||||||
import mozilla.components.support.ktx.android.content.intPreference
|
import mozilla.components.support.ktx.android.content.intPreference
|
||||||
|
import mozilla.components.support.ktx.android.content.longPreference
|
||||||
import mozilla.components.support.ktx.android.content.stringPreference
|
import mozilla.components.support.ktx.android.content.stringPreference
|
||||||
import org.mozilla.fenix.BuildConfig
|
import org.mozilla.fenix.BuildConfig
|
||||||
import org.mozilla.fenix.Config
|
import org.mozilla.fenix.Config
|
||||||
@ -268,6 +269,11 @@ class Settings private constructor(
|
|||||||
default = true
|
default = true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var lastPlacesStorageMaintenance by longPreference(
|
||||||
|
appContext.getPreferenceKey(R.string.pref_key_last_maintenance),
|
||||||
|
default = 0
|
||||||
|
)
|
||||||
|
|
||||||
fun addSearchWidgetInstalled(count: Int) {
|
fun addSearchWidgetInstalled(count: Int) {
|
||||||
val key = appContext.getPreferenceKey(R.string.pref_key_search_widget_installed)
|
val key = appContext.getPreferenceKey(R.string.pref_key_search_widget_installed)
|
||||||
val newValue = preferences.getInt(key, 0) + count
|
val newValue = preferences.getInt(key, 0) + count
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
<string name="pref_key_delete_permissions_on_quit" translatable="false">pref_key_delete_permissions_on_quit</string>
|
<string name="pref_key_delete_permissions_on_quit" translatable="false">pref_key_delete_permissions_on_quit</string>
|
||||||
<string name="pref_key_delete_browsing_data_on_quit_categories" translatable="false">pref_key_delete_browsing_data_on_quit_categories</string>
|
<string name="pref_key_delete_browsing_data_on_quit_categories" translatable="false">pref_key_delete_browsing_data_on_quit_categories</string>
|
||||||
|
|
||||||
|
<string name="pref_key_last_maintenance" translatable="false">pref_key_last_maintenance</string>
|
||||||
<string name="pref_key_help" translatable="false">pref_key_help</string>
|
<string name="pref_key_help" translatable="false">pref_key_help</string>
|
||||||
<string name="pref_key_rate" translatable="false">pref_key_rate</string>
|
<string name="pref_key_rate" translatable="false">pref_key_rate</string>
|
||||||
<string name="pref_key_feedback" translatable="false">pref_key_feedback</string>
|
<string name="pref_key_feedback" translatable="false">pref_key_feedback</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user