'Storage Access Framework' woes.. - Java for Android App Development

TLDR at bottom!
I am needing to finally update a specialized app to support newer frameworks. I haven't had to touch this app about 8 years or so, because it was running fine, and it did its job. Sadly, because of some of the new library requirements by Google Play, it's gotta be updated. One of these changes is handling the new Storage Access Framework / writing to storage on the device. I've read the docs that searching has pointed me, and even looked at some of the examples. Sadly, the examples seem rather limited in nature, and my app doesn't seem to fit any of the 'given' examples.
The ultimate end goal is to have the users select an output directory once. And then IN that directory, the app creates folders based on the user's project. (like, 'FrontLine', 'RearLine', 'Cement', etc..). In each of these sub-directories, then, pictures and txt files are stored. (Either downloaded via http client, or taken/generated by the user.)
I was able to implement an intent calling 'ACTION_OPEN_DOCUMENT_TREE', and I get a content URI back. However, hooking that to a Camera library (for example, the androidx.camera library) needs a File or an output stream. Trying to create an output stream then gives me an error stating that access needs to be granted using the external storage permission.
I feel liek I'm missing something 'big' and obvious to connect my user's chosen output direcory into a File or some converting that will let me mkdirs, and write out files.
TLDR; Needing user to select a base output directory, in which my app creates Project directories in it, and then allows storage of pictures or text into these directories. Tried Storage Access Framework, and despite having the user select a directory, am still getting a permission denied error when trying to create output stream.
Any pointers are more then welcome, as googling I have reached dead ends, sadly. Kinda peeved at this new 'framework' and the limited scope it seems to have. (At least, in examples..)
Thanks guys!

Related

My experience setting up Atrix file and folder security

I was considering storing financial and personal information on my phone in the form of files and realized that though the fingerprint scanner is ok to prevent the casual browser from logging into the phone when it is left unaccompanied, a real hacker could easily see whats on there with very little effort.
The Atrix on the face of it looks like a secure phone with the fingerprint reader; however XDA users would know that nothing prevents a thief from entering fastboot and mounting the files and folders to see whats on there. No security app can prevent that.
Using the android built-in option and encrypting the entire sdcard is NOT an option for me at this time. I think its going to slow down the phone operation if the OS files are encrypted and each time it needs to decrypt each and every file and folder. Also it may present issues when testing new ROMs. (And I am dual booting - so my extSD also has a ROM which I would not want to slow down anymore than it already is)
So I searched for methods and apps to encrypt individual files or folders on the Atrix. There are quiet a few in the market and a few are free as well with good reviews. However most -even the ones with the best reviews seem to be just changing the file name and location and not doing real encryption. Also most of these use proprietary algorithms or methods to hide information. A really good app would be one that uses an open source algorithm to encrypt the files and folders - so that the algorithm would be tested and verified as being strong by the world.
Also another requirement was for the ability to frequently sync and update the files on the phone with the PC. The app should have a PC equivalent - that is the file can change on my PC and then I should be able to sync the changed file with the phone in some automated way.
Yet another requirement would be the ability to quickly encrypt and decrypt huge audio or video files. A few good apps could encrypt small audio and video files but not files of size 1GB or more. The apps would either freeze after some time or not encrypt them at all.
Finally I was looking for an option by which the files if I unencrypt them to be available across all apps for the duration of that session - not just in the app that encrypts and decrypts them. So in other words, once I enter the password, the folder should be mounted and available in any app that can browse the phone - until I decide to end or unmount the encrypted store.
I found only Cryptonite doing all of this. Unfortunately Cryptonite does not support Truecrypt containers on Motorola phones. There is some info here on the truecrypt port to android here:
http://forum.xda-developers.com/showthread.php?t=872297&page=7
However I could not get it working with the Atrix. Has anyone had success getting Kryptonite and Truecrypt to work on the Atrix?
Cryptonite also supports Dropbox, but I am not a big fan of storing sensitive info in the cloud - however well known the company is.
Cryptonite does support encFS and I was able to successfully create encFS encrypted folder on my Atrix. I would have liked to have TrueCrypt than encFS, just because I have been reading that Truecrypt has better overall support.
The method I use now for storing and synching encrypted information is:
for the first time only: create the encfs folder on the PC, then mount Atrix as a USB drive and copy the encrypted folder to Atrix.
To sync the encrypted files with the PC, I have to connect the Atrix as USB drive, open EncFS on the PC and select the folder on the Atrix to mount as a drive volume. Also mount the PC encFS folder as another drive. Now sync with the PC using any sync tool like MS SyncToy.
I went through a lot of searching and came to this which I think is good enough at the moment. I would like to hear if anyone else has a better app or method to secure and sync secured files on the Atrix - especially if you have got Truecrypt to somehow work on the Atrix. And I post this so that is anyone else needs this information, it is here.
shenoyh said:
Yet another requirement would be the ability to quickly encrypt and decrypt huge audio or video files. A few good apps could encrypt small audio and video files but not files of size 1GB or more. The apps would either freeze after some time or not encrypt them at all.
Click to expand...
Click to collapse
I don't know about the rest of it, I never used any strong security on my phone nor do I intend to, but I think you shouldn't ever expect to be able to "quickly encrypt and decrypt huge files". You're pretty much asking for impossible here. It's like asking to build a full-featured house, furnished and all, in 30 minutes or less. A lot of data will always require a lot of time to process. Heck, even, say, straight plain copying such a file to a computer would take quite a while.
No.
Your not going to get business class security on your atrix, or any current phone most likely.
LUKS manager is the closest thing to legitimate encryption (not gimicky BS) i have seen, but it has some fatal flaws.
Passwords and such are safe and easy to store with KeePass, which is also on windows/linux for syncing and has years of reputation (also free/open source). It isnt for files though.
-------------------------------------------------
Atrix 4G
Rom: Cyanogenmod 7.2 [20120805]
Recov: Romracer 5.0.2.7-atrix5
Radio: N_01.97.00R
Kernel: Faux 1.00ghz-026b1
UV: -0/-25/-50/-100/-150/-225/-300

ERROR: “Documents.library-Ms Is No Longer Working”

Hi All, I seem to have a repeating error where my Windows 8 Pro Libraries keep breaking. The error message is "<libraryname>.library-ms" is no longer working. Fixing the error is well documented, here for example: http://www.winhelponline.com/blog/fix-error-library-ms-is-no-longer-working-windows-7/
My problem is that it keeps happening, and it's happening the day after I fix it with the above solution. Plus it's happening for all 4 libraries (music, documents, videos, pictures). So it's a bit of a hassle.
To be clear, I always add my Windows Home Server 2011 folders to the libraries, as that's where my files are stored. I am wondering weather adding a network location is causing the repetition of this error. Has anyone else experienced this? To note, the files on my WHS 2011 server are not mapped to a drive on my Windows 8 Pro PC, and furthermore I have not added the WHS 2011 to the Homegroup - I prefer to keep things basic, but obviously will try something if it might help.
Also, I was running Windows 7 in the exact same configuration for over a year and this problem never happened. So it's definitely Windows 8, I'm just not sure if it's Windows 8 plus WHS 2011 not playing nicely. Any help appreciated.
>I always add my Windows Home Server 2011 folders to the libraries, as that's where my files are stored. I am wondering weather adding a network location is causing the repetition of this error.
Then you should find out. Replicate the WHS content on local storage and use that vs WHS for a few days to see what happens. The mantra of troubleshooting is to minimize your config until you have a known-good setup, then add new stuff one-by-one until you hit the bug. Then (hopefully) you'd have narrow down the culprit.
It's a good thing the corruption happens quickly, as ascertaining cause should be easy. The worst are the intermittent ones that occur over weeks or months.
Assuming there's no permanent fix, a workaround is to write a script for the delete/add fix mentioned. Then at least the hassle is limited to a single click per day.
Just to follow up on this. Thanks for the suggestion, I did try and reset the library's without adding the Server locations. All was fine for a bit, but then the same corruption happened and and the links to the libraries corrupted again. Not sure why. As you can see in the attached, all the libraries except the Videos one is now corrupted Seems like no one else is having this issue though (on XDA anyway).
I've experienced it myself, actually, on the machine where I moved my Documents, Pictures, Videos, Music, etc. folders out of %USERPROFILE% and onto my data drive (as in, D:\Music) then changed the library links. I just added actual links and stopped bothering with the libraries; I pretty much only use one folder for each of those content types anyhow.
Suggest reviewing your search hits more thoroughly for underlying cause(s) and not only the fix.
http://google.com/search?q="music.library-ms+is+no+longer+working" nets
http://answers.microsoft.com/en-us/...89?msgId=a51a4bb9-5c62-4881-bfa2-fa8e56fce092
suggests possible user account corruption.
http://all4naija.blogspot.com/2012/06/musiclibrary-ms-is-no-longer-working.html
"The cause of the problem is not far fetched. It could have been a program one installed previously. It could as well have been shutting down a program using the folder without following appropriate means. Like powering of Windows when a program making use of any of the Library folder is working. For example, when converting video files and shutting the computer off without finishing with the converting files."
http://www.lockergnome.com/windows/...y-ms-is-no-longer-working-error-in-windows-7/
"Windows 7 introduced libraries as a way to allow users to easily access folders containing certain data from all over their file structure without having to keep them in a specific documents directory within their user profile. The library itself can be accessed and controlled by third-party programs using an API. Unfortunately, that opens the library structure up to occasional crashes and other bugs."
Etc.
If searches don't help, minimize to a known-good setup: clean reinstall, install drivers (and nothing else), create your libraries, and run this minimal setup for a few days. If problem persists, then hardware could be the cause, and you'd need to minimize hardware config. More likely, problem disappears; add your programs back in small batches to ferret out the cause.
From the frequency of search hits, it does appear WMP libraries are susceptible to corruption. The ultimate workaround is to use a 3rd-party media manager as replacement.
BTW, I assume this isn't a hacktivated Win8, ie no system files were modded to bypass activation. If the latter, replace it. An upgrade install can also be problematic, and a clean install is suggested.

[Q] Does WP8 have clipboard storage?

I was wondering if cut/copy commands are stored on WP8 in isolated storage or somewhere else similar to the uipasteboard in iOS? Any help would be appreciated.
There is no OS-level "Cut" command. Copy (and Paste) work only for text, but are supported by the OS and across apps, not in any per-app storage. The public APIs for clipboard access are extremely limited; apps can detect when there's clipboard content and can put their own text on the clipboard, but that's it. (Internal APIs for actually accessing clipboard data do of course exist, but app's aren't generally permitted to use them.)
Developers are of course welcome to implement an app-internal clipboard of any kind they want. For example, Pocket File Manager supports Cut/Copy/Paste for files (in the same manner as Windows Explorer on PCs) but that's purely app-internal.
GoodDayToDie said:
There is no OS-level "Cut" command. Copy (and Paste) work only for text, but are supported by the OS and across apps, not in any per-app storage. The public APIs for clipboard access are extremely limited; apps can detect when there's clipboard content and can put their own text on the clipboard, but that's it. (Internal APIs for actually accessing clipboard data do of course exist, but app's aren't generally permitted to use them.)
Developers are of course welcome to implement an app-internal clipboard of any kind they want. For example, Pocket File Manager supports Cut/Copy/Paste for files (in the same manner as Windows Explorer on PCs) but that's purely app-internal.
Click to expand...
Click to collapse
Great! So basically I the WP8 doesn't have a storage place where sensitive data (i.e. Credit Card info) would be stored if someone decided to do a copy on a card number so they don't have to retype it in later in the app. Correct?
I see a lot of .DATA files in isolated storage. Do you know what these are and how to open them? Much appreciated again.
Well, as I said, there is an OS-level clipboard (shared between apps) that can handle text (but nothing else). CC#s are text, so they could be copied this way. The only way to make that impossible would be to prevent the user from selecting the text (a pointless goal in any case, as the user could just copy the number manually, or take a screenshot, or... you get the idea).
Isolated Storage is completely up to the app. The OS has nothing at all to do with it, besides providing a location in the file system for each app to use. Without even knowing what app you're talking about, I can't begin to tell you what the format of those files is.

Apps Still Have A Loophole For Writing To The SD Card.

The secret to modifying files on the SD card is in theMediaStore*class. It's a*Content Provider*with access to the database built by the Media Scanner. This is mostly useful to apps like the gallery and music players, but anything that wants to see locally stored images, audio, or video will probably use it.
We’re really interested in a child class calledMediaStore.Files. Its job is to give links (URIs) to apps so they can query the database for files on a specific storage device. Through this mechanism, developers can get a specially crafted link that can be used to open a file with write access.
It seems that this method works because the links actually call on the Media Store to open and edit files. Since the Media Store runs with system privileges, it is free to make changes on external storage devices. In essence, apps are able to masquerade as a system service for the purpose of writing to the SD card.
Total Commander*appears to be the first*to have discovered*and implemented this workaround. There are still a few known bugs and some devices, like the HTC One M8 with its /sdcard2 mount point, aren’t supported yet, but it’s almost completely working on the Note 3. While the code has been in Total Commander for quite some time, a*recently posted beta*cleaned up several bugs and makes it the best implementation we've seen.
Source: http://www.androidpolice.com/2014/0...ng-to-the-sd-card-on-kitkat-but-for-how-long/
Check out "Total Commander - file manager" - https://play.google.com/store/apps/details?id=com.ghisler.android.TotalCommander
I expect this will be too quickly fixed to get excited about.
What it needs is for Google to add a permission, even with loads of warnings and confirmations, to allow us to make our own choices - and allow the use of file managers and other apps that need access to the whole memory card.
I'm willing to take the risk Google!
But, this is Sony, so even if Mr. Google fixes it, it'll be sometime in 2015 before that appears on a Z1, if ever.
Sent from my SGP512 using Tapatalk

Has anyone successfully relocated the Metadata folder with ROOT?

I've seen quite a few posts on this and other forums claiming that with root one could move the metadata folder off of the Shield's internal memory using symlinks. I'm wondering if anyone has successfully done this and if they wouldn't mind outlining the procedure, as I've had mixed results. While I was, in fact, able to relocate the Plug-ins folder using symlinks, the same procedure failed for the metadata folder. I commented on this in another post so I'll paste that story here:
"...I tried doing this a couple of months ago and while I was able to successfully symlink the Plug-ins folder, thus allowing installation of plug-ins, the Metadata was less successful:
This was a couple of months ago so I can't remember exactly what happened, however, after creating the symlink and migrating the metadata to my external storage, the Plex app would no longer download posters or wallpapers. From what I remember, though, it would still download text information such as Titles, Plots, etc... I thought this was extremely bizarre behavior at the time. At first, it seemed that the data migrated successfully, but then new movies wouldn't have any artwork, so I was under the impression that the plex server app was refusing to write to the new folder. However, and this is where my memory is fuzzy, it seemed that Text info was still downloading (Title, plot, year, etc...). Also, the plex server app had no trouble writing to the Symlinked Plug-ins folder, so I don't understand why it couldn't do the same with the metadata (or at least the picture based metadata.)
I also remember trying to manually download artwork via the web interface but, let's say you were trying to manually update a poster for a movie, where you would normally see a grid of different posters to chose from, it was all just a bunch of blank boxes.
So to summarize, while symlinking does seem to work for Plug-ins, it doesn't actually appear to be a solution for migrating metadata off of the internal storage. If you have successfully done this and wouldn't mind outlining the steps you followed, that would certainly be extremely helpful to many users here. I've scoured this forum, the Nvidia forum, as well as XDA and Google and have yet to come across someone who has successfully migrated the metadata folder, only the Plug-ins folder."
If anyone has actually successfully done this and could clear up the procedure that would be a great help, as this question comes up often and people are always given the same answer: that with symlinks and root it is possible. It's my experience that it isn't however and it would be best to avoid spreading misinformation on this topic if that is, in fact, the case. (not just for the sake of current Shield owners but potential buyers as well.)

Categories

Resources