Access , in Action

Google has been using carrots (e.g., sample code) and sticks (e.g.,
ban on the file Uri scheme)
to get developers to work with content over files. Part of that is
using the Storage Access Framework, which is dominated by three Intent
ACTION_OPEN_DOCUMENT_TREE. Google wants us to be using those for
requesting content from the user, rather than working solely with the
device filesystem.

Hence, it would be really helpful if activities existed for those Intent
actions on all relevant devices ( 4.4+, except for ACTION_OPEN_DOCUMENT_TREE,
which is Android 5.0+). For example, they might have part of Compatibility
Test Suite test these actions, so that devices would not ship with broken

Alas, this does not appear to be the case.

In particular, it is a mixed bag on Android TV. Some devices, like the NVIDIA
Shield TV, support the Storage Access Framework. Others, such as the Xiaomi
Mi , do not. Michael Sotnikov, who brought this to my attention,
indicates that other Android TV devices behave like the Mi Box.

That’s bad.

What’s worse is that it is difficult for us to determine which devices are affected.
are supported… by activities that do nothing other than show a “You don’t have
an that can do this” Toast.

So, not only does the documentation provide no hint that these activities are
optional, but our standard detection mechanisms — such as calling resolveActivity()
on PackageManager and seeing if it returns null — do not work.

At least for the Mi Box, ACTION_OPEN_DOCUMENT_TREE is not supported in the
traditional way, by simply not having an activity for it. Hence, you can check
to see if that Intent resolves and take steps to work around the problem.
if resolveActivity() returns a ResolveInfo pointing at an activity whose
ComponentName is…$DocumentsStub

The package seems to be a stock
Google package — bundled into a FrameworkStubs.apk file — that
provides these fake implementations. It seems like a variety of Android TV
devices ship with this, perhaps lining up with the devices that Mr. Sotnikov

So, Google decided to not support the Storage Access Framework on some
Android TV devices, and failed to document this.

I filed an issue to try
to argue that things should move in the other direction, with the CTS confirming
the existence of working Storage Access Framework activities, lest we find
ourselves with a growing fleet of devices with broken implementations.

Regardless, at least if you are supporting Android TV, have a fallback plan
for devices lacking the Storage Access Framework. For example, there are many
file chooser libraries for Android;
one or more of them may offer a reasonable user experience on a TV.

Need a speaker at your Android development meetup? Mark Murphy is available, in person in the Boston/Pittsburgh/DC triangle, or by remote anywhere in the world! Contact Mark for details!


Source link


Please enter your comment!
Please enter your name here