Repository: thunderbird/thunderbird-android (language: kotlin)

Issue:
Cannot disable "New mail notifcations" in 11.0b1
### Checklist

- [x] I have used the search function to see if someone else has already submitted the same bug report.
- [x] I will describe the problem with as much detail as possible.

### App

Thunderbird for Android

### App version

11.0b1

### Where did you get the app from?

Play store

### Android version

15

### Device model

Pixel 9 Pro

### Steps to reproduce

* Go to General settings->Select an account->Notifications
* Remove check mark for "New mail notifications"
* Hit back arrow
* Go to Notifications again
* "New mail notifications" contains check mark

### Expected behavior

"New mail notifications" check mark removal should be persistent

### Actual behavior

"New mail notifications" contains check mark after I removed it

### Logs

_No response_


Discussion hints:
Can confirm, thanks for reporting!
@kewisch  please assign this to me.

Pull request: Fixed Bug - Cannot disable New mail notifcations
- Fixes #9135 

Test command: ./gradlew :legacy:storage:testDebugUnitTest --tests "com.fsck.k9.preferences.StorageEditorTest" --tests "com.fsck.k9.preferences.StoragePersisterTest" :legacy:core:testDebugUnitTest --tests "com.fsck.k9.mailstore.K9BackendDefaultStorageTest"

Fix patch:
diff --git a/app-common/src/main/kotlin/net/thunderbird/app/common/account/CommonAccountDefaultsProvider.kt b/app-common/src/main/kotlin/net/thunderbird/app/common/account/CommonAccountDefaultsProvider.kt
index 6340304b5fe..ac91610b935 100644
--- a/app-common/src/main/kotlin/net/thunderbird/app/common/account/CommonAccountDefaultsProvider.kt
+++ b/app-common/src/main/kotlin/net/thunderbird/app/common/account/CommonAccountDefaultsProvider.kt
@@ -27,6 +27,7 @@ import app.k9mail.legacy.account.ShowPictures
 import com.fsck.k9.CoreResourceProvider
 import com.fsck.k9.K9
 import net.thunderbird.core.mail.folder.api.SpecialFolderSelection
+import net.thunderbird.core.preferences.Storage
 import net.thunderbird.feature.notification.NotificationLight
 import net.thunderbird.feature.notification.NotificationSettings
 import net.thunderbird.feature.notification.NotificationVibration
@@ -41,20 +42,25 @@ internal class CommonAccountDefaultsProvider(
         applyLegacyDefaults()
     }
 
-    override fun applyOverwrites(account: LegacyAccount) = with(account) {
-        isNotifyNewMail = featureFlagProvider.provide(
-            "email_notification_default".toFeatureFlagKey(),
-        ).whenEnabledOrNot(
-            onEnabled = { true },
-            onDisabledOrUnavailable = { false },
-        )
+    override fun applyOverwrites(account: LegacyAccount, storage: Storage) = with(account) {
+        if (storage.contains("${account.uuid}.notifyNewMail")) {
+            isNotifyNewMail = storage.getBoolean("${account.uuid}.notifyNewMail", false)
+            isNotifySelfNewMail = storage.getBoolean("${account.uuid}.notifySelfNewMail", true)
+        } else {
+            isNotifyNewMail = featureFlagProvider.provide(
+                "email_notification_default".toFeatureFlagKey(),
+            ).whenEnabledOrNot(
+                onEnabled = { true },
+                onDisabledOrUnavailable = { false },
+            )
 
-        isNotifySelfNewMail = featureFlagProvider.provide(
-            "email_notification_default".toFeatureFlagKey(),
-        ).whenEnabledOrNot(
-            onEnabled = { true },
-            onDisabledOrUnavailable = { false },
-        )
+            isNotifySelfNewMail = featureFlagProvider.provide(
+                "email_notification_default".toFeatureFlagKey(),
+            ).whenEnabledOrNot(
+                onEnabled = { true },
+                onDisabledOrUnavailable = { false },
+            )
+        }
     }
 
     @Suppress("LongMethod")
diff --git a/core/preferences/src/main/java/net/thunderbird/core/preferences/Storage.kt b/core/preferences/src/main/java/net/thunderbird/core/preferences/Storage.kt
new file mode 100644
index 00000000000..c54e75afff5
--- /dev/null
+++ b/core/preferences/src/main/java/net/thunderbird/core/preferences/Storage.kt
@@ -0,0 +1,17 @@
+package net.thunderbird.core.preferences
+
+interface Storage {
+    fun isEmpty(): Boolean
+
+    fun contains(key: String): Boolean
+
+    fun getAll(): Map<String, String>
+
+    fun getBoolean(key: String, defValue: Boolean): Boolean
+
+    fun getInt(key: String, defValue: Int): Int
+
+    fun getLong(key: String, defValue: Long): Long
+
+    fun getString(key: String?, defValue: String?): String
+}
diff --git a/legacy/account/build.gradle.kts b/legacy/account/build.gradle.kts
index 19768910725..29e4f3fb2a9 100644
--- a/legacy/account/build.gradle.kts
+++ b/legacy/account/build.gradle.kts
@@ -12,6 +12,7 @@ dependencies {
     api(projects.mail.common)
 
     implementation(projects.core.account)
+    implementation(projects.core.preferences)
     implementation(projects.core.mail.folder.api)
     implementation(projects.backend.api)
 }
diff --git a/legacy/account/src/main/java/app/k9mail/legacy/account/AccountDefaultsProvider.kt b/legacy/account/src/main/java/app/k9mail/legacy/account/AccountDefaultsProvider.kt
index 1e9575ec960..dbb481a44f1 100644
--- a/legacy/account/src/main/java/app/k9mail/legacy/account/AccountDefaultsProvider.kt
+++ b/legacy/account/src/main/java/app/k9mail/legacy/account/AccountDefaultsProvider.kt
@@ -1,5 +1,7 @@
 package app.k9mail.legacy.account
 
+import net.thunderbird.core.preferences.Storage
+
 interface AccountDefaultsProvider {
     /**
      * Apply default values to the account.
@@ -13,7 +15,7 @@ interface AccountDefaultsProvider {
      *
      * This method should be called when updating an existing account.
      */
-    fun applyOverwrites(account: LegacyAccount)
+    fun applyOverwrites(account: LegacyAccount, storage: Storage)
 
     companion object {
         const val DEFAULT_MAXIMUM_AUTO_DOWNLOAD_MESSAGE_SIZE = 131072
diff --git a/legacy/core/src/main/java/com/fsck/k9/AccountPreferenceSerializer.kt b/legacy/core/src/main/java/com/fsck/k9/AccountPreferenceSerializer.kt
index 2aa2ac2c19c..a6490400c85 100644
--- a/legacy/core/src/main/java/com/fsck/k9/AccountPreferenceSerializer.kt
+++ b/legacy/core/src/main/java/com/fsck/k9/AccountPreferenceSerializer.kt
@@ -24,9 +24,9 @@ import app.k9mail.legacy.account.QuoteStyle
 import app.k9mail.legacy.account.ShowPictures
 import app.k9mail.legacy.account.SortType
 import com.fsck.k9.helper.Utility
-import com.fsck.k9.preferences.Storage
 import com.fsck.k9.preferences.StorageEditor
 import net.thunderbird.core.mail.folder.api.SpecialFolderSelection
+import net.thunderbird.core.preferences.Storage
 import net.thunderbird.feature.notification.NotificationLight
 import net.thunderbird.feature.notification.NotificationSettings
 import net.thunderbird.feature.notification.NotificationVibration
diff --git a/legacy/core/src/main/java/com/fsck/k9/FontSizes.kt b/legacy/core/src/main/java/com/fsck/k9/FontSizes.kt
index bd34843a92f..ab866fb40e6 100644
--- a/legacy/core/src/main/java/com/fsck/k9/FontSizes.kt
+++ b/legacy/core/src/main/java/com/fsck/k9/FontSizes.kt
@@ -2,8 +2,8 @@ package com.fsck.k9
 
 import android.util.TypedValue
 import android.widget.TextView
-import com.fsck.k9.preferences.Storage
 import com.fsck.k9.preferences.StorageEditor
+import net.thunderbird.core.preferences.Storage
 
 /**
  * Manage font size of the information displayed in the message list and in the message view.
diff --git a/legacy/core/src/main/java/com/fsck/k9/K9.kt b/legacy/core/src/main/java/com/fsck/k9/K9.kt
index d05ee56423e..9c2fd253a2f 100644
--- a/legacy/core/src/main/java/com/fsck/k9/K9.kt
+++ b/legacy/core/src/main/java/com/fsck/k9/K9.kt
@@ -13,9 +13,9 @@ import com.fsck.k9.logging.Logger
 import com.fsck.k9.mail.K9MailLib
 import com.fsck.k9.mailstore.LocalStore
 import com.fsck.k9.preferences.RealGeneralSettingsManager
-import com.fsck.k9.preferences.Storage
 import com.fsck.k9.preferences.StorageEditor
 import kotlinx.datetime.Clock
+import net.thunderbird.core.preferences.Storage
 import org.koin.core.component.KoinComponent
 import org.koin.core.component.inject
 import timber.log.Timber
diff --git a/legacy/core/src/main/java/com/fsck/k9/Preferences.kt b/legacy/core/src/main/java/com/fsck/k9/Preferences.kt
index b3af621dd18..ed38273f39c 100644
--- a/legacy/core/src/main/java/com/fsck/k9/Preferences.kt
+++ b/legacy/core/src/main/java/com/fsck/k9/Preferences.kt
@@ -11,7 +11,6 @@ import app.k9mail.legacy.account.LegacyAccount
 import app.k9mail.legacy.di.DI
 import com.fsck.k9.mail.MessagingException
 import com.fsck.k9.mailstore.LocalStoreProvider
-import com.fsck.k9.preferences.Storage
 import com.fsck.k9.preferences.StorageEditor
 import com.fsck.k9.preferences.StoragePersister
 import java.util.LinkedList
@@ -27,6 +26,7 @@ import kotlinx.coroutines.flow.Flow
 import kotlinx.coroutines.flow.buffer
 import kotlinx.coroutines.flow.callbackFlow
 import kotlinx.coroutines.flow.flowOn
+import net.thunderbird.core.preferences.Storage
 import timber.log.Timber
 
 @Suppress("MaxLineLength")
@@ -91,7 +91,7 @@ class Preferences internal constructor(
 
                     accounts[uuid] = account
                     accountsInOrder.add(account)
-                    accountDefaultsProvider.applyOverwrites(account)
+                    accountDefaultsProvider.applyOverwrites(account, storage)
                 }
             }
 
diff --git a/legacy/core/src/main/java/com/fsck/k9/preferences/Storage.java b/legacy/core/src/main/java/com/fsck/k9/preferences/DefaultStorage.java
similarity index 71%
rename from legacy/core/src/main/java/com/fsck/k9/preferences/Storage.java
rename to legacy/core/src/main/java/com/fsck/k9/preferences/DefaultStorage.java
index a515d5825cf..5c42666b054 100644
--- a/legacy/core/src/main/java/com/fsck/k9/preferences/Storage.java
+++ b/legacy/core/src/main/java/com/fsck/k9/preferences/DefaultStorage.java
@@ -4,28 +4,35 @@
 import java.util.Collections;
 import java.util.Map;
 
+import androidx.annotation.NonNull;
+import net.thunderbird.core.preferences.Storage;
 import timber.log.Timber;
 
-public class Storage {
+public class DefaultStorage implements Storage {
     private final Map<String, String> values;
 
-    public Storage(Map<String, String> values) {
+    public DefaultStorage(Map<String, String> values) {
         this.values = Collections.unmodifiableMap(values);
     }
 
+    @Override
     public boolean isEmpty() {
         return values.isEmpty();
     }
 
-    public boolean contains(String key) {
+    @Override
+    public boolean contains(@NonNull String key) {
         return values.containsKey(key);
     }
 
+    @NonNull
+    @Override
     public Map<String, String> getAll() {
         return values;
     }
 
-    public boolean getBoolean(String key, boolean defValue) {
+    @Override
+    public boolean getBoolean(@NonNull String key, boolean defValue) {
         String val = values.get(key);
         if (val == null) {
             return defValue;
@@ -33,7 +40,8 @@ public boolean getBoolean(String key, boolean defValue) {
         return Boolean.parseBoolean(val);
     }
 
-    public int getInt(String key, int defValue) {
+    @Override
+    public int getInt(@NonNull String key, int defValue) {
         String val = values.get(key);
         if (val == null) {
             return defValue;
@@ -46,7 +54,8 @@ public int getInt(String key, int defValue) {
         }
     }
 
-    public long getLong(String key, long defValue) {
+    @Override
+    public long getLong(@NonNull String key, long defValue) {
         String val = values.get(key);
         if (val == null) {
             return defValue;
@@ -59,6 +68,8 @@ public long getLong(String key, long defValue) {
         }
     }
 
+    @NonNull
+    @Override
     public String getString(String key, String defValue) {
         String val = values.get(key);
         if (val == null) {
diff --git a/legacy/core/src/main/java/com/fsck/k9/preferences/GeneralSettingsDescriptions.java b/legacy/core/src/main/java/com/fsck/k9/preferences/GeneralSettingsDescriptions.java
index 7a430181441..f4cd974e834 100644
--- a/legacy/core/src/main/java/com/fsck/k9/preferences/GeneralSettingsDescriptions.java
+++ b/legacy/core/src/main/java/com/fsck/k9/preferences/GeneralSettingsDescriptions.java
@@ -40,6 +40,7 @@
 import com.fsck.k9.preferences.upgrader.GeneralSettingsUpgraderTo79;
 import com.fsck.k9.preferences.upgrader.GeneralSettingsUpgraderTo89;
 import net.thunderbird.core.preferences.AppTheme;
+import net.thunderbird.core.preferences.Storage;
 import net.thunderbird.core.preferences.SubTheme;
 
 import static com.fsck.k9.K9.LockScreenNotificationVisibility;
diff --git a/legacy/core/src/main/java/com/fsck/k9/preferences/RealGeneralSettingsManager.kt b/legacy/core/src/main/java/com/fsck/k9/preferences/RealGeneralSettingsManager.kt
index 76d4c395e8d..6179987b0e7 100644
--- a/legacy/core/src/main/java/com/fsck/k9/preferences/RealGeneralSettingsManager.kt
+++ b/legacy/core/src/main/java/com/fsck/k9/preferences/RealGeneralSettingsManager.kt
@@ -16,6 +16,7 @@ import net.thunderbird.core.preferences.BackgroundSync
 import net.thunderbird.core.preferences.GeneralSettings
 import net.thunderbird.core.preferences.GeneralSettingsManager
 import net.thunderbird.core.preferences.SettingsChangePublisher
+import net.thunderbird.core.preferences.Storage
 import net.thunderbird.core.preferences.SubTheme
 import timber.log.Timber
 
diff --git a/legacy/core/src/main/java/com/fsck/k9/preferences/SettingsExporter.kt b/legacy/core/src/main/java/com/fsck/k9/preferences/SettingsExporter.kt
index 43cb57a1b38..4c8745003b9 100644
--- a/legacy/core/src/main/java/com/fsck/k9/preferences/SettingsExporter.kt
+++ b/legacy/core/src/main/java/com/fsck/k9/preferences/SettingsExporter.kt
@@ -66,7 +66,7 @@ class SettingsExporter(
 
             val storage = preferences.storage
 
-            val prefs: Map<String, Any> = storage.all.toSortedMap()
+            val prefs: Map<String, Any> = storage.getAll().toSortedMap()
             if (includeGlobals) {
                 serializer.startTag(null, GLOBAL_ELEMENT)
                 writeSettings(serializer, prefs)
diff --git a/legacy/core/src/main/java/com/fsck/k9/preferences/StoragePersister.kt b/legacy/core/src/main/java/com/fsck/k9/preferences/StoragePersister.kt
index 5f14f6d4c3a..193df11590f 100644
--- a/legacy/core/src/main/java/com/fsck/k9/preferences/StoragePersister.kt
+++ b/legacy/core/src/main/java/com/fsck/k9/preferences/StoragePersister.kt
@@ -1,5 +1,7 @@
 package com.fsck.k9.preferences
 
+import net.thunderbird.core.preferences.Storage
+
 interface StoragePersister {
     fun loadValues(): Storage
 
diff --git a/legacy/storage/src/main/java/com/fsck/k9/preferences/K9StorageEditor.java b/legacy/storage/src/main/java/com/fsck/k9/preferences/K9StorageEditor.java
index 74a6266cd61..bc6bb6243ff 100644
--- a/legacy/storage/src/main/java/com/fsck/k9/preferences/K9StorageEditor.java
+++ b/legacy/storage/src/main/java/com/fsck/k9/preferences/K9StorageEditor.java
@@ -11,6 +11,7 @@
 
 import com.fsck.k9.preferences.K9StoragePersister.StoragePersistOperationCallback;
 import com.fsck.k9.preferences.K9StoragePersister.StoragePersistOperations;
+import net.thunderbird.core.preferences.Storage;
 import timber.log.Timber;
 
 
@@ -74,7 +75,7 @@ public void onPersistTransactionSuccess(Map<String, String> workingStorage) {
         long endTime = SystemClock.elapsedRealtime();
         Timber.i("Preferences commit took %d ms", endTime - startTime);
 
-        return new Storage(newValues);
+        return new DefaultStorage(newValues);
     }
 
     @Override
diff --git a/legacy/storage/src/main/java/com/fsck/k9/preferences/K9StoragePersister.java b/legacy/storage/src/main/java/com/fsck/k9/preferences/K9StoragePersister.java
index c5d1c034c29..e8d628a394a 100644
--- a/legacy/storage/src/main/java/com/fsck/k9/preferences/K9StoragePersister.java
+++ b/legacy/storage/src/main/java/com/fsck/k9/preferences/K9StoragePersister.java
@@ -15,6 +15,7 @@
 import com.fsck.k9.preferences.migration.DefaultStorageMigrationHelper;
 import com.fsck.k9.preferences.migration.StorageMigrations;
 import com.fsck.k9.preferences.migration.StorageMigrationHelper;
+import net.thunderbird.core.preferences.Storage;
 import timber.log.Timber;
 
 
@@ -143,7 +144,7 @@ public Storage loadValues() {
         Timber.i("Loading preferences from DB into Storage");
 
         try (SQLiteDatabase database = openDB()) {
-            return new Storage(readAllValues(database));
+            return new DefaultStorage(readAllValues(database));
         } finally {
             long endTime = SystemClock.elapsedRealtime();
             Timber.i("Preferences load took %d ms", endTime - startTime);


Test patch:
diff --git a/app-common/src/test/kotlin/net/thunderbird/app/common/account/CommonAccountDefaultsProviderTest.kt b/app-common/src/test/kotlin/net/thunderbird/app/common/account/CommonAccountDefaultsProviderTest.kt
index b31bff47e5e..ed5c374c430 100644
--- a/app-common/src/test/kotlin/net/thunderbird/app/common/account/CommonAccountDefaultsProviderTest.kt
+++ b/app-common/src/test/kotlin/net/thunderbird/app/common/account/CommonAccountDefaultsProviderTest.kt
@@ -30,6 +30,7 @@ import assertk.assertions.isTrue
 import com.fsck.k9.CoreResourceProvider
 import com.fsck.k9.K9
 import net.thunderbird.core.mail.folder.api.SpecialFolderSelection
+import net.thunderbird.core.preferences.Storage
 import net.thunderbird.feature.notification.NotificationLight
 import net.thunderbird.feature.notification.NotificationSettings
 import net.thunderbird.feature.notification.NotificationVibration
@@ -147,6 +148,11 @@ class CommonAccountDefaultsProviderTest {
             uuid = "test-uuid",
             isSensitiveDebugLoggingEnabled = { false },
         )
+        val storage = mock<Storage> {
+            on { contains("${account.uuid}.notifyNewMail") } doReturn false
+            on { getBoolean("${account.uuid}.notifyNewMail", false) } doReturn false
+            on { getBoolean("${account.uuid}.notifySelfNewMail", false) } doReturn false
+        }
         val testSubject = CommonAccountDefaultsProvider(
             resourceProvider = resourceProvider,
             featureFlagProvider = {
@@ -155,7 +161,7 @@ class CommonAccountDefaultsProviderTest {
         )
 
         // act
-        testSubject.applyOverwrites(account)
+        testSubject.applyOverwrites(account, storage)
 
         // assert
         assertThat(account.isNotifyNewMail).isFalse()
@@ -172,6 +178,73 @@ class CommonAccountDefaultsProviderTest {
             uuid = "test-uuid",
             isSensitiveDebugLoggingEnabled = { false },
         )
+        val storage = mock<Storage> {
+            on { contains("${account.uuid}.notifyNewMail") } doReturn false
+            on { getBoolean("${account.uuid}.notifyNewMail", false) } doReturn false
+            on { getBoolean("${account.uuid}.notifySelfNewMail", false) } doReturn false
+        }
+        val testSubject = CommonAccountDefaultsProvider(
+            resourceProvider = resourceProvider,
+            featureFlagProvider = {
+                FeatureFlagResult.Enabled
+            },
+        )
+
+        // act
+        testSubject.applyOverwrites(account, storage)
+
+        // assert
+        assertThat(account.isNotifyNewMail).isTrue()
+        assertThat(account.isNotifySelfNewMail).isTrue()
+    }
+
+    @Suppress("MaxLineLength")
+    @Test
+    fun `applyOverwrites updates account notification values from storage when storage contains isNotifyNewMail value`() {
+        // arrange
+        val resourceProvider = mock<CoreResourceProvider> {
+            on { defaultIdentityDescription() } doReturn "Default Identity"
+        }
+        val account = LegacyAccount(
+            uuid = "test-uuid",
+            isSensitiveDebugLoggingEnabled = { false },
+        )
+        val storage = mock<Storage> {
+            on { contains("${account.uuid}.notifyNewMail") } doReturn true
+            on { getBoolean("${account.uuid}.notifyNewMail", false) } doReturn false
+            on { getBoolean("${account.uuid}.notifySelfNewMail", false) } doReturn false
+        }
+        val testSubject = CommonAccountDefaultsProvider(
+            resourceProvider = resourceProvider,
+            featureFlagProvider = {
+                FeatureFlagResult.Enabled
+            },
+        )
+
+        // act
+        testSubject.applyOverwrites(account, storage)
+
+        // assert
+        assertThat(account.isNotifyNewMail).isFalse()
+        assertThat(account.isNotifySelfNewMail).isFalse()
+    }
+
+    @Suppress("MaxLineLength")
+    @Test
+    fun `applyOverwrites updates account notification values from featureFlag values when storage does not contain isNotifyNewMail value`() {
+        // arrange
+        val resourceProvider = mock<CoreResourceProvider> {
+            on { defaultIdentityDescription() } doReturn "Default Identity"
+        }
+        val account = LegacyAccount(
+            uuid = "test-uuid",
+            isSensitiveDebugLoggingEnabled = { false },
+        )
+        val storage = mock<Storage> {
+            on { contains("${account.uuid}.notifyNewMail") } doReturn false
+            on { getBoolean("${account.uuid}.notifyNewMail", false) } doReturn false
+            on { getBoolean("${account.uuid}.notifySelfNewMail", false) } doReturn false
+        }
         val testSubject = CommonAccountDefaultsProvider(
             resourceProvider = resourceProvider,
             featureFlagProvider = {
@@ -180,7 +253,7 @@ class CommonAccountDefaultsProviderTest {
         )
 
         // act
-        testSubject.applyOverwrites(account)
+        testSubject.applyOverwrites(account, storage)
 
         // assert
         assertThat(account.isNotifyNewMail).isTrue()
diff --git a/core/android/testing/src/main/kotlin/net/thunderbird/core/android/preferences/InMemoryStoragePersister.kt b/core/android/testing/src/main/kotlin/net/thunderbird/core/android/preferences/InMemoryStoragePersister.kt
index 60ea25bcaf4..0c622e71f81 100644
--- a/core/android/testing/src/main/kotlin/net/thunderbird/core/android/preferences/InMemoryStoragePersister.kt
+++ b/core/android/testing/src/main/kotlin/net/thunderbird/core/android/preferences/InMemoryStoragePersister.kt
@@ -1,15 +1,20 @@
 package net.thunderbird.core.android.preferences
 
-import com.fsck.k9.preferences.Storage
+import com.fsck.k9.preferences.DefaultStorage
 import com.fsck.k9.preferences.StorageEditor
 import com.fsck.k9.preferences.StoragePersister
 import com.fsck.k9.preferences.StorageUpdater
+import net.thunderbird.core.preferences.Storage
 
 class InMemoryStoragePersister : StoragePersister {
     private val values = mutableMapOf<String, Any?>()
 
     override fun loadValues(): Storage {
-        return Storage(values.mapValues { (_, value) -> value?.toString() ?: "" })
+        return DefaultStorage(
+            values.mapValues { (_, value) ->
+                value?.toString() ?: ""
+            },
+        )
     }
 
     override fun createStorageEditor(storageUpdater: StorageUpdater): StorageEditor {
@@ -60,7 +65,7 @@ class InMemoryStoragePersister : StoragePersister {
         }
 
         private fun writeValues(currentStorage: Storage): Storage {
-            return Storage(currentStorage.all - removals + changes)
+            return DefaultStorage(currentStorage.getAll() - removals + changes)
         }
     }
 }
diff --git a/legacy/core/src/test/java/com/fsck/k9/mailstore/K9BackendStorageTest.kt b/legacy/core/src/test/java/com/fsck/k9/mailstore/K9BackendDefaultStorageTest.kt
similarity index 96%
rename from legacy/core/src/test/java/com/fsck/k9/mailstore/K9BackendStorageTest.kt
rename to legacy/core/src/test/java/com/fsck/k9/mailstore/K9BackendDefaultStorageTest.kt
index bf65252c3f9..88f3ca875d5 100644
--- a/legacy/core/src/test/java/com/fsck/k9/mailstore/K9BackendStorageTest.kt
+++ b/legacy/core/src/test/java/com/fsck/k9/mailstore/K9BackendDefaultStorageTest.kt
@@ -15,7 +15,7 @@ import org.mockito.kotlin.any
 import org.mockito.kotlin.doReturn
 import org.mockito.kotlin.mock
 
-class K9BackendStorageTest : K9RobolectricTest() {
+class K9BackendDefaultStorageTest : K9RobolectricTest() {
     val preferences: Preferences by inject()
     val messageStoreManager: MessageStoreManager by inject()
     val saveMessageDataCreator: SaveMessageDataCreator by inject()
@@ -62,6 +62,7 @@ class K9BackendStorageTest : K9RobolectricTest() {
         assertThat(value).isEqualTo(23L)
     }
 
+    @Suppress("ForbiddenComment")
     fun createAccount(): LegacyAccount {
         // FIXME: This is a hack to get Preferences into a state where it's safe to call newAccount()
         preferences.clearAccounts()
diff --git a/legacy/core/src/test/java/net/thunderbird/legacy/core/FakeAccountDefaultsProvider.kt b/legacy/core/src/test/java/net/thunderbird/legacy/core/FakeAccountDefaultsProvider.kt
index 71ff560d41d..63f7048051d 100644
--- a/legacy/core/src/test/java/net/thunderbird/legacy/core/FakeAccountDefaultsProvider.kt
+++ b/legacy/core/src/test/java/net/thunderbird/legacy/core/FakeAccountDefaultsProvider.kt
@@ -3,6 +3,7 @@ package net.thunderbird.legacy.core
 import app.k9mail.legacy.account.AccountDefaultsProvider
 import app.k9mail.legacy.account.Identity
 import app.k9mail.legacy.account.LegacyAccount
+import net.thunderbird.core.preferences.Storage
 
 class FakeAccountDefaultsProvider : AccountDefaultsProvider {
     override fun applyDefaults(account: LegacyAccount) {
@@ -20,5 +21,5 @@ class FakeAccountDefaultsProvider : AccountDefaultsProvider {
         }
     }
 
-    override fun applyOverwrites(account: LegacyAccount) = Unit
+    override fun applyOverwrites(account: LegacyAccount, storage: Storage) = Unit
 }
diff --git a/legacy/storage/src/test/java/com/fsck/k9/preferences/StorageEditorTest.kt b/legacy/storage/src/test/java/com/fsck/k9/preferences/StorageEditorTest.kt
index cbb09cf5ff9..5b7eec55d04 100644
--- a/legacy/storage/src/test/java/com/fsck/k9/preferences/StorageEditorTest.kt
+++ b/legacy/storage/src/test/java/com/fsck/k9/preferences/StorageEditorTest.kt
@@ -8,6 +8,7 @@ import assertk.assertions.isTrue
 import com.fsck.k9.preferences.K9StoragePersister.StoragePersistOperationCallback
 import com.fsck.k9.preferences.K9StoragePersister.StoragePersistOperations
 import com.fsck.k9.storage.K9RobolectricTest
+import net.thunderbird.core.preferences.Storage
 import org.junit.Test
 import org.mockito.ArgumentMatchers.any
 import org.mockito.kotlin.doAnswer
@@ -17,8 +18,9 @@ import org.mockito.kotlin.stubbing
 import org.mockito.kotlin.verify
 import org.mockito.kotlin.verifyNoMoreInteractions
 
-class StorageEditorTest : K9RobolectricTest() {
-    private val storage: Storage = Storage(mapOf("storage-key" to "storage-value"))
+class DefaultStorageEditorTest : K9RobolectricTest() {
+    private val storage: Storage =
+        DefaultStorage(mapOf("storage-key" to "storage-value"))
     private val storageUpdater = TestStorageUpdater(storage)
     private val storagePersister = mock<K9StoragePersister>()
     private val storagePersisterOps = mock<StoragePersistOperations>()
@@ -27,7 +29,7 @@ class StorageEditorTest : K9RobolectricTest() {
     private val workingMap = mutableMapOf<String, String>()
 
     private val newValues: Map<String, String>
-        get() = storageUpdater.newStorage!!.all
+        get() = storageUpdater.newStorage!!.getAll()
 
     @Test
     fun commit_exception() {
@@ -47,7 +49,7 @@ class StorageEditorTest : K9RobolectricTest() {
         val success = editor.commit()
 
         assertThat(success).isTrue()
-        assertThat(newValues).isEqualTo(storage.all)
+        assertThat(newValues).isEqualTo(storage.getAll())
 
         verifyNoMoreInteractions(storagePersisterOps)
     }
diff --git a/legacy/storage/src/test/java/com/fsck/k9/preferences/StoragePersisterTest.kt b/legacy/storage/src/test/java/com/fsck/k9/preferences/StoragePersisterTest.kt
index 58424c924b6..bfa2ab377e8 100644
--- a/legacy/storage/src/test/java/com/fsck/k9/preferences/StoragePersisterTest.kt
+++ b/legacy/storage/src/test/java/com/fsck/k9/preferences/StoragePersisterTest.kt
@@ -48,7 +48,7 @@ class StoragePersisterTest : K9RobolectricTest() {
 
         storagePersister.doInTransaction(operationCallback)
 
-        val values = storagePersister.loadValues().all
+        val values = storagePersister.loadValues().getAll()
 
         assertThat(values).containsOnly("x" to "y")
     }
@@ -69,7 +69,7 @@ class StoragePersisterTest : K9RobolectricTest() {
 
         val values = storagePersister.loadValues()
 
-        assertThat(values.isEmpty).isTrue()
+        assertThat(values.isEmpty()).isTrue()
         verify(operationCallback, never()).onPersistTransactionSuccess(any())
     }
 
@@ -87,7 +87,7 @@ class StoragePersisterTest : K9RobolectricTest() {
 
         val values = storagePersister.loadValues()
 
-        assertThat(values.isEmpty).isTrue()
+        assertThat(values.isEmpty()).isTrue()
     }
 
     @Test
@@ -103,7 +103,7 @@ class StoragePersisterTest : K9RobolectricTest() {
 
         val values = storagePersister.loadValues()
 
-        assertThat(values.isEmpty).isTrue()
+        assertThat(values.isEmpty()).isTrue()
     }
 
     private fun prepareCallback(