Android 11 application adaptation

Major changes on Android 11

1.1 Compatibility

1.1.1 Partition storage

Description: The partitioned storage mechanism allows the application to have a dedicated storage area of ​​its own in the external storage space. This area is private. Therefore, this area is very suitable for storing users' private data. Of course, applications cannot access the dedicated storage areas of other applications. But if an application needs to make specific files in its own dedicated storage area accessible to other applications, it can mark these files as shareable by setting the file sharing method. Partition storage will play a very good role in file management, application protection, and user privacy data protection.

Sphere of influence:

1) Applications whose targetSdkVersion is 30.

2) The targetSdkVersion is 29, and requestLegacyExternalStorage is not set to true to disable partition storage applications.

Adaptation suggestions:

If your application still uses the old storage mechanism, you now need to migrate the data to a directory compatible with partitioned storage.

Where to access the file

Required permissions

Access method

Application private directory

Access without permission

getExternalFilesDir ()

Private directories for other applications

None, but the target file needs to be marked as shareable by its application using FileProvider

Obtained through ParcelFileDescriptor and FileDescriptor

Media file directory (audio, photo, video file)

READ_EXTERNAL_STORAGE (only needed when accessing files of other applications)

MediaStore API

Download catalog (document files, etc.)

Access without permission

Storage Access Framework SAF

Detailed introduction of partition storage: https://developer.android.google.cn/preview/privacy/storage

1.1.2 Single authorization

Description: The Android 11 developer preview version divides permissions in a more granular manner and introduces the concept of "single authorization". The user can perform a single authorization to allow the application to gain temporary access to the user's location, camera or microphone, as shown in the figure below. After obtaining this authorization, the application can obtain access to the corresponding data within the following time periods:

1) When the application's Activity is visible.

2) A short period of time after the application turns to the background.

3) A foreground service is started when the Activity is visible, and then the application is transferred to the background, then the application can continue to access related data until the foreground service stops.

Scope of influence: All applications running on Android 11.

Adaptation advice: If your app has followed the best practices related to permissions (https://developer.android.google.com/privacy/best-practices), you can support single authorization without changing the app.

image.png

Figure: The permission request window in the app provides one-time permission options

1.1.3 How to obtain background location information access authority

Note: When an application applies for background location information access permissions, the pop-up window that allows users to grant permissions will no longer provide the option of "Always Allow". This option only exists on the application permission grant page in the settings, which can reduce it to a certain extent The "back door" situation of the application occurs, as shown in the following figure, and the application for the background location permission requires the application to have the foreground location permission.

Affected area: all applications running on the Android 11 developer preview version

Adaptation suggestion: If your application determines that it needs to obtain the background location information access permission, now it needs to be divided into two steps, because it is no longer possible to directly apply for the background location information access permission without the foreground location information access permission.

1) First apply for the front desk location information access permission

2) Then apply for background location information access permission, which is the so-called "always allowed", and the user will be guided to the settings to grant

image.png

Figure: When applying for background location information access permission, the permission request popup in the app no ​​longer contains "Always Allow"

image.png

Figure: Granting of background location information access permissions can only be done in the settings

1.1.4 Package visibility

Description: The Android 11 developer preview version changes the way that apps query other installed apps on the same device and how they interact with them.

Affected range: applications whose targetSdkVersion is 30

Adaptation suggestion: The application needs to add the <queries> element to the application manifest file so that the system knows which other installed applications should be shown to it. If your app performs common interactions with other apps, then you don’t need to change the app. For more information about the visibility of Android 11 developer preview packages, please refer to

https://developer.android.google.cn/preview/privacy/package-visibility。

1.1.5 New foreground service types

Description: Android 11 changes the way the foreground service accesses camera and microphone related data to further protect user privacy.

Affected range: applications whose targetSdkVersion is 30

Adaptation suggestion: You need to add new camera and microphone types in the foregroundServiceType attribute of the foreground service declaration, otherwise the camera and microphone data will not be obtained.

1.1.6 The use of custom view message box is restricted

Note: The custom view message box published from the background will be blocked by the system. This type of message box uses setView() to define a layout for itself, as shown in the figure. For security and user experience considerations, the system blocks custom view message boxes initiated from the background. But the custom view message box published from the foreground can still take effect normally, and the text message box created with Toast.makeText() is not affected, and it can take effect normally when published in the foreground and background.

Affected range: applications whose targetSdkVersion is 30

Adaptation suggestion: It is recommended to use the information prompt control (Snackbar) instead.

image.png

Figure: Example of a custom view message box published from the background on Android Q

1.1.7 Update of non-SDK interface list

Note: Android 11 has a large number of updates to the list of non-SDK interfaces. For the update of the list of interfaces, please check https://developer.android.google.cn/preview/non-sdk-11. These changes may bring different degrees of compatibility issues to some applications that rely on non-SDK interfaces, especially applications that rely on the Android Q graylist interface, because some of these interfaces have been included in the blacklist in Android 11. .

Scope of influence: All applications running on Android 11.

Adaptation suggestion: If your application relies on the restricted interface of Android 11, you should start planning to upgrade the SDK and migrate to an SDK alternative.

 

1.2 New interactive experience and methods

Every time the Android system is upgraded, it will almost bring some new changes in the interactive experience, and this time Android 11 is no exception.

E.g:

1.2.1 Chat bubble

The conversation method of chat bubbles is officially launched and is no longer an experimental feature. This feature allows the conversation window to be minimized to one or more floating bubbles, and the bubbles can be expanded into small window mode pages;

image.png

Figure: Message notification in bubble form

image.png

Figure: The bubble expands into a small session window

1.2.2 New input method keyboard transition animation

With the help of two new API interfaces-Insets Animation Listener and WindowInsets Animation Controller, Android 11 brings a new transition to the input method keyboard that we have to deal with every day Animation, these APIs allow you to more easily adjust the content of the application, keeping in sync with the appearance and disappearance of the IME and other elements such as the status and navigation bar. This is a sample provided by Google https://github.com/android/user-interface-samples/tree/master/WindowInsetsAnimation. Compared with the animation that pops up directly from the bottom in the current mainstream version, the new input method keyboard animation can change frame by frame following the actual movement of our fingers, presenting smoother and more natural sliding in and out effects, and so on.

 

1.3 New support at the hardware level

1.3.1 Android 11 will better support various mobile phone screens to improve user experience

● Waterfall screen: The "waterfall" area of ​​the waterfall screen will cause the edge content to display distortion and accidental touch. On Android 11, developers can already control the interaction of the "waterfall" area. The existing DisplayCutout.getSafeInset...() method will now return a safe border area that can avoid the waterfall area and bangs.

● High refreshing screen: Android 11 has added a new API-Surface.setFrameRate() to allow apps to set their preferred refresh rate, so as to take advantage of the high refreshing screen and get a better user experience, while also helping the system to run Intelligent switching during application solves the power consumption problem that may be caused by high refresh rate from the system level.

1.3.2 Android 11 supports concurrent use of multiple cameras

Developers can use the new API to query the support for using multiple cameras at the same time (including the front camera and the rear camera). If you need to check the support status on the device running the application, you can use the following two methods. The getConcurrentCameraIds() method can return the combination of camera IDs, and isConcurrentSessionConfigurationSupported() can query whether the camera device can concurrently support the corresponding session configuration.

 

1.4 Enhanced 5G support

Android 11 brings "dynamic metering" and "bandwidth estimation" for 5G, to better utilize the high bandwidth and low latency characteristics of 5G. Flexible for different scenarios and different network conditions, adaptive streaming media quality.

 

1.5 Other functions

1.5.1 ADB incremental APK installation

It may take a long time to install a large APK on the device. ADB incremental APK installation can install enough APKs to start the application while streaming the remaining data in the background, thus speeding up the process. If the device supports this function and you have installed the latest SDK platform tools, the adb install command will automatically use this function. Or run this command adb install –incremental to use this feature. Before running ADB incremental APK installation, you must first sign the APK and create an APK signature scheme v4 file. And the v4 signature file must be placed next to the APK to make this function work properly.

1.5.2 Application process exit reason

Android 11 introduced the ActivityManager.getHistoricalProcessExitReasons() method to report the reason for any process termination recently. Applications can use this method to collect crash diagnostic information, such as process termination due to ANR, memory problems, or other reasons. In addition, you can also use the new setProcessStateSummary() method to store custom state information for later analysis.

1.5.3 Dynamic Resource Loader

Android 11 introduces two new API classes, ResourcesLoader and ResourcesProvider, to support the search and loading methods of dynamically expanding resources. One of the main use cases is to allow applications to access resources in specific directories outside the APK.

Reference link

 The storage mechanism update in Android 11: https://developer.android.google.cn/preview/privacy/storage

Follow best practices regarding permissions: https://developer.android.google.com/privacy/best-practices

 Package visibility in Android 11: https://developer.android.google.cn/preview/privacy/package-visibility

 Update of the message box in Android 11: g.co/dev/toast

 List of non-SDK interfaces updated: https://developer.android.google.cn/preview/non-sdk-11

 New input method keyboard transition animation example: https://github.com/android/user-interface-samples/tree/master/WindowInsetsAnimation

 Significant privacy changes in Android 11: https://developer.android.google.cn/preview/privacy

Overview of the new features and APIs of Android 11: https://developer.android.google.cn/preview/features

Guess you like

Origin blog.csdn.net/weixin_40611659/article/details/108747906