Fix SD card access under KitKat (Android 4.4) #18

Open
GoogleCodeExporter opened this Issue Jun 26, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@GoogleCodeExporter
Google has changed how SD card permissions work under Android 4.4 (KitKat). I 
*thought* Cryptnos would not be affected, but based on my experience with my 
newly upgraded phone, I was apparently wrong. This should be a pretty simple 
fix, but I have no idea when I'll find time to address it.

Original issue reported on code.google.com by jeff.darlington@gmail.com on 12 May 2014 at 9:02

@GoogleCodeExporter

This comment has been minimized.

Show comment
Hide comment
@GoogleCodeExporter

GoogleCodeExporter Jun 26, 2015

For a bit of explanation, this only strictly affects exporting sites to a file. 
It somewhat affects file imports as well, but not as adversely as exports.

A bit of additional information, primarily sourced from here:

https://developer.android.com/about/versions/android-4.4.html

It looks like the ability to WRITE to anywhere on external storage is now a bit 
of a no-no in KitKat and up. This isn't necessarily a HUGE problem for us, but 
a different paradigm that individual users are going to have to get used to. We 
can restore the ability to READ from any location by using 
Environment.getExternalStoragePublicDirectory() rather than 
Environment.getExternalStorageDirectory(), but writing will be restricted to 
whatever is returned by Context.getExternalFilesDir().

Prior to Version 1.1.0 of Cryptnos, users were restricted to importing and 
exporting to just the root of the SD card. In 1.1.0, we allowed users to import 
and export from anywhere on the card as long as they had a recognized file 
manager app installed that allowed them to select the file to import or the 
folder to export to. Perhaps the best fix here will be to go back to the 
original functionality and restrict imports and exports to the folder returned 
by Context.getExternalFilesDir(). This limits the user's freedom a bit, but 
that's what we're stuck with.

The question is whether we should force this upon ALL users, or just those in 
KitKat or above. Frankly, I hate restricting users, but I also dislike having 
to maintain multiple functionalities for multiple versions. So odds are I'll 
probably end up ripping out the file manager connection code and the choice of 
where to where read and save files.

Yeah, I think that sucks too.

We'll definitely need to notify the user of this change and offer suggestions 
on how to move files outside the special magic directory into it.

Original comment by jeff.darlington@gmail.com on 16 May 2014 at 8:15

For a bit of explanation, this only strictly affects exporting sites to a file. 
It somewhat affects file imports as well, but not as adversely as exports.

A bit of additional information, primarily sourced from here:

https://developer.android.com/about/versions/android-4.4.html

It looks like the ability to WRITE to anywhere on external storage is now a bit 
of a no-no in KitKat and up. This isn't necessarily a HUGE problem for us, but 
a different paradigm that individual users are going to have to get used to. We 
can restore the ability to READ from any location by using 
Environment.getExternalStoragePublicDirectory() rather than 
Environment.getExternalStorageDirectory(), but writing will be restricted to 
whatever is returned by Context.getExternalFilesDir().

Prior to Version 1.1.0 of Cryptnos, users were restricted to importing and 
exporting to just the root of the SD card. In 1.1.0, we allowed users to import 
and export from anywhere on the card as long as they had a recognized file 
manager app installed that allowed them to select the file to import or the 
folder to export to. Perhaps the best fix here will be to go back to the 
original functionality and restrict imports and exports to the folder returned 
by Context.getExternalFilesDir(). This limits the user's freedom a bit, but 
that's what we're stuck with.

The question is whether we should force this upon ALL users, or just those in 
KitKat or above. Frankly, I hate restricting users, but I also dislike having 
to maintain multiple functionalities for multiple versions. So odds are I'll 
probably end up ripping out the file manager connection code and the choice of 
where to where read and save files.

Yeah, I think that sucks too.

We'll definitely need to notify the user of this change and offer suggestions 
on how to move files outside the special magic directory into it.

Original comment by jeff.darlington@gmail.com on 16 May 2014 at 8:15

@gpfjeff

This comment has been minimized.

Show comment
Hide comment
@gpfjeff

gpfjeff Oct 28, 2016

Owner

This is looking like it might end up as a non-issue. It's been over two years since I've had a chance to play with the code, but I can't replicate this anymore on my current device running Marshmallow (6.0.1). Obviously, it would be "best" if I update the code to specifically look for KitKat devices and disable the broken functionality. That said, with KitKat being over two years old and unlikely to appear on new devices, it might become moot quickly. Latest Android version rankings show KitKat at around 28% of the market (currently the most common), but that will probably start dropping rapidly. I hate to say it, but I might just close this with a "won't fix" status.

Owner

gpfjeff commented Oct 28, 2016

This is looking like it might end up as a non-issue. It's been over two years since I've had a chance to play with the code, but I can't replicate this anymore on my current device running Marshmallow (6.0.1). Obviously, it would be "best" if I update the code to specifically look for KitKat devices and disable the broken functionality. That said, with KitKat being over two years old and unlikely to appear on new devices, it might become moot quickly. Latest Android version rankings show KitKat at around 28% of the market (currently the most common), but that will probably start dropping rapidly. I hate to say it, but I might just close this with a "won't fix" status.

@gpfjeff

This comment has been minimized.

Show comment
Hide comment
@gpfjeff

gpfjeff Oct 28, 2016

Owner

Whoops... let me retract that. I forgot that my Marshmallow device doesn't have a removable SD card, just internal storage. Trying again on my tablet which has Lollipop (5.0.2) and an SD card, I could both read and write to the internal storage but only read from the SD card. Writing to the SD card fails. So I guess I do need to look into this. Unfortunately, in order to test the later Android versions in the emulator, I may need to upgrade to Android Studio, which is a bigger task. I'll keep this open for now.

Owner

gpfjeff commented Oct 28, 2016

Whoops... let me retract that. I forgot that my Marshmallow device doesn't have a removable SD card, just internal storage. Trying again on my tablet which has Lollipop (5.0.2) and an SD card, I could both read and write to the internal storage but only read from the SD card. Writing to the SD card fails. So I guess I do need to look into this. Unfortunately, in order to test the later Android versions in the emulator, I may need to upgrade to Android Studio, which is a bigger task. I'll keep this open for now.

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