An overview of the

The Android 11 Developer Preview is scheduled to start in February 2020 and end when the final public release is available to AOSP and Oems, with the final release expected in the third quarter of 2020. That is to say, we will use the official version in September or October, but there may be a little delay due to the epidemic. I hope the epidemic will end soon!

Attached is a timeline from Google’s website:

A lot of people say that they have just used Android 10 to complete the adaptation, but Android 11 has come, and it is too difficult.

It’s a bit of a bummer, but it’s nice to think that the upgrade is definitely for Android. Let’s take a look at what Android 11 has in store for us.

Version features

What are the important updates for users?

  • Seamless update

    Seamless updates require virtual A/B partitions at Android 11 startup to reduce downtime caused by system updates and provide A mechanism for recovery if updates go wrong.

    When the Android system is updated, the phone will boot into the recovery state and may remain on the “Install System Update” screen for up to 25 minutes. This will result in a lot of downtime, during which you won’t be able to run any apps, check any texts, or answer any phone calls. The outage occurs because system partitions need to be taken offline while system files are being updated, but seamless system updates solve this problem by using both system partitions.

  • Optimize 5G support

    Android 11 brings a whole new connectivity API to support 5G networks, so it can take advantage of the improved speeds and delays 5G offers, such as enabling apps to automatically serve high-quality video when a high-quality network is detected.

    Dynamic metering API

    Using this API, you can check if the connection is unmetered and, if so, provide higher resolution or quality, potentially using more data. Expanded the SCOPE of the API to include cellular networks so that you can identify users whose carriers provide true unmetered data when connecting to their 5G network.

    Bandwidth estimator API

    The API for 5G has been updated to make it easier to check downstream/upstream bandwidth without polling the network or calculating your own estimates. If the modem does not provide support, we will do a default estimate based on the current connection.

  • Turn on airplane mode, bluetooth headset keeps connecting

    In the Android 11 developer preview, users can connect to a Bluetooth headset and turn it on in airplane mode, and bluetooth will continue to connect, and there will be a message notification.

  • Scroll screenshot/long screenshot

    Although many handset manufacturers have already integrated deep customization systems, the native Android 11 is finally supported, which is good.

  • Battery Shared

    The battery-sharing feature is similar to “reverse wireless charging”, allowing users to share the Pixel’s battery with other compatible devices, including smartwatches, headphones and more.

  • Use rich media in quick replies

    Starting with Android 11, users can insert images and other rich media content into quick replies.

  • Floating chat bubble

    Floating chat bubbles is a new feature in Android 11, which allows apps to bubble ongoing conversations across the screen as long as they use a new API.

  • Privacy and Permissions

    Android 11 has added one-time permissions for location, microphone, and camera. In other words, an APP with a one-time license will still have to ask the user for authorization the next time it is used.

  • Screen video

    On-screen recording was featured in early versions of Android 10, but has since been removed. With the release of the Android 11 Developer preview, on-screen recording is back.

What do you need to pay attention to for developer adaptation?

  • Storage Mechanism Update
  • Permission to update
  • Application package visibility
  • Front Desk Service Type
  • Update of message box (Toast)
  • Supports concurrent use of multiple cameras
  • Some other new features

Attached is the major privacy change chart on the official website:

Storage Mechanism Update

Partitioned storage forcibly executed

Android10 has introduced the feature of partitioned storage. Partitioned storage mainly divides shared storage into collections and restricts application access to this area at will

  • Clear application attribution
  • Protection of application data
  • Protection of user data

Everyone knows Android10 provides requestLegacyExternalStorage = true opt out partition storage, would be forced to use in the Android11 partition storage.

But the official to give developers more time to test, with Android 10 (29) API level for the application of the target platform can still request requestLegacyExternalStorage properties. Applications can use this flag to temporarily disable partitioned storage-related changes, such as granting access to different directories and different types of media files. When you will be applying updates to the Android after 11 for the target platform, system will ignore requestLegacyExternalStorage tag.

Maintain compatibility with Android 10

If the application running on Android devices 10 opt out partition storage, it is recommended that you continue to in the application of listing file requestLegacyExternalStorage set to true. That way, apps can continue to work as expected on devices running Android 10.

Migrate data to a directory visible when using partitioned storage

If your application uses an older storage model and previously targeted Android 10 or lower, you may store data in directories that your application cannot access after enabling the partitioned storage model. Before targeting Android 11, migrate your data to a directory compatible with partitioned storage. In most cases, you can migrate data to your application-specific directory.

If you have data that needs to be migrated, you can keep the old storage model when users upgrade to a new version of the application targeting Android 11. In this way, users can retain access to application data stored in the same directory your application used to store data. If you want to enable the old storage model in order to upgrade, please the list in the application preserveLegacyExternalStorage attribute set to true.

Note: most applications don’t need to use preserveLegacyExternalStorage. This flag only applies if you have migrated application data to a location compatible with partitioned storage and want users to retain access to the data when updating your application. Using this tag makes it more difficult to test how partitioned storage affects the users of your application, because when the user updates your application, it will continue to use the old storage model.

If you are using preserveLegacyExternalStorage old storage model only when the user unloading remain valid before your application. If the user in carrying the Android devices installation or reinstall your application, so whatever preserveLegacyExternalStorage values, your application cannot disable partition storage model.

Test Partitioned Storage To enable partitioned storage in your application regardless of the target SDK version and manifest tag value of the application, enable the following application compatibility flags:

DEFAULT_SCOPED_STORAGE (enabled for all applications by default) FORCE_ENABLE_SCOPED_STORAGE (disabled for all applications by default) If you want to disable partitioned storage and switch to the older storage model, unset these flags.

Media file access permission

Store permissions

  • For all applications

    Storage runtime permissions have been renamed Files & Media

  • Android11 for the target platform applications

    WRITE_EXTERNALSTORAGE and WRITE_MEDIA_STORAGE do not provide any additional access rights

Manage device storage space

If your application is a file manager application running on Android 11, it can no longer delete other applications’ cached files, even if your application has full file access. Instead, your application should do the following:

Check the available space by calling the ACTION_MANAGE_STORAGE Intent action. If there is not enough free space on the device, ask the user to agree to let your application clear all caches. To do this, call ACTION_CLEAR_APP_CACHE intent.

Note: ACTION_CLEAR_APP_CACHE Intent actions can seriously affect the battery life of the device and may remove a large number of files from the device.

MediaStore API and batch processing

In Android 11, you can no longer delete files from other apps without the user’s consent, even if your app has full file access.

  • Allows batch editing/deletion

  • Multiple methods have been added to the MediaStore API

    createWriteRequest()

    A request by a user to grant an application write access to a specified media file group.

    createFavoriteRequest()

    A request by the user to mark a specified media file on the device as favorites. Any application that has read access to the file can see that the user has marked the file as favorites.

    createTrashRequest()

    A request by the user to place a specified media file into the device garbage bin. The contents of the trash can are permanently deleted after a system-defined period of time.

    createDeleteRequest()

    A request by the user to delete the specified media file immediately and permanently, rather than putting it in the trash first.

Apply for batch operation permissions for media files as follows :(thanks Google team for sharing)

Use the original path to access the file

Android 10 does not allow direct file path access, but it is difficult for some third-party frameworks to call native methods without directly using file path access. So Android 11 starts allowing applications with READ_EXTERNAL_STORAGE permission to read device media files using the direct file path and native libraries. With this feature, your application works better with third-party media libraries.

If you use a direct path to the file and native libraries, it is recommended that you in the application of the listing file requestLegacyExternalStorage set to true, so as to select disable partition storage. This ensures compatibility between previous versions.

Points to note:

  • The direct access path is MediaStore based, and using it directly is bound to cause performance degradation, depending on the I/O mode
  • The performance impact of opening and first reading is relatively significant
  • Use it only if third-party libraries require direct access to the path, and use the MediaStore API whenever possible for performance reasons

Access the private directories of other applications

On Android 11, apps can no longer access files in the application-specific directories of any other apps on the external storage device.

Document access restrictions

To give developers time to test, the following changes related to the Storage Access Framework (SAF) will only take effect if the app is targeted at Android 11.

  • Access to the directory

    You can no longer request access to the following directories using the ACTION_OPEN_DOCUMENT_TREE Intent action:

    Root directory of the internal storage volume.

    The root directory of each SD card volume that the device manufacturer considers reliable, whether the card is an analog or removable card. The Download directory.

  • Access to the file

    You can no longer use ACTION_OPEN_DOCUMENT_TREE or ACTION_OPEN_DOCUMENT Intent actions to ask the user to select a separate file from the following directory:

    The Android/data/ directory and all its subdirectories.

    The Android/obb/ directory and all its subdirectories.

All file access rights

If your application needs to access a large number of files in the shared storage area, you can obtain all file Access by:

  • Declare MANAGE_EXTERNAL_STORAGE permission.

  • Using ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION intent

The actions take the user to a system Settings page, where the user can enable the following options for your application: Grant administrative rights to all files.

All File Access Rights grants the following permissions:

  • Read and write permission to all files in the shared storage space.

  • Access to the contents of the Mediastore.files table.

The permissions is suitable for the batch processing function such as file management and backup restore applications use, if you only need to access a file and a few such functions using storage access framework can not get all files “access”, looking forward to Google play to make a further specification, clear compliance/no compliance of use cases.

Permission to update

With Android 11, users will be able to specify more detailed permissions for location information, microphone and camera, as users become more concerned about app privacy

One-time permission

Android 11 has added one-time permissions, and every time an app requests permission related to location information, microphone, or camera, the user-facing permissions dialog box contains the option to do this once only. If the user selects this option in the dialog box, the system grants temporary single authorization to the application. When the function is used, the system will reclaim this permission.

The application can then access the relevant data for a period of time, depending on the application’s behavior and the user’s actions:

  • When the application’s Activity is visible, the application can access related data.

  • If the user transfers the application to the background, the application can continue to access related data for a short period of time.

  • If you start a foreground service while your Activity is visible, and the user then moves your application to the background, your application can continue to access the relevant data until the foreground service is stopped.

  • If a user revokes a single authorization (for example, in system Settings), the application cannot access the data, whether or not you have started the foreground service. As with any permission, if the user revokes the application’s single authorization, the application process terminates.

About adaptation: no change!!

If your application already follows best practices related to permissions, you can support single authorization without changing your application.

In particular, before attempting to access information protected by a privilege, be sure to check whether the application has that privilege; If the application requests permission for the first time, or if the user has revoked permission, complete the following process:

1. Call shouldShowRequestPermissionRationale (). If this method returns true, display an interface element in your application that explains to the user why your application needs permissions.

2. Request permission.

A dialog box is displayed to request the right time limit again

The next time the user opens the app and the app subsequently requests permissions related to location information, microphone or camera, the system will prompt the user again.

Request permission process (thanks Google team for sharing) :

The first time a user requests permission, the default is no reason for calling the permission. When the user rejects the permission for the first time, the reason for calling the permission is explained in this callback. When the user knows the reason, Once again to apply for permission system will adjust shouldShowRequestPermissionRationale () = true, developers can pop-up permissions in this judgment explanation and allow the user to decide whether to continue to apply for permission to obtain system permissions box or (no thanks), If the system permission box is rejected twice, it will never be displayed again.

Visibility of the Permissions dialog box

Android 11 does not recommend repeating requests for permissions in a specific permission group. After an application is installed on the device, if a user clicks reject twice for a specific permission, this operation indicates that the user does not ask for the permission in the corresponding permission group in the future.

The system also defines the response behavior for operations similar to clicking reject:

If the user presses the back button to close the permission dialog box, this action does not count as a “reject” action.

If the user uses requestPermissions() to go from your application to system Settings and then presses the back button, this action counts as a “rejection” action.

The phone number

Android 11 changes the phone-related permissions that your app uses to read phone numbers.

If your application is targeting Android 11 and needs access to the phone number API shown in the list below, you must request READ_PHONE_NUMBERS, not READ_PHONE_STATE.

The getLine1Number() method in the TelephonyManager class and the TelecomManager class.

The unsupported getMsisdn() method in the TelephonyManager class.

If your application declares READ_PHONE_STATE to invoke methods other than those in the previous list, you can continue to request READ_PHONE_STATE on all Android versions. However, if you only use the READ_PHONE_STATE privilege for the methods in the previous list, update your manifest file as follows:

Change the READ_PHONE_STATE declaration so that your application uses this permission only for Android 10 (API level 29) and lower.

Add the READ_PHONE_NUMBERS permission.

The following manifest declaration code snippet demonstrates this process:

<manifest> <! -- Grants the READ_PHONE_STATE permission only on devices that run Android 10 (API level 29) and lower. --> <uses-permission android:name="READ_PHONE_STATE"
                     android:maxSdkVersion="29" />
    <uses-permission android:name="READ_PHONE_NUMBERS" />
</manifest>
Copy the code

Location permissions

There are foreground location permission and background location permission, in the target version of Android R below the default is to apply for foreground location permission at the same time to apply for background location permission, and Android R can not apply at the same time, can only apply for foreground location permission and then apply for background location permission.

Background location information access permission

Android 11 further emphasizes user control over location information by adding single-pass authorization and removing the ability for users to grant access to ACCESS_BACKGROUND_LOCATION via in-app prompts

  • If your application is targeting Android 11, you can create a custom interface that explains to the user why your application requires ACCESS_BACKGROUND_LOCATION permission.

  • If your application is targeted at a later version of the platform, you must use the interface provided by the system that indicates that your application needs to access location information in the background, even if your application is not being used.

Create a custom interface

If your application is targeting Android 11, you can display a custom interface that more clearly explains to the user why your application needs the ACCESS_BACKGROUND_LOCATION permission.

Follow the guidelines in this section to create an interface that is easier for users to understand.

Application requirements For background location Information To request ACCESS_BACKGROUND_LOCATION for your application, your application must obtain the foreground location permission, that is, ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION. If you try to request both ACCESS_BACKGROUND_LOCATION and any other permissions, the system will throw an exception.

When you have foreground location permissions, you need to pop up the reason for requesting background location permissions:

  • Grant permission. If the user selects this option, a permission request is made on ACCESS_BACKGROUND_LOCATION. The system directs the user to the system Settings to complete the process of granting this permission.

    To help users find options in Settings to grant ACCESS_BACKGROUND_LOCATION permission, you can add user-visible labels to the corresponding Settings option in the application interface. GetBackgroundPermissionOptionLabel () method can provide according to the user’s device language preferences for the localization of label.

  • No permissions are granted. If users do not grant permissions, they should be able to continue using the application. If the user selects this option, the application can continue to run normally, but may remove the user from functions that require access to background location information.

Note that even after granting ACCESS_BACKGROUND_LOCATION to the application, users can change their location information access in the system Settings to be allowed only when using the application or asked every time. Users can also deny applications access to location information entirely.

Direct users to system Settings as needed

If the user agrees to grant ACCESS_BACKGROUND_LOCATION to your application, your application should send the user to the system Settings to enable ACCESS_BACKGROUND_LOCATION

Redirection to system Settings restricted

After the application takes the user to its permissions page in system Settings, the user may choose to always allow access to location information other than the permission level, such as deny. Android 11 allows apps to direct users from a screen to system Settings up to twice. Therefore, it is important to clearly explain to users why application functionality needs to access location information in the background.

When the application reaches this limit, you can still invoke an Intent to direct the user to the information page applied to the system Settings. From this page, users can go to the application’s permissions page. To load the application information page, run settings. ACTION_APPLICATION_DETAILS_SETTINGS Intent.

Application package visibility

Android 11 changes the way apps query and interact with other installed apps on the same device. If your application is targeting Android 11, you may need to add elements to your application’s manifest file so that the system knows what other applications to show your application.

Query for and interact with specific software packages

If you know a specific set of applications that you want to query or interact with (for example, applications that integrate with your application or applications whose services you use), add their package names to a set of elements within the tag:

<manifest package="com.example.game">
    <queries>
        <package android:name="com.example.store" />
        <package android:name="com.example.services" />
    </queries>
    ...
</manifest>
Copy the code

Query and interact with an application given an Intent filter

Your application may need to query or interact with a set of applications with a specific purpose, but you may not know the specific package name to add. In this case, you can list the Intent filter signature in the tag. Your application can then find applications with matching tags.

The following example allows your application to see an installed application that supports JPEG image sharing:

<manifest package="com.example.game">
    <queries>
        <intent>
            <action android:name="android.intent.action.SEND" />
            <data android:mimeType="image/jpeg" />
        </intent>
    </queries>
    ...
</manifest>
Copy the code

Query all applications and interactions with them

In rare cases, your application may need to query or interact with all installed applications on the device, regardless of what components those applications contain. For example, Google Play and other app stores. To allow your application to see all other installed applications, Android 11 introduces QUERY_ALL_PACKAGES permissions.

In the upcoming developer preview, Google Play will provide guidance for apps that need this privilege, so stay tuned.

Use cases that are impervious to change

The following list contains several examples of use cases that do not need to be declared:

  • The target application is your own application.
  • You can start an Activity with an implicit intent. Your application may limit how it interacts with other applications using implicit intEnts.
  • Your application interacts with some system package (such as a media provider) that implements the core functions of Android. Other applications expect results from your application. This happens when your application is a content provider, when other applications call your application by calling startActivityForResult(), and when your application is a service that other applications are trying to start or connect to.

For example, if another application makes a request to a content provider in your application, the system will allow your application to see that other application.

Launches a network intent in a non-browser application

If you want to open a URL from an app but don’t want the option to open it from a browser box, you can do this

If the phone in addition to the browser is not suitable for open the url in the way, would be thrown ActivityNotFoundException is unusual, can get to the exception for further processing.

Front Desk Service Type

Starting with Android 9, apps are limited to foreground access to the camera and microphone. To further protect users, Android 11 changes the way foreground services access data related to cameras and microphones. If your application targets The Android 11 platform and accesses these types of data in a foreground service, you need to add the new Camera and MICROPHONE types to the foregroundServiceType property declared by the foreground service.

Examples using location information and cameras

If a foreground service in your application requires access to device location information and camera-related data, declare the service as shown in the following code snippet:

<manifest>
    ...
    <service ... android:foregroundServiceType="location|camera" />
</manifest>
Copy the code

Examples using location information, camera, and microphone

If a foreground service requires access to location information, cameras, and microphones, declare the service as shown in the following code snippet:

<manifest>
    ...
    <service ...
        android:foregroundServiceType="location|camera|microphone" />
</manifest>
Copy the code

Update of message box (Toast)

Android 11 deprecated the custom message box view to protect users. To give developers more time to adjust to these changes, they will only take effect if your app is targeted at Android 11.

Points to note:

  • Message boxes containing custom views (using setView()) are masked if they are sent in the background from an Android 11 targeted application.

  • Text message boxes are still allowed; This type of message box is created using toast.maketext () without calling setView()

  • If you want to be notified when a message box (text message box or custom message box) appears or disappears, use the new addCallback() method.

  • Text Message Box API changes (Android 11 targeted apps)

    The getView() method returns NULLCopy the code

    The return values of the following methods do not reflect actual values, so you should not rely on them in your application:

      getHorizontalMargin()
    
      getVerticalMargin()
    
      getGravity()
    
      getXOffset()
    
      getYOffset()
    Copy the code

    The following methods are empty operations, so your application should not use them:

      setMargin()
    
      setGravity()
    Copy the code

Supports concurrent use of multiple cameras

Android 11 added apis to query support for using multiple cameras at the same time, both front and rear.

To check the support status on the device running the application, use the following methods:

GetConcurrentCameraIds () returns a Set of camera ID combinations that can be streamed concurrently with a guaranteed data stream combination if they are configured by the same application process.

IsConcurrentSessionConfigurationSupported () query camera equipment support whether can develop the corresponding session configuration.

Some other new features

Better support for waterfall screens

Android 11 provides some apis to support the waterfall screen, which is a full screen with no borders. The display is seen as a variation on bangs. The existing DisplayCutout. GetSafeInset… The () method now returns a safe margin that avoids the waterfall area and bangs. To render your app content in the waterfall area, do the following:

Call DisplayCutout. GetWaterfallInsets () to obtain waterfall lining the accurate size.

The window layout attribute set for LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS layoutInDisplayCutoutMode, extended to allow the window to screen the bang and falls on the edge of the area. You must make sure there is nothing important in the bangs or waterfall area.

Hinge Angle sensors and foldable devices

With Android 11, apps running on devices with a hinge screen configuration can determine the hinge Angle by: A new sensor with TYPE_HINGE_ANGLE is provided, as well as a new SensorEvent that monitors hinge angles and provides Angle measurements between two parts of the device. You can use these raw measurements to perform fine animation displays as the user manipulates the device.

While knowing the exact Angle of the hinges can be useful for some types of applications (such as starters and wallpapers), most should use the Jetpack window manager library to retrieve the DeviceState by calling devicestate.getposture ().

Application or you also can call registerDeviceStateChangeCallback (), to notified when DeviceState change, and change in the status of a response.

As there are and will be many more different Windows and device configurations on the market today, responding to device state is more secure and reliable.

5G icon display

In Android 11 (API level “R”) and later, With android. The Manifest. Permission. READ_PHONE_STATE permission application by PhoneStateListener. OnDisplayInfoChanged () request to update the phone display information, This includes information on wireless access technology for marketing and branding.

The new API offers a variety of 5G icon display solutions for different carriers. Supported technologies include:

  • LTE
  • LTE (LTE+) with Carrier Aggregation technology
  • LTE (5Ge) Advanced Professional edition
  • NR (5G)
  • NR (5G+) in millimeter Wave Mobile Network Frequency Band

More apis and features

Android 11 also provides more apis and features that can be referenced to point me to see the world

The last

First feel Google team share! This article is a summary of Android 11 knowledge by referring to the official documents and browsing Android 11 Labs online activity video. It may not be comprehensive enough, but please give us more advice. For more content, please check the Android Developer platform.

The most recent Beta of Android 11 was scheduled for June 3rd, but it was delayed due to protests and other events in the US. It may be a little bit later this year, but justice will come!! !

Wish world peace!!