Random Musings on the R Developer Preview 3
Each time Google releases a new developer preview, I read what I can to see if there are things that warrant more attention from developers. I try to emphasize mainstream features that any developer might reasonably use, along with things that may not get quite as much attention, because they are buried in the JavaDocs.
The deeper we get into the release series for a new Android version, the fewer “big ticket” changes appear. Android R is no exception. Many of the changes are tweaks to things that debuted earlier, such as new class and method names around data access auditing.
So, What’s New?
We now have
Environment. This is how we can find out if the user has granted us
MANAGE_EXTERNAL_STORAGE. The zero-parameter version tells us if we have such rights for external storage; the one-parameter version tells us if we have such rights on whatever storage volume contains the supplied
File. This was a clear gap in the earlier developer previews, so I am glad that this was added!
There is a new option with the keystore to require authentication per use on designated keys, with developer-controlled authenticators (e.g., strong biometrics or a device credential).
ContentResolvernow has a
notifyChange()method that takes a collection of
Urivalues, presumably as an optimization.
ParcelFileDescriptornow has a
wrap()method. You also supply an
OnCloseListener, which is notified when the underlying
ParcelFileDescriptoris closed. This could be useful for tracking file descriptor leaks — keep a roster of those that you create and remove them from the list when they are closed.
Also, Android Police pointed out that there is a new Settings option to “auto-revoke permissions”. Basically, if the user does not use your app for a while (“a few months”), Android will automatically revoke certain permissions that the user has granted. Well-written apps should not be harmed by this, but it is yet another wrinkle with runtime permissions added by Android R, on top of the one-time permission option that debuted with DP1.
What Significantly Changed?
Besides the name changes in data access auditing, we have:
android.widget.inlineand got a bit more in the way of documentation.
InlineContentViewfeels like something layered atop of the
SurfaceControlViewHostthat I profiled here and here. Still, it is unclear how this is going to get used in practice.
ApplicationExitInfogot three new reasons of why your process died. Also, we can now register a “process state summary” via
ActivityManagerand get that back in
ApplicationExitInfo, to provide a bit more context about what the app was doing at the time its process died. And, if we crashed (particularly with an ANR), we can get details of what the threads were doing at the time.
FEATURE_CONTEXT_HUB was, it no longer exists.
Also, as part of revamping the “resource loader” system, they got rid
DirectoryAssetLoader… despite still referring to it in the preview
While technically not “gone”, a couple of
WebView methods were deprecated:
I will work on releasing an updated version of Elements of Android R in the coming weeks, covering some of this and other things that are part of earlier developer previews.
Interested in Jetpack Compose?
jetc.dev has a weekly newsletter of the latest articles, samples, and other details of Compose development!