LightBlog

jeudi 18 février 2021

Android 12 is here with its first Developer Preview and a lot of changes for developers

The Android operating system has been around for years now, and it’s become the dominant OS for mobile devices. While Android as a platform has definitely matured over the years, there’s always room for some improvement. And improve it will, as Google is now releasing the first version of its next upgrade, Android 12. Android 12 Developer Preview 1 is here, and it brings along changes that make Android more intuitive, better performing, and more secure.

Before we move on, here’s something that needs repetition: This Developer Preview, as the name implies, is intended for developers only so they can try out the upcoming OS and test their apps to adapt to the changes that are introduced. That means this is a very rough OS release, as is intended, but Google will be polishing it with developer feedback over the next few months. If you’re an average user, the Android 12 update for you will arrive not before the second half of the year. Until then, we recommend you stay away from flashing the builds onto your phone and just read our coverage to stay updated on all the changes coming to Android!

Android 12 is being built with the tenants of privacy, better user experience, and better performance, with its Developer Preview 1 introducing:

  • Trust and Safety
    • Modern SameSite cookie behaviors in WebView
    • Restricted Netlink MAC
    • Safer exporting of components
    • Safer handling of intents
  • Better User Experience Tools
    • Compatible media transcoding
    • AVIF image support
    • Foreground service optimizations
    • Rich content insertion
    • Haptic-coupled audio effect
    • Multi-channel audio
    • Immersive mode improvements for gesture navigation
    • Notification UI updates
    • Faster and more responsive notifications
    • Improved Binder IPC calls
  • App Compatibility
    • Project Mainline / Google Play System Updates:  ART and more
    • Optimizing for tablets, foldables, TVs
    • Updated lists of non-SDK interfaces
    • Easier testing and debugging changes
    • Platform stability milestone
  • How to Download and How to Install Android 12 Developer Preview 1

Trust and Safety related changes in Android 12

Google hopes to give users more transparency and control while keeping Android devices secure. Android 12 brings along new controls over identifiers that can be used for tracking, safer defaults for app components, and more.

Modern SameSite cookie behaviors in WebView

WebView is being updated to bring it in line with changes to Google Chrome and other browsers, with respect to SameSite cookie behaviors. This will provide additional security and privacy, and give users more transparency and control over how cookies can be used across sites.

Restricted Netlink MAC

Google wants developers to migrate to privacy-protecting resettable identifiers. To that end, it has adopted a multi-release effort to ease migration of device-scoped Netlink MAC. Android 11 restricted access to device-scoped Netlink MAC to API level 30, and in Android 12, the restriction is being applied for all apps, regardless of targetSDK level.

Safer exporting of components

Apps on previous Android releases can inadvertently export activities, services, and receivers. Google is changing the default handling of the android;exported attribute to be more explicit in Android 12. With Android 12, components that declare one or more intent filters must now explicitly declare an android;exported attribute. Google is advising developers to inspect their components in the manifest in order to avoid installation errors related to the change.

Safer handling of Intents

Android 12 requires apps to explicitly declare a mutability flag, either FLAG_MUTABLE or the new FLAG_IMMUTABLE, for each PendingIntent. This should make handling PendingIntents more secure.


Better User Experience Tools in Android 12

No update is complete without some more polish towards the user experience, and Android 12 is no different.

Compatible media transcoding

Most mobile devices these days come with H.265 / HEVC hardware encoding, allowing camera apps to capture in the HEVC format as it offers significant improvements in quality and compression over older codecs. Most apps support HEVC, but there are still a few that do not support it. For these apps, Google is introducing compatible media transcoding with Android 12.

With this feature, an app that does not support HEVC can have the platform automatically transcode the file into H.264 / AVC, a format that sees much wider compatibility. As one would expect, the transcoding process will take some time depending on the video and the hardware properties of the smartphone. Google provides the example of the Pixel 4 (Snapdragon 855) that takes around 9 seconds to transcode a 1-minute 1080p 30fps video.

Developers can opt-in to use the transcoding service by simply declaring the media formats that their app does not support. Google strongly recommends that apps support HEVC in the first place, but if that is not possible, then the developer should enable compatible media transcoding. The feature will be active on all devices using HEVC format for video capture.

AVIF Image Support

Android 12 is introducing platform support for AV1 Image File Format, allowing for higher image quality with more efficient compression. AVIF is a container format for images and sequences of images encoded using AV1. AVIF takes advantage of the intra-frame encoded content from video compression, dramatically improving image quality for the same file size when compared to older image formats such as JPEG.

Left: AVIF (18.2kB). Right: JPEG (20.7kB). Credits: Image comparison from AVIF has landed by Jake Archibald

Foreground Service Optimizations

A foreground service is a service that performs some operation that is noticeable to the user, like an audio app playing an audio track and thus using a foreground service. These services are an important way for apps to manage certain types of user-facing tasks. But when they are overused, it can affect performance and even lead to app kills.

Citing user experience improvements, Google will be blocking foreground service starts from the background for apps that are targeting the new platform. And to make it easier for developers to transition away from this start pattern, Android 12 introduces a new expedited job in JobScheduler that gets elevated process priority, network access, and runs immediately regardless of power constraints like Battery Saver or Doze. For back-compatibility, Google has also built expedited jobs into the latest release of Jetpack WorkManager library. Further, Google is also delaying the display of some foreground service notifications by up to 10 seconds. This gives short-lived tasks a chance to complete before their notifications are shown, reducing distraction for users.

Rich Content Insertion

We’ve long crossed the point where our communication on phones relied only on simple voice and text. Most communication these days is incomplete without accompanying images (read: memes), videos, and other expressive content (read: reaction gifs). However, inserting and moving these rich types of content within and across apps is not easy.

To make it easier for apps to receive rich content, Google is introducing a new unified API that lets them accept content from any source: clipboard, keyboard, or drag and drop. Developers can attach a new interface called OnReceiveContentListener to UI components and get a callback when content is inserted through any mechanism. This callback consequently becomes the single place for the app code to handle the insertion of all types of content, whether it be plain text, styled text, markup, images, video, or audio files, and beyond.

For back-compatibility, Google has added the unified API to Androidx.

Haptic-coupled audio effect

In Android 12, apps can provide audio-coupled haptic feedback through the phone’s vibrator. Further, the vibration strength and frequency are derived from an audio session, allowing developers to create a more immersive game and audio experience. For instance, calling apps can perhaps use custom ringtones to identify callers through haptic feedback, and games could simulate rough terrain in a racing game. There are a fair few possibilities to explore here.

Multi-Channel Audio

Android 12 includes several enhancements for audio with spatial information. It adds support for MPEG-H playback in passthrough and offload mode. The audio mixers, resamplers, and effects have been optimized for up to 24 channels (the previous maximum was 8 on Android 11).

Immersive mode improvements for gesture navigation

Android 12 brings along a change that sounds very important on the surface. In full-screen or immersive app experiences, Android 12 will allow users to navigate their phones with one swipe as a default. The OS will still protect apps from accidental gestures in these full-screen experiences. We’ll be getting our hands on the Developer Preview to figure out exactly what has changed as the wording does not do complete justice to the change.

Notification UI updates

As you may have already spotted in the leaked Android 12 screenshots, notifications will be receiving a bit of a touch-up to make them more modern, easier to use, and more functional. Google mentions that there are changes from the drawer and controls to the templates themselves. Transitions and animations are also being optimized to make them smoother. Apps that target Android 12 will also have access to notifications with custom content with icon and other changes to match all other notifications. We’ll be taking a closer look at the changes in our hands-on.

Faster and more responsive notifications

Notifications should offer a clear and quick path to reach a certain section within an app. For that cause, developers need to ensure that notification taps trigger Activity starts directly, rather than using an intermediary broadcast receiver or service to start the Activity (an approach that Google is referring to as Notification Trampoline). Notification Trampolines can cause significant delays and affect user experience, and so, Android 12 will block these notification trampolines by preventing them from launching their target Activities. Google is asking developers to migrate away from such a practice. This change applies only to apps targeting the new platform, but for all apps, Google will display a toast to make trampolines visible to the developer and to users.

Improved Binder IPC calls

Google has focused on reducing system variability by making optimizations to latency and workload distribution that reduce the median experience for 99% percentile use cases. This has resulted in improvements to system binder calls, adding lightweight caching strategies and focusing on removing lock contention to improve latency distribution. Google claims that this has yielded about 2x performance increase on Binder calls overall, with significant improvements in specific calls such as refContentProvider() (47x improvement), releaseWakeLock() (15x improvement), and JobScheduler.schedule() (7.9x improvement).


App Compatibility in Android 12

In this section, Google talks about making updates faster and smoother for both developers and users. App-facing changes are being made opt-in to give developers more time to adapt to the new platform.

Project Mainline / Google Play System Updates:  ART and more

As we figured out last year itself, Google is transitioning ART into a Project Mainline module. This will allow Google to improve runtime performance and correctness, manage memory core more efficiently, and make Kotlin operations faster — all without requiring a full system update.

Further, some of the functions mentioned in this very news piece are also being delivered through Project Mainline. For instance, the seamless transcoding feature is being delivered through an updatable module, indicating that this could very well be the future for Android.

Optimizing for tablets, foldables, and TVs

Google is also releasing the first Android 12 preview for Android TV. With this, you not only get the latest Android features on the TV, but also get to test against the new Google TV experience.

Updated lists of non-SDK interfaces

With this release, Google has restricted additional non-SDK interfaces.

Easier testing and debugging changes

Introduced with Android 11, Google allows for easier testing and debugging of changes through opt-in toggles for changes presented individually from Developer Options or through ADB.

Platform stability milestone

Just like last year, Google is planning to reach the Platform Stability milestone for this release, to let developers have concrete knowledge about the final SDK/NDK APIs and all the final internal APIs and app-facing system behaviors that they need to prepare their app for. Google is expecting to reach Android 12 Platform Stability by August 2021.


Download and Install Android 12 Developer Preview 1

You can easily download the latest Android 12 Developer Preview from the links present in our dedicated article, which shall be updated with download links for future releases as well.

Google is officially releasing this developer preview update for:

Further, we have installation instructions available for Android 12 Developer Preview 1 for common installation routes such as Recovery, ADB, and Fastboot for the aforementioned Pixel devices, and through a GSI for all other Project Treble-compatible devices.

The post Android 12 is here with its first Developer Preview and a lot of changes for developers appeared first on xda-developers.



from xda-developers https://ift.tt/3at6YZP
via IFTTT

Aucun commentaire:

Enregistrer un commentaire