Backups stored in internal memory despite SD card #7521

Closed
nrizzio opened this Issue Mar 14, 2018 · 8 comments

Comments

Projects
None yet
7 participants
@nrizzio
Contributor

nrizzio commented Mar 14, 2018

I have:


Bug description

I have a removable SD card in my phone. When I enable backups, they are stored within internal memory. This often plows right through my storage and defeats the purpose of having an SD card.

Steps to reproduce

  • insert SD card, encrypt it
  • enable backups
  • wait for the first backup to finish

Actual result: The backup is stored within internal memory, chewing up scarce storage space
Expected result: The backup is stored on the SD card, allowing me to save valuable space

Device info

Device: Samsung Galaxy Grand Prime
Android version: 5.1.1
Signal version: 4.17.3

Link to debug log

https://debuglogs.org/03539ef784b5b00aa608880dee112ea4f4fc98f830f74acd9876c0fec62095cb

Note

I submitted this on mobile (my computer is rather broken at the moment). I apologize in advance if I have missed details or made formatting mistakes.

@johanw666

This comment has been minimized.

Show comment
Hide comment
@johanw666

johanw666 Mar 14, 2018

Your misunderstanding comes from the ambiguous terminology: "external memory" in Android was in the beginning (Android 1 - 2) usually the removable memory card, but now it confusingly means the internal memory. And when unified memory is used in Android 6 or higher it can be both.

See http://www.riptutorial.com/android/example/17144/android--internal-and-external-storage---terminology-clarification for more details.

If you want to automatically map the internal sd card to the removable one, there is an Xposed module to do that: XinternalSD. It only works for apps who use the official api's to find the location because it hooks that api call but Signal does that.

johanw666 commented Mar 14, 2018

Your misunderstanding comes from the ambiguous terminology: "external memory" in Android was in the beginning (Android 1 - 2) usually the removable memory card, but now it confusingly means the internal memory. And when unified memory is used in Android 6 or higher it can be both.

See http://www.riptutorial.com/android/example/17144/android--internal-and-external-storage---terminology-clarification for more details.

If you want to automatically map the internal sd card to the removable one, there is an Xposed module to do that: XinternalSD. It only works for apps who use the official api's to find the location because it hooks that api call but Signal does that.

@RiseT

This comment has been minimized.

Show comment
Hide comment
@RiseT

RiseT Mar 14, 2018

Contributor

So - according to that link - the correct (i. e. Google's) terminology for a SD card would be "Secondary External Storage"...? Jeez...

Back to topic, imho it should be possible to store Signal backups on a SD card without having to use a tool like Xposed.

Contributor

RiseT commented Mar 14, 2018

So - according to that link - the correct (i. e. Google's) terminology for a SD card would be "Secondary External Storage"...? Jeez...

Back to topic, imho it should be possible to store Signal backups on a SD card without having to use a tool like Xposed.

@moxie0

This comment has been minimized.

Show comment
Hide comment
@moxie0

moxie0 Mar 14, 2018

Member

I don't think there's a way to get the path you want. We ask Android for the external storage directory, and use the path it gives us.

Member

moxie0 commented Mar 14, 2018

I don't think there's a way to get the path you want. We ask Android for the external storage directory, and use the path it gives us.

@2-4601 2-4601 added the backup label Mar 18, 2018

@cdysthe

This comment has been minimized.

Show comment
Hide comment
@cdysthe

cdysthe Mar 22, 2018

I'm having the same issue on my Moto G5+ with Android 7. Backups are stored on internal storage, not the SD card.

cdysthe commented Mar 22, 2018

I'm having the same issue on my Moto G5+ with Android 7. Backups are stored on internal storage, not the SD card.

@RiseT

This comment has been minimized.

Show comment
Hide comment
@RiseT

RiseT Mar 22, 2018

Contributor

For what it's worth, here's what I've found. I've looked at several places, and everything proposed seems to come down to one of the solutions or workarounds mentioned below.

You are welcome to use the getExternalFilesDirs(), getExternalCacheDirs(), and getExternalMediaDirs() methods on Context. Note the plural method names. If those methods return 2+ entries, the second and subsequent ones are locations on removable storage that you can read from and write to, no permissions required. However, you cannot access all of removable storage this way, just a location specific for your app.

You are also welcome to use the Storage Access Framework, allowing the user to pick where the content goes, including placing it on removable storage. However, you are no longer working with files and paths, but with content and Uri values.

The N Developer Preview offers another option for "Scoped Directory Access", which supports removable storage. However, this is still part of a developer preview at the present time (March 2016).

Source:
https://stackoverflow.com/questions/35947286/android-dev-accessing-external-sd-card-directly-on-samsung-devices-with-extsdc

Contributor

RiseT commented Mar 22, 2018

For what it's worth, here's what I've found. I've looked at several places, and everything proposed seems to come down to one of the solutions or workarounds mentioned below.

You are welcome to use the getExternalFilesDirs(), getExternalCacheDirs(), and getExternalMediaDirs() methods on Context. Note the plural method names. If those methods return 2+ entries, the second and subsequent ones are locations on removable storage that you can read from and write to, no permissions required. However, you cannot access all of removable storage this way, just a location specific for your app.

You are also welcome to use the Storage Access Framework, allowing the user to pick where the content goes, including placing it on removable storage. However, you are no longer working with files and paths, but with content and Uri values.

The N Developer Preview offers another option for "Scoped Directory Access", which supports removable storage. However, this is still part of a developer preview at the present time (March 2016).

Source:
https://stackoverflow.com/questions/35947286/android-dev-accessing-external-sd-card-directly-on-samsung-devices-with-extsdc

@Natanji

This comment has been minimized.

Show comment
Hide comment
@Natanji

Natanji Apr 2, 2018

@moxie0 An easy solution to this would be a an option to pick the directory where the backup should be saved. There's no reason for Signal to force a specific directory and only rely on what Android is telling you; with the diversity in the devices and how they implement external storage, it's bound to fail on some devices.

Natanji commented Apr 2, 2018

@moxie0 An easy solution to this would be a an option to pick the directory where the backup should be saved. There's no reason for Signal to force a specific directory and only rely on what Android is telling you; with the diversity in the devices and how they implement external storage, it's bound to fail on some devices.

@moxie0

This comment has been minimized.

Show comment
Hide comment
@moxie0

moxie0 Apr 3, 2018

Member

I've reviewed the API, and it doesn't seem like there's any defined way to access "removable storage," and that even the undefined ways are limited to scoped access for music, video, etc. Please reopen if anyone can determine a way to reliably access removable storage.

Member

moxie0 commented Apr 3, 2018

I've reviewed the API, and it doesn't seem like there's any defined way to access "removable storage," and that even the undefined ways are limited to scoped access for music, video, etc. Please reopen if anyone can determine a way to reliably access removable storage.

@moxie0 moxie0 closed this Apr 3, 2018

@Natanji

This comment has been minimized.

Show comment
Hide comment
@Natanji

Natanji Apr 3, 2018

@moxie0 It might be worth looking at the Code for OsmAnd for this. In OsmAnd users can choose between internal memory, external memory 1 (which is as @johanw666 pointed out usually the Android "emulated" internal memory, so ends up being the same location) and external memory 2, which is the actual SD card.

Their way to (reliably, as far as I can tell) get the SD card is to check whether the file path contains the string "emulated" (which means internal memory) among all the dirs returned by getExternalFilesDirs(). It might seem hacky but works reliably as far as I can tell, see here for how Osmand implements this.

Natanji commented Apr 3, 2018

@moxie0 It might be worth looking at the Code for OsmAnd for this. In OsmAnd users can choose between internal memory, external memory 1 (which is as @johanw666 pointed out usually the Android "emulated" internal memory, so ends up being the same location) and external memory 2, which is the actual SD card.

Their way to (reliably, as far as I can tell) get the SD card is to check whether the file path contains the string "emulated" (which means internal memory) among all the dirs returned by getExternalFilesDirs(). It might seem hacky but works reliably as far as I can tell, see here for how Osmand implements this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment