oxen-io / session-android

A private messenger for Android.
https://getsession.org
GNU General Public License v3.0
1.88k stars 173 forks source link

How to I restore my messages after a clean flash? #1309

Open 2011 opened 1 year ago

2011 commented 1 year ago

Code of conduct

Describe the bug

I recently had to clean flash my device. I backed up session (neobackup) , and also backed up every file on date. After restoring session (including the databases), it won't even start (crashes immediately). Does someway exist to restore the database of messeges, and if not, does some way exist to "offline" recover the messages in the database without adding them to the current instance?

Screenshots or logs

[08-30 21:49:51.977 1628:4071 I/ActivityTaskManager]
START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=network.loki.messenger/.RoutingActivity bnds=[566,776][704,1016]} from uid 10147

[08-30 21:49:51.987 1628:4071 V/SplashScreenExceptionList]
SplashScreen checking exception for package network.loki.messenger (target sdk:33) -> false

[08-30 21:49:52.004 1628:1824 I/ActivityManager]
Start proc 26350:network.loki.messenger/u0a220 for next-top-activity {network.loki.messenger/network.loki.messenger.RoutingActivity}

[08-30 21:49:52.007 1628:6940 D/CoreBackPreview]
Window{3237b6 u0 Splash Screen network.loki.messenger}: Setting back callback OnBackInvokedCallbackInfo{mCallback=android.window.IOnBackInvokedCallback$Stub$Proxy@f4d338d, mPriority=0}

[08-30 21:49:52.095 26350:26350 V/GraphicsEnvironment]
ANGLE Developer option for 'network.loki.messenger' set to: 'default'

[08-30 21:49:52.095 26350:26350 V/GraphicsEnvironment]
ANGLE GameManagerService for network.loki.messenger: false

[08-30 21:49:52.258 26350:26350 E/AndroidRuntime]
FATAL EXCEPTION: main
Process: network.loki.messenger, PID: 26350
java.lang.RuntimeException: Unable to create application org.thoughtcrime.securesms.ApplicationContext: java.lang.NullPointerException: Attempt to invoke virtual method 'javax.crypto.SecretKey java.security.KeyStore$SecretKeyEntry.getSecretKey()' on a null object reference
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6776)
        at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2129)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7884)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'javax.crypto.SecretKey java.security.KeyStore$SecretKeyEntry.getSecretKey()' on a null object reference
        at org.thoughtcrime.securesms.crypto.KeyStoreHelper.getSecretKey(KeyStoreHelper.java:127)
        at org.thoughtcrime.securesms.crypto.KeyStoreHelper.getKeyStoreEntry(KeyStoreHelper.java:113)
        at org.thoughtcrime.securesms.crypto.KeyStoreHelper.unseal(KeyStoreHelper.java:70)
        at org.thoughtcrime.securesms.crypto.DatabaseSecretProvider.getEncryptedDatabaseSecret(DatabaseSecretProvider.java:58)
        at org.thoughtcrime.securesms.crypto.DatabaseSecretProvider.getOrCreateDatabaseSecret(DatabaseSecretProvider.java:29)
        at org.thoughtcrime.securesms.dependencies.DatabaseModule.provideOpenHelper(DatabaseModule.kt:34)
        at org.thoughtcrime.securesms.dependencies.DatabaseModule_ProvideOpenHelperFactory.provideOpenHelper(DatabaseModule_ProvideOpenHelperFactory.java:33)
        at org.thoughtcrime.securesms.DaggerApplicationContext_HiltComponents_SingletonC$SwitchingProvider.get(DaggerApplicationContext_HiltComponents_SingletonC.java:1344)
        at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
        at org.thoughtcrime.securesms.DaggerApplicationContext_HiltComponents_SingletonC$SwitchingProvider.get(DaggerApplicationContext_HiltComponents_SingletonC.java:1341)
        at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
        at org.thoughtcrime.securesms.DaggerApplicationContext_HiltComponents_SingletonC.injectApplicationContext2(DaggerApplicationContext_HiltComponents_SingletonC.java:463)
        at org.thoughtcrime.securesms.DaggerApplicationContext_HiltComponents_SingletonC.injectApplicationContext(DaggerApplicationContext_HiltComponents_SingletonC.java:318)
        at org.thoughtcrime.securesms.Hilt_ApplicationContext.onCreate(Hilt_ApplicationContext.java:41)
        at org.thoughtcrime.securesms.ApplicationContext.onCreate(ApplicationContext.java:209)
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1280)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6771)
        ... 9 more

[08-30 21:49:52.263 1628:6940 W/ActivityTaskManager]
  Force finishing activity network.loki.messenger/.RoutingActivity

[08-30 21:49:52.268 1628:1804 I/ActivityManager]
Showing crash dialog for package network.loki.messenger u0

[08-30 21:49:52.313 1628:1804 D/CoreBackPreview]
Window{5625eb4 u0 Application Error: network.loki.messenger}: Setting back callback OnBackInvokedCallbackInfo{mCallback=android.window.WindowOnBackInvokedDispatcher$OnBackInvokedCallbackWrapper@591987f, mPriority=0}

[08-30 21:49:52.763 1628:1807 W/ActivityTaskManager]
Activity top resumed state loss timeout for ActivityRecord{f9cbddb u0 network.loki.messenger/.RoutingActivity} t127 f}}

[08-30 21:49:52.765 1628:1807 W/ActivityTaskManager]
Activity pause timeout for ActivityRecord{f9cbddb u0 network.loki.messenger/.RoutingActivity} t127 f}}

[08-30 21:49:52.806 1628:1808 W/InputManager-JNI]
Input channel object '3237b6 Splash Screen network.loki.messenger (client)' was disposed without first being removed with the input manager!

[08-30 21:49:57.091 1628:1804 D/CoreBackPreview]
Window{5625eb4 u0 Application Error: network.loki.messenger}: Setting back callback null

[08-30 21:49:57.091 1628:6940 W/WindowManager]
  Force finishing activity network.loki.messenger/.RoutingActivity

[08-30 21:49:57.101 1628:6940 I/ActivityManager]
Killing 26350:network.loki.messenger/u0a220 (adj 900): crash

[08-30 21:49:57.102 1628:1804 W/InputManager-JNI]
Input channel object '5625eb4 Application Error: network.loki.messenger (client)' was disposed without first being removed with the input manager!

[08-30 21:49:57.151 1628:1708 V/ActivityManager]
Got obituary of 26350:network.loki.messenger

Smartphone (please complete the following information):

hjubb commented 1 year ago

This looks like the entire DB and all the preferences including which keys to use for decrypting are not part of the restoration (as they are kept in the android key store, not in the application itself). If there is a way to restore keys that were in the android key store as part of your device restoration that would possibly solve the issue

2011 commented 1 year ago

I would like to put in another plea here for simple message export capabilities. For me, I value the ability to encrypt data in transit, but other participants in conversations can always compromise messages (copying them or taking screenshots - from another device if necessary), so keeping communications completely secure depends on them, as well as the program. Making message archiving difficult creates a false sense of security for that reason, and many use cases (say a lawyer who must retain communications with clients in an easily accessible manner, but wants to avoid unencrypted messaging and file transfers) would benefit from the ability to export (and then remove, which would improve the performance of the program, as well) conversations, or parts thereof. Anyone can make plain text copies now (in a painfully slow manner - one message at a time). Adding that capability for Session to do that much more efficiently would (in the vast majority of cases) make the program more valuable for users.