johanw666 / Signal-Android

Fork from a private messenger for Android with extra options added: full backup and (partial, ony text) xml backup of messages. Restore can happen at any time, not only after a fresh install. Import SMS database. Import of (unencrypted) WhatsApp databases. Removed apk expire. Choose between passphrase protection and the Android screenlock. Choice for the backup location (internal or removable storage on Android < 11 (on 11 and higher this is already possible)). Set the maptype in the place picker. Option to treat view-once media as normal media. Option to ignore remote deletion. Choose between FCM or websocket notification delivery.
https://johanw.home.xs4all.nl/Signal/signal-jw.html
GNU Affero General Public License v3.0
250 stars 16 forks source link

Encrypted / plaintext backup fails #14

Open 1dud3 opened 3 years ago

1dud3 commented 3 years ago

Bug description

Unable to create neither encrypted backup nor plaintext backup. Permission to access storage is requested, but it's already granted.

Steps to reproduce

Actual result: Asking for permission to storage, which has already been granted. No backup created. (No issues saving images, videos etc.) Expected result: Plaintext or encrypted backup.

Remark

In addition to debug log linked below, separate logcat app lists the following entry: "E/TaskPersister( 2944): File error accessing recents directory (directory doesn't exist?)."

Screenshots

Screenshot_20201101-015509_Signal Screenshot_20201101-022700_Permission_controller Screenshot_20201101-022707_Permission_controller

Device info

Device: Motorola Moto E2 2015 LTE (surnia) Android version: Android 10 / LineageOS 17.1 (lineage-17.1-20201030-nightly) Signal version: 4.75.7.0-JW

Link to debug log

https://debuglogs.org/424c0ed84be4efe096b99663af0bfa96d5bb2b9dca4dbdfe6bfc06387cfdb567

johanw666 commented 3 years ago

I can't find any crash but I should add more logging to test what is going on. Are you trying to export the backups to removable storage or to internal storage?

Could be some Android 10 or LineageOS specific bug, unfortunately I don't have devices with those versions to test it on.

Recent changes for Android 10 and higher were made in the normal backup. Does that backup work? It should ask for a backup location if you activate that the first time.

1dud3 commented 3 years ago

That's weird... I can create an encrypted backup going via settings > chats & media. The option to backup to sd card is gone, but after activating automatic backup, I can select any folder on internal and external storage. But it's still impossible to create neither plaintext nor encrypted backup via import / export. On top I successfully made a plaintext backup last month on the same device without any issues.

Screenshot_20201101-151532_Signal

johanw666 commented 3 years ago

The option to backup to sd card is gone

Yes, on Android 10 the same base directory is used as the one for the normal backup. Since the switch would be ignored anyway in the code I made it invisible for Android >= 10.

Something must have gone wrong, probably with the permissions and the new Android 10 code. I'll check it out.

thinkbrown commented 3 years ago

FWIW, this also appears to be happening attempting a plaintext import under Android 10 on a Moto G7.

johanw666 commented 3 years ago

I implemented a quick hack in 4.75.8.0-JW that might fix this problem temporarily until I can implement a proper solution, but I can not test it. It works on lower versions of Android the same as before. Can anyone with Android 10 please try if the standard backup works, and encrypted / plaintext backup too?

thinkbrown commented 3 years ago

I should be able to take a look at it tonight.

1dud3 commented 3 years ago

"Export successful"

Plaintext backup is working again on my device with LOS 17.1/Android 10.

Thank you very, very much.

thinkbrown commented 3 years ago

Confirmed that the import begins after renaming the backup and moving it to the right location. However, the backup times out after 10 seconds. Checked the log and it reports

java.util.concurrent.TimeoutException: net.sqlcipher.database.SQLiteCompiledSql.finalize() timed out after 10 seconds

I'm gonna go ahead and open another issue for this, since it doesn't appear to be related to file IO anymore.

johanw666 commented 3 years ago

owever, the backup times out after 10 seconds.

This import problem is indeed something else. For a temporarily solution to get going, can you manually split the xml file and import it in parts?

May I ask how big that import file is? My xml export is around 12MB but I never tried to import it completely.

thinkbrown commented 3 years ago

The xml backup file is ~5.7GiB, so splitting it up isn't exactly an easy solution.

johanw666 commented 3 years ago

Oof! That large for an xml backup, that are really a lot of messages. On my current test device I could not even test that, it would run out of storage during import. I can see if I can do the split during import, current import is done in one single database transaction, that might be too much.

thinkbrown commented 3 years ago

@johanw666 Has there been any progress on splitting the database import?

johanw666 commented 3 years ago

Not yet, I've been working on getting import / export to work with Android 10 at all. It now works as it did before, but a nice proper solution probably requires the MANAGE_EXTERNAL_STORAGE permission from Android 11 because a lot of functuions require access to the File api.

ljanders0n commented 3 years ago

That's my issue I believe. When I attempt to export as plaintext I get "Cannot write to storage". The app has access to media, but there is no other storage access option.

zoidy commented 3 years ago

I have the same issue as ljanders0n. I'm on Android 11. Upon trying to export I get the error "Error, unable to write to storage". The standard Signal backup works just fine. I was excited to find this fork as I want to migrate away from WhatsApp but the very limited export functionality gave me pause. It'd be great to have the option for an automated, unencrypted backup as well

johanw666 commented 2 years ago

OK, for Android 11 I implemented a solution in 5.23.1. It needs some polishing in the coming releases but it works for me at the moment on an Android 11 device. Import / Export on Android 10 will remain tricky with fixed directories and needing to give access via Chats - Backups first.

vocux commented 2 years ago

I have the same problem, Android 10 on an Honor8x 5.29.1.0-JW. Gave persmission to storage and to a specific folder via Chats - Backups but all I get is "Error, unable to write storage". Standard encrypted backups via Chats - Backups work fine.

johanw666 commented 2 years ago

On Android 10 my fork only supports exports to [internal or removable storage]/Android/data/org.thoughtcrime.securesms/files/Signal/ . This limitation was unfortunately necessary for Android 10, where it works in the same way as Android 4 - 9 to make the full and plaintrext backup working. On Android 11 and higher the backup can be stored anywhere.