Random Musings on the Android 13 Developer Preview 2
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.
What Got Clarified From Last TimeAbout five weeks ago, I wrote about DP1.
This time around, the ���13 DP1 while 12L is in beta?��� answer is ���12L is now foldedinto DP2���.
Also, they are nowdocumenting the POST_NOTIFICATIONS permission.Of particular note is that this permission affects all apps, regardless oftargetSdkVersion. If your targetSdkVersion is below Android 13���s presumedvalue of 33, the system will prompt the user to grant permission when you createyour first notification channel, for a newly-installed app on 13.If you create that channel at an inopportune time��� you willneed to modify your app.
They are also documenting the new option for controlling whether a dynamically-registered receiver is exported.And, they mentioned in the blog post the option for revoking already-grantedpermissions, though the method name changed.Plus, they talk a bit about BODY_SENSORS_BACKGROUND.
But beyond that, the mysteries from DP1 remain mysteries.
What Else Got Announced Of Note?The biggest thing is the Foreground Services (FGS) Task Manager. This allowsusers to stop your app���s process easily from the notification shade, if yourapp has a foreground service running. Of particular note is that the OS willnag users periodically about your app, if your service runs most of the time(20 hours out of the preceding 24, with a maximum of one nag per month).Developers may wind up adding flagsto avoid users getting bothered by those messages, which in turn will causeGoogle to remove the impacts of those flags in some future Android release.
(if you spend enough time in Android development, predicting developer-and-Googleactions in advance becomes simply a matter of pattern matching���)
The War on Background Processingcontinues, beyond the FGS Task Manager.
In a tweak to JobScheduler, ���In Android 13, the system now tries to determine the next time an app will be launched���,which is not at all creepy. Nope, not one bit.
The official blog post mentions a few things that might impact a smallpercentage of developers.
And, that���s pretty much it for official stuff.
What���s Up With All the New Permissions?DP2 adds 15 new permissions over DP1,let alone prior versions of Android.
Some of these, like MANAGE_WIFI_AUTO_JOIN and MANAEG_WIFI_INTERFACES, aredocumented as ���Not for use by third-party applications���, which makes you wonderwhy they bothered to put them in an Android SDK that is explicitly for third-party applications.
They have added three content-specific permissions: READ_MEDIA_AUDIO,READ_MEDIA_IMAGE, and READ_MEDIA_VIDEO. The JavaDocs indicate that theseare replacements for READ_EXTERNAL_STORAGE, but only for those app that targetAndroid 13 or higher. Presumably, holding one of these permissions, and not READ_EXTERNAL_STORAGE,only gives you read access to that media type and not other content.
The other permission that may generate widespread interest is USE_EXACT_ALARM. Android 12 added SCHEDULE_EXACT_ALARM to be able to use exact alarms, but thisis an ���app ops��� permission, one that users have to grant directly in Settings.USE_EXACT_ALARM appears to be a normal permission, but the JavaDocs make it plain that the Play Store (and perhaps elsewhere) will require you to fill out a formto be able to ship an app that requests it. As many developers are discoveringwith MANAGE_EXTERNAL_STORAGE, you need a really good reason to request one of thesesorts of permissions.
What Is Up In the CloudsLast time, I mentioned ACTION_PICK_IMAGES and how it may be backed by CloudMediaProvider objects.It appears that this might extend beyond images someday, as there arenew interfaces tied to CloudMediaProvider rendering previews on a supplied SurfaceIt���s possible that this is just for animated images, but my guess is that theremay be more coming in this area, if not in Android 13 then in future versionsof Android.
What Makes Me Want to Change the ChannelThere are a ton of new and changed classesin android.media.tv,which pertains to actual TV channel playback on an Android TV device.
And, there arechanges to the new android.media.tv.interactive package,including a new TvInteractiveAppService.That is described as ���a service that provides runtime environment and runs TV interactive applications���.It is not completely clear what ���TV interactive applications��� are that are somehowdifferent from ���applications that run on Android TV���.
What Brings to Mind a Beatles SongActivities, fragments, and dialogs all now implement OnBackInvokedDispatcherOwner.From these, you can get an OnBackInvokedDispatcherand use that to register an OnBackInvokedCallback,allowing you to get back.
What Makes Me Wonder If These Supplements Are FDA-ApprovedA process can be supplemental.It is unclear what this means.
There is also a new supplementalapi package,containing an AdServicesVersion. Because of course an operating systemshould be in the business of managing ads.
Oddly, given these changes, SUPPLEMENTAL_PROCESS_SERVICE was removed in DP2 afterhaving been added in DP1.
What Fulfills Some Developer FantasiesI see a fair number of developers wanting to block or the screenshots shown in the overviewscreen. FLAG_SECURE blocks them nicely, but also blocks all other types of screenshots.Some developers have been trying to play games with replacing the activity contentat just the right time, like that���s ever going to be reliable. Now, we finally canopt out of those screenshots.
What Helps Me Stay Awake At NightYou can now call setStateListener() on a WakeLockand register a WakeLockStateListener,letting you know if the WakeLock is enabled or disabled.
Mostly, this appears to be for cases where you want the wakelock to be enabled,but the system decided to disable it.
What Else Caught My EyeThere are a bunch of new feature identifiers,including ones that seem tied to the 12L merger (e.g., FEATURE_EXPANDED_PICTURE_IN_PICTURE).
Android 12L added activity embedding, as one way to take advantage of largerscreen sizes. 13 DP2 appears to let you control which apps can embed youractivities, via android:knownActivityEmbeddingCertsattributes on <application> and <activity>. And, it appears that you canallow arbitrary apps to embed your activity via android:allowUntrustedActivityEmbedding.
There is now an EthernetNetworkSpecifier,suggesting a continued push into less-mobile devices, like perhaps TVs.
There is now a Dumpable and DumpableContainer pair of interfaces,for dumping stuff to a PrintWriter.
showNext() and showPrevious() on RemoteViews are now deprecatedin favor of setDisplayedChild().
There is a new LocaleConfig class,with a broken explanation.
There is a new isLowPowerStandbyEnabled()method on PowerManager, continuing the War on Background Processing. Becausewhen you have 18 power modes, adding a 19th will help. On the other end of the power spectrum, you can now find out if you are plugged into a dock,though I now really want BATTERY_PLUGGED_WHARF and BATTERY_PLUGGED_PIER as well.
And it still seems as though changes are afoot for android:sharedUserId, asthe new EXTRA_NEW_UIDwill tell you about changes to uids.


