Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Companion App doesn't work on privacy-focused Android distributions (CalyxOS, GrapheneOS) #55

Open
mrrfv opened this issue Mar 15, 2023 Discussed in #39 · 11 comments
Open
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@mrrfv
Copy link
Owner

mrrfv commented Mar 15, 2023

Discussed in #39

Originally posted by onley November 27, 2022

Does this still work under Android 12? I have tried to perform a backup twice, once using tar export and once using adb export and both times it failed at "Exporting contacts (as vCard)". When using adb export there was also an error message
adb: error: failed to stat remote object '/storage/emulated/0/linux-android-backup-temp/.': No such file or directory
apparently the companion app is unable to write to the device.


Report any possible clues regarding this problem as well as workarounds under this issue. Unfortunately I don't have any devices that could run either of these operating systems, so I'm unable to debug this without your help.

@mrrfv mrrfv pinned this issue Mar 15, 2023
@mrrfv mrrfv added bug Something isn't working help wanted Extra attention is needed labels Mar 15, 2023
@mrrfv
Copy link
Owner Author

mrrfv commented Apr 7, 2023

Can't test, but one possible solution is to disable Storage Scopes for Linux Android Backup and grant the storage permissions manually.

It's possible to do this by going to Settings -> Apps & notifications -> See all apps -> Linux Android Backup Companion -> Permissions -> Storage Scopes and toggling it off.

Then, storage permissions can be granted by going to Settings -> Apps & notifications -> See all apps -> Linux Android Backup Companion -> Permissions -> Files and media and choosing Allow management of all files.

@alex27riva
Copy link

I related issue: I did a backup on my Pixel 6a with stock Android and I restored it on GrapheneOS (on the same phone, after flashing it).
Apps are restored correctly, but some crash at startup. A reinstallation of the app fixes the problem.
Also, the internal storage data was not copied due to permission problems, I had to copy the folders manually using "adb push".

@mrrfv
Copy link
Owner Author

mrrfv commented May 14, 2023

What permission errors were you getting?

@alex27riva
Copy link

What permission errors were you getting?

Unfortunately, I didn't take a screenshot. But it was a very general error message.
If you don't have a Pixel phone with Graphene you can emulate it in Android Studio, although the steps to do the system build are not simple.

@lemzwerg
Copy link

I get the same problem on my Samsung Galaxy A40 that uses Android 11 (last automatic system update was in March 2023) . Running the backup script from the git repository I took the brute-force way of commenting out the offending code that tries to back up SMS and Contact information, and it continued.

diff --git a/functions/backup_func.sh b/functions/backup_func.sh
index 0a714da..81e37f9 100644
--- a/functions/backup_func.sh
+++ b/functions/backup_func.sh
@@ -55,13 +55,13 @@ function backup_func() {
   done
 
   # Export contacts and SMS messages
-  cecho "Exporting contacts (as vCard) and SMS messages (as CSV)."
-  mkdir ./backup-tmp/Contacts
-  get_file /storage/emulated/0/open-android-backup-temp . ./backup-tmp/Contacts
-  mkdir ./backup-tmp/SMS
-  mv ./backup-tmp/Contacts/SMS_Messages.csv ./backup-tmp/SMS
-  cecho "Removing temporary files created by the companion app."
-  adb shell rm -rf /storage/emulated/0/open-android-backup-temp
+#  cecho "Exporting contacts (as vCard) and SMS messages (as CSV)."
+#  mkdir ./backup-tmp/Contacts
+#  get_file /storage/emulated/0/open-android-backup-temp . ./backup-tmp/Contacts
+#  mkdir ./backup-tmp/SMS
+#  mv ./backup-tmp/Contacts/SMS_Messages.csv ./backup-tmp/SMS
+#  cecho "Removing temporary files created by the companion app."
+#  adb shell rm -rf /storage/emulated/0/open-android-backup-temp
 
   # Export internal storage
   cecho "Exporting internal storage - this will take a while."

Funnily, I still see 'Exporting contacts (as vCard) and SMS messages (as CSV).' on the terminal inspite of being commented out; I have no idea how this can happen...

Similarly, 'Exporting call logs' doesn't seem to work; I see

Exporting call logs.
Error while accessing provider:call_log
java.lang.SecurityException: Permission Denial: \
  opening provider com.android.providers.contacts.CallLogProvider from (null) (pid=18813, uid=2000) \
  requires android.permission.READ_CALL_LOG or android.permission.WRITE_CALL_LOG
        at android.os.Parcel.createExceptionOrNull(Parcel.java:2386)
        ...

but this didn't make the script abort.

@mrrfv
Copy link
Owner Author

mrrfv commented Jun 17, 2023

@lemzwerg Thanks for the info! However, to troubleshoot the issue you are facing, I need to see the logs when the script is run with no modifications. Could you please run the script as it is and send me the logs as an attachment or a link? This will help me understand what is going wrong and how to fix it. If you're worried the logs could contain identifying information, you can email them to me - my e-mail address can be found in my GitHub profile.

@lemzwerg
Copy link

Sorry for the late replay. Here it is.

~/samsung a40> LANG= LANGUAGE= .../git/open-android-backup/backup.sh
[...]
Couldn't find srm, a command provided by the 'secure-delete' package on Debian and Ubuntu. Secure removal of sensitive temporary files created by the script is unavailable - encrypting your disks is recommended.
Open Android Backup will install a companion app on your device, which will allow for contacts and other data to be backed up and restored.
The companion app is open-source, and you can see what it's doing under the hood on GitHub.
Companion app already downloaded.
Attempting to uninstall companion app.
Installing companion app.
Performing Streamed Install
Success
Granting required permissions to companion app.
Couldn't find any temporary files to cleanup, continuing. This is not an error.
Starting: Intent { cmp=mrrfv.backup.companion/.MainActivity }
The companion app has been opened on your device. Please press the 'Export Data' button - this will export contacts to the internal storage, allowing this script to backup them. Press Enter to continue.

Attempting to uninstall companion app.
Exporting apps.
Backing up app: com.skype.raider
[...many packages...]
Exporting contacts (as vCard) and SMS messages (as CSV).
0.00 B 0:00:00 [0.00 B/s] [<=>                                                                                  ]
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
Errors occurred while backing up . - this file (or multiple files) might've been ignored.
mv: cannot stat './backup-tmp/Contacts/SMS_Messages.csv': No such file or directory

@mrrfv
Copy link
Owner Author

mrrfv commented Jun 22, 2023

Just to confirm, did you press the "Export data" button when the Companion App was automatically opened on your device? This error usually shows up when this button isn't pressed.

Related issue: #63

@lemzwerg
Copy link

Yep, I did that.

@mrrfv
Copy link
Owner Author

mrrfv commented Feb 15, 2024

I can't reproduce this on the latest GrapheneOS 🙁

@lemzwerg
Copy link

Good news: I've just done a full backup without any problems of my Galaxy S40 (Android 11, Kernel 4.4.177 from 2023-Mar-24) on my GNU/Linux box using current git (f2c7e83).

In other words, the problem, whatever it was, has been solved for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants
@lemzwerg @alex27riva @mrrfv and others