Random Musings on the Android 12 Developer Preview 1

Each time Google releases a new developer preview, I rummage throughthe API differences reportthe high-level overviews,and even the release blog post,to see if there are things that warrant more attention from developers. I try to emphasize mainstream features that any developermight reasonably use, along with things that may notget quite as much attention, because they are buried in the JavaDocs.

As with the previous four releases, Android 12 seems to be lacking a prominentuser-facing feature. I have no idea what I willtell my mother that she���ll gain if her phone gets the update at some point.Admittedly, Google appears to be sandbagging a bit, holding out some changesfor later releases, so perhaps something compelling to ordinary people will appearlater.

But, as has been common in a similar timeframe, the interesting bits for developersare not covered in the DP1 release notes.

What Will Irritate Developers

In principle, I am a fan of requiring positive declaration of exported components.However, this desperately needs a Lint warning, though hopefully one is forthcoming,perhaps in the current canary release of Android Studio 2020.3.1 Arctic Fox My Goodness This Name Is Long.I am hopeful that the error messagewill improve, though, as tens of thousands of developers next year are going toencounter this change, and approximately zero of those developers will be readingthe documentation. Helen of Troy had ���the face that launched a thousand ships���;this sort of inscrutable error message for an all-but-guaranteed failure is���the error that launched a thousand Stack Overflow questions���.

I had no idea that nested Intentswere much of a thing, making me wonder if this was a technique used by certainlibraries (e.g., ad networks). That, andrequiring mutability flags on PendingIntent,worry me less for apps directly and more for libraries that might not be receivingupdates. Of course, depending on where those libraries were published,the libraries may be gone, anyway.

I foresee a blog post in my future on writing activity trampolines.

Perhaps the one that worries me most is the limit on starting foreground services from the background.In theory, this is fine. In practice, foreground services are already unreliable,with timing-related OS bugs yielding Context.startForegroundService() did not then call Service.startForeground()or similar sorts of errors. My concern is that, just as Google seems unconcerned aboutthose errors, Google will not care about follow-on errors related to timing ofwhen you can and cannot start a foreground service. Hopefully, my fears are unfounded.

Fortunately, all of the preceding changes in this section only take effect once yourtargetSdkVersion hits 31(?) or higher. That means it probably will affect those of usexperimenting with DP1 for a few months, and then the bulk of developers sometime next year.

One change that might take effect more quickly ��� though I have not yet tested it ���is that there are new permissions for using the cameraand using the microphonein the background. These are dangerous permissions, ones that we have to requestat runtime.It is also unclear how future camera and microphone togglesmight behave and how apps will find out about the state changes.

And the new VERSION_CODES value is messed up,as usual.

What Is Neat But Confusing

The unified content API,for accepting media from paste, drag-and-drop, and other sources, is nice. However,it is unclear why this is a new framework API, since the documentation depicts itas being a wrapper around existing APIs with a backport already in AndroidX. Ifthe backport is complete, why did we need a framework API? And if we needed a frameworkAPI, what is the gap between what Android 12 offers and what the backport offers?

PackageManager has gained some interesting, if under-documented, features:

You can request checksums of installed apps.

There is a new form of ���property��� that you can declare ona componentor elsewhere in the manifest. It is unclear how this relates to the long-standing<meta-data> option in the manifest.

A package can have attributionsin the <manifest>, defined in <attribution> elements.It is unclear if this ties into data access auditing,though, or what role these ���attributions��� otherwise play.

What Is Subtly Nice

The postponed foreground service notificationsfeature should help with user distraction. Often, we need a foreground service becausewe cannot be certain that a background service will complete in time��� but ifthe work is completed quickly, we hassle the users with a short-lived notification.This change should help eliminate that.

Apps have improved options for blocking touch input passed through other windows,including a permission to be able to enable such a blockand a window option to implement the block.Frankly, this is long overdue, as is banning apps from closing system dialogs.

Since the beginning, we have built up some heuristics for which types of Contextare safe for UI operations and which ones are not. Finally, Google is formalizingthe concept, with a dedicated API to tell you if this Context is OK for UI work.There is a corresponding option in StrictModeto warn you about incorrect Context usage.

PowerManager can now give us real-world estimates of remaining battery life,which might be useful for some apps to better scale back work in low-battery states.

And, as Romain Guy tweeted about,we have a new API to apply a RenderEffect to a View,which should give us an easy blur option.

What Needs Third-Party Love

ImageDecoder now supports decoding the full animations of GIF and WebP images.It will be interesting if image-loading libraries start adopting it on Android 12and newer devices ��� my guess is that they will only if if provides obviousbenefits over their existing code for handling these animations.

What���s Dead (Or Seriously Morphed)

At least in DP1, there are relatively few massive deprecations, like the deprecationof AsyncTask in Android 10.

However:

LocationManageris significantly changing its API for obtaining locations

Obtaining the WiFi connection infoor IP address has moved to newlocations in the SDK

DevicePolicyManager is overhauling its passphrase quality API,resulting in a bunch of deprecations

You can no longer use GET_INTENT_FILTERSwhen querying the PackageManager

If you were using FLAG_BLUR_BEHIND or TYPE_STATUS_BAR_PANEL on WindowManger.LayoutParams,those values have been removed from the SDK entirely

What Is the Human Resources Department Doing In My Developer Preview?

There is a new PeopleManagersystem service. Google added a lightweight concept of ���conversations��� to the NotificationAPI over the past few releases. This appears to try extend that further.

This might tie into the conversation app widgets described in some Android 12 document leaks.There also is a new way to tie a NotificationChannel to conversations.

What Is the Insect Resources Department Doing In My Developer Preview?

There is a BugreportManagerin Android 12, though it is unclear exactly how useful it will turn out to be.

What Makes Me Go ���Hmmmmm���

And now, we get to a list of other things that caught my eye in the APIdifferences report that did not get included in Google���s DP1 overview:

There is a new AppSearchManagerthat appears to be an on-device search engine. It will be interesting if thisgets covered more in future developer previews.

The fused location provider has appeared in the SDK for the first time.It will be interesting to see if this means that you can start using this onnon-Play devices.

We now have a new facet of a Configuration: fontWeightAdjustment.I do not see an option for this in the Settings app. It also remains to be seenif this triggers a new type of configuration change.

We can now control whether we get click events for a disabled View.

It appears as though an <intent-filter> can now filter Uri values basedon a suffixand some sort of ���advanced pattern���.It is unclear what is so advanced about that pattern, though.

There are two new Notification categories. CATEGORY_WORKOUTsuggests that Google is going to have more explicit support for fitness-relatedapps, perhaps stemming from their acquisition of Fitbit. And I do not know whatCATEGORY_LOCATION_SHARINGmeans, such as ���sharing with who?���.

If you played with Android 10���s device controls, there is new control type: the thumbnail.I am uncertain what the use case is, though security cameras might be one.

There is a new requireDeviceScreenOnattribute on��� something. It is described as ���Whether the device must be screen on before routing data to this service. The default is true.���.That default seems odd; otherwise, I would have thought that perhaps this attributegoes on <service> in the manifest. It is possible that this ties into a new option to require unlocking the device before processing a notification action.

There is a new AppUriAuthenticationPolicy,though it is unclear how it will be used.

We can have more sophisticated haptics, with multiple blended vibration patterns.Alas, the name of the class for thiswill spawn yet another round of off-color jokes.

What Happens Now?

While I do plan on writing an Elements of Android S along the lines of itsQ and Rpredecessors, I plan on waiting to release something. I waste too much timechasing changes that eventually themselves change or outright vanish.So, my current plan is to wait to ship a Version 0.1 of the book until thelast developer preview or first beta release. If you feel that this is a mistake,and I should publish something more rapidly,let me know!.

 •  0 comments  •  flag
Share on Twitter
Published on February 21, 2021 06:26
No comments have been added yet.