commit a7ab2ffced7b6026b3c7039d66f3cc2a5d341eb4
parent be5a61e17d1204929abafe70cf472ef818723411
Author: rhunk <101876869+rhunk@users.noreply.github.com>
Date: Tue, 31 Oct 2023 14:58:46 +0100
fix(core/bridge): friend sync crash
- add missing explicit types
Diffstat:
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/bridge/BridgeClient.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/bridge/BridgeClient.kt
@@ -13,6 +13,7 @@ import de.robv.android.xposed.XposedHelpers
import me.rhunk.snapenhance.bridge.BridgeInterface
import me.rhunk.snapenhance.bridge.ConfigStateListener
import me.rhunk.snapenhance.bridge.DownloadCallback
+import me.rhunk.snapenhance.bridge.MessageLoggerInterface
import me.rhunk.snapenhance.bridge.SyncCallback
import me.rhunk.snapenhance.bridge.e2ee.E2eeInterface
import me.rhunk.snapenhance.bridge.scripting.IScripting
@@ -103,6 +104,7 @@ class BridgeClient(
fun broadcastLog(tag: String, level: String, message: String) = service.broadcastLog(tag, level, message)
+ //TODO: use interfaces instead of direct file access
fun createAndReadFile(
fileType: BridgeFileType,
defaultContent: ByteArray
@@ -123,11 +125,14 @@ class BridgeClient(
LocalePair(it.key, it.value)
}
- fun getApplicationApkPath() = service.getApplicationApkPath()
+ fun getApplicationApkPath(): String = service.getApplicationApkPath()
fun enqueueDownload(intent: Intent, callback: DownloadCallback) = service.enqueueDownload(intent, callback)
- fun sync(callback: SyncCallback) = service.sync(callback)
+ fun sync(callback: SyncCallback) {
+ if (!context.database.hasMain()) return
+ service.sync(callback)
+ }
fun triggerSync(scope: SocialScope, id: String) = service.triggerSync(scope.key, id)
@@ -148,7 +153,7 @@ class BridgeClient(
fun getE2eeInterface(): E2eeInterface = service.getE2eeInterface()
- fun getMessageLogger() = service.messageLogger
+ fun getMessageLogger(): MessageLoggerInterface = service.messageLogger
fun registerMessagingBridge(bridge: MessagingBridge) = service.registerMessagingBridge(bridge)
diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/database/DatabaseAccess.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/database/DatabaseAccess.kt
@@ -68,13 +68,13 @@ class DatabaseAccess(
}
}.onFailure {
context.log.error("Failed to open database $fileName, restarting!", it)
- context.softRestartApp()
}.getOrNull() ?: throw IllegalStateException("Failed to open database $fileName")
}
private fun openMain() = openLocalDatabase("main.db")
private fun openArroyo() = openLocalDatabase("arroyo.db")
+ fun hasMain(): Boolean = context.androidContext.getDatabasePath("main.db").exists()
fun hasArroyo(): Boolean = context.androidContext.getDatabasePath("arroyo.db").exists()
private fun <T : DatabaseObject> readDatabaseObject(