Skip to content

Commit

Permalink
Remove always-on isUsingRustBackend
Browse files Browse the repository at this point in the history
  • Loading branch information
dae committed Jun 18, 2022
1 parent daf4ce9 commit 2ddbe7d
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 18 deletions.
4 changes: 2 additions & 2 deletions AnkiDroid/src/main/java/com/ichi2/anki/Preferences.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions AnkiDroid/src/main/java/com/ichi2/libanki/Collection.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -2496,8 +2496,6 @@ open class Collection @VisibleForTesting constructor(
return sched
}

val isUsingRustBackend: Boolean
get() = droidBackend.isUsingRustBackend()
open val backend: DroidBackend
get() = droidBackend

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ interface DroidBackend {
fun closeCollection(db: DB?, downgradeToSchema11: Boolean)

fun databaseCreationInitializesData(): Boolean
fun isUsingRustBackend(): Boolean

@VisibleForTesting(otherwise = VisibleForTesting.NONE)
fun debugEnsureNoOpenPointers()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit 2ddbe7d

Please sign in to comment.