Android Q features and APIs

Tram Ho

Android Q has a beta version and is introduced with lots of interesting features for both users and developers. In this article, I will focus on new points for developers.

Enhanced security

Android Q introduces some security features summarized as follows:

Improve the biometric authentication dialog

Specify user authentication request

From now on, you can provide a hint to the system that does not require user authentication after being authenticated by a hidden biometric method. For example, requires no further authentication after the user has authenticated with face recognition.

By default, the system will typically require the user to authenticate with the actions sensitive or high-risk (eg purchase on the store). However, if you have some low-risk actions for candidates, you can provide suggestions for users not requesting authentication by passing false to the setConfirmationRequired method ( because this variable is transmitted as a hint. system, the system can ignore the value if the user changes their system settings for biometric authentication.

Face authentication without user authentication

Face authentication requires authentication of users

Improved backup support for device login information

You can now ask the system to allow users to authenticate with the device’s PIN, pattern or password if they cannot authenticate using biometric inputs for a number of reasons. To enable support this reserve, use the method setDeviceCredentialALLowed () .

If your application is currently using createdConfirmDeviceCredentialIntent () to return to your device’s login, switch to using a new alternative method.

Check equipment for biometric capabilities

Now you can check whether a device supports biometric authentication before calling the BiometricPrompt using the canAuthenticate () method in the BiometricManager class.

Run DEX code embedded directly from APK

You can now ask the platform to run the DEX code embedded directly from the application’s APK file. This option can help prevent an attack if the attacker tried to fake compiled code locally on the device.

To enable this feature, set the android: useEmbeddedDex attribute value to true in the <application> tag of your application manifest. You must also build an APK containing uncompressed DEX code that ART can access directly. Add the following options in the config file or Bazel Gradle to build an APK with uncompressed code DEX:

Gradle

Bazel

Connectivity features

Android Q includes a number of network and connectivity-related improvements.

Wi-Fi Network Connection API

Android Q adds support for peer-to-peer connections. This feature allows your application to prompt users to change the access point that the device is connected using the WifiNetworkSpecifier to describe the properties of the requested network. Peer connections are used for non-network purposes, such as configuring bootstrapping for secondary devices such as Chromecast hardware and Google Home.

Stream using the API:

  1. Create Wi-Fi network identifier using the WifiNetworkSpecifier.Builder .
  2. Set the network filter to match the networks to connect with the required login information.
  3. Decide to combine the SSID , SSID form, BSSID and BSSID templates to set the network filter in each request, following the following requirements:
    • Each request must provide at least one form of SSID, SSID, BSSID or BSSID
    • Each request can only set one SSID or SSID form
    • Each request can only place one BSSID or BSSID form
  4. Add the specified sets to the network request with the NetworkCallback version to monitor the status of the request.

If the user accepts the request and successfully connecting to the network, NetworkCallback.onAvailable () is called on the callback object. If users reject the request or if the network connection fails, NetworkCallback.onAvailable () is called on the callback object.

Bypassing user approval

When the user approves a network to connect to meeting the requirements of an application, the device will save approved for a specific access point. If the application makes a specific request to reconnect that access point, the device will skip the user approval phase and automatically connect to the network. If the user chooses to forget the network while being connected to the network requested by the API, then this cached approval for the combination of the application and the network will be deleted and any future requests from the application will users need to be re-approved. If the application making the request is not specific (such as the SSID or BSSID form), then the user will need to approve the request.

sample code

Wi-Fi network API suggestion

Q Android adds support for the application to add information to the network device to automatically connect to Wi-Fi access point. You can provide suggestions for how to connect network using WifiNetworkSuggestion . The last platform select the access point to accept based on input from your application and others.

The following code will show us how to provide login information for an open network, a WPA2 and a network WPA3:

Suggestions from the application must be approved by the user before starting to connect with them. This approval is provided by the user in response to a notification that first finds a network that matches one of the application suggestions in the scan results. When connected to one of the proposed network, installation will display the text attribute with application networking Suggest respectively.

Control user disconnects

If the user uses Wi-Fi chooser to disconnect from one of the network suggestions, the network will be listed in the blacklist for 24 hours. During a backlist, the network will not be considered to automatically connect, even if the application deletes and re-adds the network proposal corresponding to the network.

Change the approval status for applications

A user who refuses to announce a network proposal will remove the CHANGE_WIFI_STATE permission from the application. Users can grant this approval later by going to the Wi-Fi control menu (Settings> Applications & notifications> Access special application> Wi-Fi control> Application name).

Above I have introduced some new developer functions on this new beta version of Android Q. I will introduce new functions in the following article. Thank you for reading your lesson ?

Share the news now

Source : Viblo