oandbackup icon indicating copy to clipboard operation
oandbackup copied to clipboard

No full access to external SD card on Android 6

Open qwertfisch opened this issue 9 years ago • 7 comments

Since Android 6 changed the way of handling SDcards, it is no more possible to use backup/restore properly with an external SD card.

Android 6 offers two possibilities of using an SD card, in portable mode and in internal mode. The latter somehow maps the SD card transparently to sdcard (or sdcard0) – the same as the internal storage in earlier versions. In portable mode the SD card is used as before, except it receives another folder name, created from the UUID.

Expected and actual behaviour

I have flashed CM13 nightly (2016-03-05) and tried restoring my backups (done on CM12.1). After installing oandbackup from f-droid, I set the backup folder to the portable SD card (in my case: /storage/9016-4EF8/oandbackup), and oandbackup was able to read the entries. Restoring the apk was also possible, but the data could not be restored, despite reporting success. Doing new backups failed right from the start (apk as well as apk&data). Also it was not possible deleting previous backups.

When using the default backup folder in the internal storage, everything works fine as usual. But for me this seems a bit risky when dealing with Cyanogenmod updates, I rather have these backups on an external medium (which also provides more space).

qwertfisch avatar Mar 07 '16 18:03 qwertfisch

according to https://developer.android.com/training/permissions/requesting.html this is only supposed to happen "If the device is running Android 6.0 or higher, and your app's target SDK is 23 or higher" or if the permission has been revoked excplicitly. since https://github.com/jensstein/oandbackup/issues/124 probably is the same problem, i wonder if cm13 maybe revokes this permission by default. (oab doesn't target api 23)

jensstein avatar Mar 07 '16 20:03 jensstein

The permission for accessing storage was given. Other apps like Document Viewer were able to read from SD card. But that was no problem for oab, either … The problematic write access though, I did not test with any other app (except file manager, but that’s a CM standard app).

Nevermind, apart from this problem there were a whole lot more, so I switched back to CM12.1 and cannot provide you with any more information. I will resume as soon as CM13 is released in a stable version.

qwertfisch avatar Mar 07 '16 22:03 qwertfisch

I'm running CM13. There is a workaround for Titanium backup, which works for oandbackup:

Set the restore directory to [external sdcard]/Android/data/dk.jens.backup-1/files

Namely the default directory for apps

Iey4iej3 avatar May 10 '16 07:05 Iey4iej3

Thanks @FrankEular this seems to do the trick. In my case it was [external sdcard]/Android/data/dk.jens.backup/files, but I can confirm it solves the issue.

jomo avatar Oct 09 '17 00:10 jomo

Wow! Indeed it works. For Android 6 which doesn't understand tricks like [external card], user has to use the full path, e.g. /storage/xxxx-yyyy/Android/data/dk.jens.backup/files

ildar avatar Oct 09 '17 19:10 ildar

It seems due to the stricter management of permissions from Android Marshmallow: an ordinary app is no longer allowed to write in an arbitrary directory on external sdcards. I see that Open Camera takes advantage of Storage Access Framework to save photos. I don't know whether it's a good idea for oandbackup to do the same trick (This Framework seems a bit buggy).

Iey4iej3 avatar Oct 13 '17 07:10 Iey4iej3

I have summarized all open issues concerning this problem in #173. Also there is an extensive description of file handling with external SD cards for different Android versions.

Maybe continue the discussion in #173?

qwertfisch avatar Oct 13 '17 09:10 qwertfisch