By Dave Burke, Vice President of Engineering

Last month, we releasedThe first preview of Android 12″, giving developers a taste of the new version of Android. Now we’re bringing you the next milestone in this year’s planned release: Developer Preview 2, with more new features and changes that you’re welcome to try out on your own. Open collaboration is at the heart of our early preview program, designed to work with the developer community. Your input will help us build a better Android platform for developers and users alike. Please continue to give us feedback!

With Android 12, we are committed to making the operating system smarter, easier to use, and more powerful, with privacy and security at its core. We will also provide you with new tools to help you create a better experience for your users, whether they are using a phone, laptop, tablet, TV or car. Today’s announcements include a new rounded corners API, improved picture-in-picture API, better companion device management, easy-to-use effects like blur and color filters, app overlay controls, and more.

There’s a lot to play with in Developer Preview 2, and this article will detail some of the highlights! To learn more about this preview and to get information about downloading and installing it to Pixel devices, visit the Android 12 developer website. We will also be offering an over-the-air (OTA) update today for those who already have Developer Preview 1 or 1.1 installed.

Don’t forget to tell us what you think, and thanks again to every user for their valuable feedback.

Trust and Security

We remain focused on providing users with more transparency and control, while keeping devices and data secure. In today’s preview, we’ve added some new features for your application to test out.

App Override Control – Android’s system alert dialog allows an app to display a layer on top of other active apps to help the app alert users to important actions. However, because these Windows interrupt user operations, the application needs to request permission to display the content. In Android 12, you can control whether or not you allow these overlay layers to be displayed on your content. After declaring the new permissions, your application can call Windows #setHideOverlayWindows() to indicate that all TYPE_APPLICATION_OVERLAY Windows should be hidden when your application window is visible. You can do this in sensitive interfaces such as the transaction confirmation process. Please visit the official documentation for details.

Extending security for Screen-lock Notifications – Android 12 adds more fine-grained privacy and security controls to control the notifications displayed when a device locks its screen. You can now configure notification actions so that authentication challenges are always generated when a notification action is triggered by a screen lock. This feature is an extension of the existing notification visibility controls in the notification API. For example, this feature allows an instant messaging application to request authentication before deleting a message or marking it as read. Please visit the official documentation for details.

Accessing the App Summary – For applications that need to verify the integrity of an app package installed on an Android device, we have introduced a new API that allows you to query the platform directly for the checksum of an installed app. You can choose from a variety of digest algorithms, including SHA256, SHA512, and Merkle Root. In request the checksum, the application package name, need to check and types, the trust certificates of the installation program, and to receive the check and the listener as a parameter to invoke the PackageManager. RequestChecksums (). Depending on the parameters, the platform returns a checksum either precomputed by the installer (such as Google Play) or computed directly by the platform. The returned results are filtered by package visibility criteria, so you need to declare the packages you want to see in the manifest. This new API allows you to get checksums in a simpler and more efficient way, with the stability of standard public apis, but also optimized for faster and more secure usage. To support backward compatibility, we are developing a corresponding Jetpack library that will bring this functionality to API 15 and above. We’ll bring you more details on this later, so stay tuned. Learn more about privacy and security changes.

Better user experience tools

We are committed to providing you with more tools to help you build better experiences and achieve better performance. Here are some of the updates in Developer Preview 2.

Support the rounded– Many modern devices have rounded corners on their screens, which makes for a clean and stylish look, but also creates additional problems for app developers. To deliver a great user experience on these devices, developers need to take these rounded corners into account and adjust interface elements around them to prevent them from being cropped.

To address this issue, we have introduced a new API that makes it easy for you to query rounded corners and their details. RoundedCorner provides information about rounded radius, center point, and more. You can get detailed information about each rounded corner by using display.getroundedCorner (). . You can also call WindowInsets getRoundedCorner () to obtain information such as the rounded corner position based on your application boundary. This gives you the flexibility to adjust the placement of interface elements and content as needed. Please visit the official documentation for details.

Picture in Picture (PIP) improvements – For users who use gesture navigation, we have improved the way the app transitions to PIP mode when swiping up to the home screen. If an app has automatic PIP enabled, the system now transitions the app directly to PIP mode when the user is swiped to the home screen, rather than waiting for the swiped to the home screen animation to complete. This smoothes the transition and improves perceptual performance. We also improved the way PIP Windows are resized for non-video content. Applications can now enable seamless resizing, allowing the system to resize PIP activities as needed. Android 12 also supports hiding the PIP window by dragging it to the left or right edge of the screen. In addition, to make the PIP window easier to manipulate, we’ve updated the click-action behavior: a single tap now displays the control, and two taps toggle the PIP window size. Please visit the official documentation for details.

Keeping companion Devices Awake – For apps that manage companion devices such as smartwatches and fitness trackers, ensuring that associated companion devices stay up and connected when they are nearby is a challenge. To make this easier, we’ve introduced a new CompanionDevice Manager API for Companion Deviceservice. Applications that manage ancillary devices can use this service to let the system wake up the application when the associated ancillary devices are nearby. The system ensures that the service is awake when the device is nearby, and notifies the service when the device enters and leaves the connection range or shuts down, so that the application can clean up the state as needed. When connected to a watch, the app can also use new companion device configurations to simplify the registration process by binding related permissions to a single authorization. Please visit the official documentation for details.

Improved Bandwidth estimation – For developers who need to know their users’ available bandwidth in order to customize their experience, we have improved bandwidth estimation capabilities and enhanced our existing bandwidth estimation API to give data throughput estimates for each carrier or Wi-Fi SSID, network type, and signal strength for all users on the device. The new estimation method is simpler and more accurate than most other methods, and you are welcome to try it out and give feedback.

Easier blur, color filters, and more – In Android 12, you can more easily apply commonly used graphics effects to views and render structures. You can use RenderEffects to apply specific effects such as blur and color filters to any RenderNode. You can combine these effects into chain effects (that is, inner and outer effects) or mix them. You can also apply effects directly to a View (View, because it is based on RenderNode) by calling View.setrenderEffect (RenderEffect).

view.setRenderEffect(RenderEffect.createBlurEffect(radiusX, radiusY, SHADER_TILE_MODE))
Copy the code

Set the blur effect for the view using RenderEffect

With this feature, you don’t have to get Bitmap data, process the image, create a new Bitmap, and set it back to the ImageView when you blur the ImageView. RenderEffect leverages the existing rendering pipeline to minimize extra computation.

Please try the above features and share your experience with us! Please visit the official documentation for detailed information on rendering effects.

You can also use a new Window. SetBackgroundBlurRadius () API to create fog glass Window background effect. This API allows you to set the blur radius to adjust the fog density and range, and the platform will only apply the blur effect to the background content within the border of your application window. You can also use blurBehindRadius to blur everything behind the window to create depth for the floating window.

▽ The background of the window and the contents behind the window are blurred

Application compatibility

When launching new versions of the platform, we will prioritize application compatibility to make the system update experience faster and smoother. In Android 12, most application-oriented changes are optional, giving you more time to adjust. We’ve also updated our tools and processes to help you get ready faster.

The release of Developer Preview 2 means that we have done a lot of work in the release phase and are continuing to improve overall stability. Now people can experiment with new features and changes and give us feedback. We look forward to your feedback on how the API is being used and how platform changes affect the application. Please visit the feedback page to share your thoughts or report a problem.

Now you can also start compatibility testing and determine what needs to be done next. We encourage developers to do this early to release compatible updates when Android 12 Beta 1 comes out. There is no need to change the targetSdkVersion of the app at this time, but we recommend using the behavior change toggle to get a feel for how the optional changes in Android 12 will affect the app.

We will reach the platform stability milestone in August 2021, when all the application-oriented system behavior, SDK/NDK API and non-SDK listings will be finalized. At that point, you can complete final compatibility tests and release a fully compatible application, SDK, or development library. Release schedule as bellow: developer. The android. Google. Cn/preview/ove…

△ App compatibility switch in developer options

Start playing Android 12 now

Whether you want to try out Android 12’s features, test your apps, or submit feedback, you can start with this developer preview. Simply download and swipe your device’s system image into your Pixel 3/3 XL, Pixel 3A / 3A XL, Pixel 4/4 XL, Pixel 4A / 4A 5G or Pixel 5 device, or use an Android emulator to start using immediately. If you already have the preview installed on your Pixel device, you will automatically get all subsequent preview and Beta updates over OTA. Please visit the official documentation for details.

You can also use Developer Preview 2 to test your apps on Android TV and try out the new Google TV experience. Head over to the Android TV developer website for more information and get started with the ADT-3 developer kit.

For full information on the release, visit the Android 12 developer website.