⬆️ ⬇️

Android O: features support for the new operating system

Hello! An important event will take place very soon - the release of Android O. Support for new versions of the operating system is the responsibility of any serious product. Each update of Android forces many developers to work seriously to preserve the functionality of existing functions and bring new ones thanks to the capabilities of new versions of Android.



In this article we will look at the main changes of Android O and evaluate their possible impact.



image



image



Working on Android O, Google developers first of all solved the problem of fast battery charge on Android devices, so the main changes are related to the optimization of background tasks and the use of application resources.



Changes in Android O can be divided into two categories:



  1. Potentially "breaking" the current performance and requiring additional efforts to support;



    ThreatTarget> = OTarget <oEffect
    Background Location LimitsAffectedAffectedRestriction on geolocation query
    Background Execution LimitsAffectedOkChanging the list of available broadcasts in the manifest;

    Changing the time of the services in the background.
    Notification ChannelsAffectedOkImprovements for notification channels
    WindowmanagerAffectedOkEffect on overlapping windows
    Privacy (Build.Serial / net.dns / etc)AffectedAffectedChanging the availability of user IDs
    AccountManager.

    getAccounts ()
    AffectedOkA request for a list of accounts on the device returns null


  2. Opportunities to implement new features.

    New opportunitiesApplication
    Android EnterpriseImproving device control
    Autofill FrameworkAutocomplete entry fields
    Notification ChannelsUX enhancement
    Picture in PictureUX enhancement
    Adaptive IconVendor firmware consistency
    Accessibility button and fingerprint gesturesImproving UX (accessibility button in the navigation bar, trapping gestures on the fingerprint scanner)
    Webview Apis (eg Safebrowsing)Improved Webview built-in capabilities
    Pinning shortcuts and WidgetsSoftware creation of shortcuts and widgets in the launcher


In our opinion, these are the most significant (at least for Kaspersky Lab) changes in Android O. Consider each separately.



Background Location Limits



This is a limit on the number of location requests for applications in the background. So, starting with Android O and regardless of the TargetSDK installed, applications can receive only a few location updates per hour. However, these restrictions do not apply to applications for which at least one of the following parameters is valid:





Thus, for Foreground applications, the behavior will be the same as in previous versions of Android.



If the foreground service is absent, then the geolocation request will be changed:





Background execution limits



The restriction on the background operation of the application is a key change of Android O, which will be noticeable to a large extent only when switching to targetSdk “O”. If targetSdk <= 25, then if the application is in the background and has been transferred by the system to the Cached state (when the system is free to kill the process at any time), and it does not have active components, the system will release all WakeLock ( that the application should not be able to sleep) of this application. It is important to note that if the application is not targetSDK <O, then in the settings you can set the behavior policy the same as if the application were with targetSDK O.



For applications with targetSdk, the “O” background execution limits consist of two categories:



  1. Limit Background Services

    After the application has moved to the background, it has a “window” in a few minutes, during which services can start and work. After the expiration of this interval, all services are stopped, and the launch of new ones will cause the application to crash. Google tries to minimize the number of running background services and suggests using JobScheduler and GcmNetworkManager.

    If you need to perform lengthy tasks in the background, it is recommended to use foregroundService, which will explicitly tell the user that the application is running.

    It is worth noting that after you call startForeground() , you must call startForeground() within 5 seconds, otherwise the system may show ANR.
  2. Registration restrictions for broadcasts in the manifest

    The new version of Android continues the work begun by Android 7.0 (probably everyone remembers the applications that were re-elevated with each change of the mobile station). But if in the 7th version in the manifesto it was impossible to register only a few Broadcast, now there are a majority of such Broadcasts.


Notification Channels



Notification Channels is a tool for grouping notifications into subject groups that a user can manage directly. If the application is built with target> = O, then at least one of the notification channels must be supported. In case targetApi <O, then the work with notifications inside the product will remain the same.



Windowmanager



Android O introduces a new type of windows (for targetSDK O) that can be displayed on top of other windows - TYPE_APPLICATION_OVERLAY. In this case, several old types of windows have become deprecated , and now when they are used, a RuntimeException is generated.

These types of windows can now be used only by system applications:





Privacy (Build.Serial / net.dns / etc)



In Android O, there are some improvements designed to help the user manage access to their ids. These improvements include:





AccountManager.getAccounts ()



Starting with Android O, the GET_ACCOUNTS permission is not enough to access the list of accounts. Now there are two options for applications with targetSDK O:





Android Enterprise



Google is actively developing Android for Work. In Android O, they provided more options for controlling the device. For example, for a working profile, you can get a separate lock with your own settings, find out information about available system updates.



Autofill Framework



With the advent of the Autofill Framework API, it has become possible to more conveniently fill user data into applications than when using Accessability. When you call the framework, you will need to match the packageName of the product for which the call to autocomplete occurred, and then provide the input data. To correctly identify the login and password fields, you need to create and maintain a database with resourceId controls or other service information that allows you to correctly identify UI elements for autofilling.



Picture in Picture



Android O allows you to run activity in Picture-In-Picture, which is a special type of multi-window mode. Google recommends using this mode exclusively for video display applications.



Adaptive Icon



Starting with Android O, you can provide another version of Launcher Icon for the application, which the system can easily cut to a form that is used by the device manufacturer. Also, if there is such an icon, the system will be able to do some animation of application icons.



Pinning shortcuts and Widgets



New feature Android O - software creating shortcuts and widgets in the launcher. The label is a separate icon that allows you to perform a task in the application for a given intent. Successful attachment of a widget or shortcut requires user consent in the system confirmation dialog.



Conclusion



The time when Android allowed you to do whatever you want is a thing of the past. Android expands the "legal" tools to create new functions, closes gaps for hacks and makes you work honestly. Android O breaks a part of existing applications, but tries to make the end users happier. Cheers thanks!

I wish everyone to write good apps, think about users and be happy owners of Android devices.



PS

The author of the article is Alexander Shindin ayushindin .

Sasha wrote an article and boldly fell ill, so he trusted me to put the article on Habr to me =)

We wish him a speedy recovery!



')

Source: https://habr.com/ru/post/334652/



All Articles