From 2ddbe7d6c9fab06ceebee5e33dd7220122a6f9c7 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 17 Jun 2022 18:04:06 +1000 Subject: [PATCH] Remove always-on isUsingRustBackend --- AnkiDroid/src/main/java/com/ichi2/anki/Preferences.kt | 4 ++-- .../java/com/ichi2/anki/servicelayer/DebugInfoService.kt | 7 +------ AnkiDroid/src/main/java/com/ichi2/libanki/Collection.kt | 4 +--- .../main/java/com/ichi2/libanki/backend/DroidBackend.kt | 2 -- .../java/com/ichi2/libanki/backend/RustDroidBackend.kt | 5 ----- 5 files changed, 4 insertions(+), 18 deletions(-) diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/Preferences.kt b/AnkiDroid/src/main/java/com/ichi2/anki/Preferences.kt index 1a42c748c77d..d4f5e428a04f 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/Preferences.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/Preferences.kt @@ -259,7 +259,7 @@ class Preferences : AnkiActivity() { NEW_TIMEZONE_HANDLING -> { val switch = pref as SwitchPreference switch.isChecked = col.sched._new_timezone_enabled() - if (col.schedVer() <= 1 || !col.isUsingRustBackend) { + if (col.schedVer() <= 1) { Timber.d("Disabled 'newTimezoneHandling' box") switch.isEnabled = false } @@ -616,7 +616,7 @@ class Preferences : AnkiActivity() { pm.setComponentEnabledSetting(providerName, state, PackageManager.DONT_KILL_APP) } NEW_TIMEZONE_HANDLING -> { - if (preferencesActivity.col.schedVer() != 1 && preferencesActivity.col.isUsingRustBackend) { + if (preferencesActivity.col.schedVer() != 1) { val sched = preferencesActivity.col.sched val wasEnabled = sched._new_timezone_enabled() val isEnabled = (pref as SwitchPreference).isChecked diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/servicelayer/DebugInfoService.kt b/AnkiDroid/src/main/java/com/ichi2/anki/servicelayer/DebugInfoService.kt index 2fcb16e0c878..c94328de6321 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/servicelayer/DebugInfoService.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/servicelayer/DebugInfoService.kt @@ -35,12 +35,7 @@ object DebugInfoService { } catch (e: Throwable) { Timber.e(e, "Sched name not found") } - var dbV2Enabled: Boolean? = null - try { - dbV2Enabled = col.get().isUsingRustBackend - } catch (e: Throwable) { - Timber.w(e, "Unable to detect Rust Backend") - } + var dbV2Enabled = true val webviewUserAgent = getWebviewUserAgent(info) return """ AnkiDroid Version = $pkgVersionName diff --git a/AnkiDroid/src/main/java/com/ichi2/libanki/Collection.kt b/AnkiDroid/src/main/java/com/ichi2/libanki/Collection.kt index 8f6e0f6f648b..f039c09fa30f 100644 --- a/AnkiDroid/src/main/java/com/ichi2/libanki/Collection.kt +++ b/AnkiDroid/src/main/java/com/ichi2/libanki/Collection.kt @@ -219,7 +219,7 @@ open class Collection @VisibleForTesting constructor( sched = Sched(this) } else if (ver == 2) { sched = SchedV2(this) - if (!server && isUsingRustBackend) { + if (!server) { try { set_config("localOffset", sched._current_timezone_offset()) } catch (e: BackendNotSupportedException) { @@ -2496,8 +2496,6 @@ open class Collection @VisibleForTesting constructor( return sched } - val isUsingRustBackend: Boolean - get() = droidBackend.isUsingRustBackend() open val backend: DroidBackend get() = droidBackend diff --git a/AnkiDroid/src/main/java/com/ichi2/libanki/backend/DroidBackend.kt b/AnkiDroid/src/main/java/com/ichi2/libanki/backend/DroidBackend.kt index 07427f2dc0d0..1d6704d5eaa4 100644 --- a/AnkiDroid/src/main/java/com/ichi2/libanki/backend/DroidBackend.kt +++ b/AnkiDroid/src/main/java/com/ichi2/libanki/backend/DroidBackend.kt @@ -40,8 +40,6 @@ interface DroidBackend { fun closeCollection(db: DB?, downgradeToSchema11: Boolean) fun databaseCreationInitializesData(): Boolean - fun isUsingRustBackend(): Boolean - @VisibleForTesting(otherwise = VisibleForTesting.NONE) fun debugEnsureNoOpenPointers() diff --git a/AnkiDroid/src/main/java/com/ichi2/libanki/backend/RustDroidBackend.kt b/AnkiDroid/src/main/java/com/ichi2/libanki/backend/RustDroidBackend.kt index e12f11217632..4905918e25c1 100644 --- a/AnkiDroid/src/main/java/com/ichi2/libanki/backend/RustDroidBackend.kt +++ b/AnkiDroid/src/main/java/com/ichi2/libanki/backend/RustDroidBackend.kt @@ -49,11 +49,6 @@ open class RustDroidBackend( override fun databaseCreationInitializesData(): Boolean { return false // only true in V16, not V11 } - - override fun isUsingRustBackend(): Boolean { - return true - } - override fun debugEnsureNoOpenPointers() { val result = backend.getBackend().getActiveSequenceNumbers() if (result.isNotEmpty()) {