Google is working hard on Android 13, as it recently released Developer Preview 2 for the operating system. With the current schedule still going, we can expect to see the first beta release sometime in April, followed by a few more betas and potentially a full release in August, September or October. Google does not commit to any launch window. Shortly after DP2 was dropped, some interesting changes were documented within a developer resource titled “Battery Resource Utilization”.
It bypasses some new rules and limitations regarding the “restricted” app standby bucket state an app can end up in, but what’s even more interesting is that it details a new notification of excessive battery usage in the background. Exactly for the same document:
Android 13 offers a system notification that appears when your app consumes too much device battery in a 24 hour period. This new notification appears for all apps on devices running Android 13, regardless of the target SDK version.
When measuring your app’s impact on a device’s battery life, the system takes into account the work your app does in several different places, including the following:
- Provided services, even those with visual notifications
- Work tasks, including expedited work
- broadcast receivers
- Background services
- Your app cache
If this notification appears for your app, it will not appear again on the same device until at least 24 hours have passed.
If the system detects that your application is running a foreground service for an extended period of time – at least 20 hours in a 24 hour period – it sends a notification to the user, inviting them to interact with the foreground services task manager (FGS).
Note: If the system shows this notification to your app, it will not show a similar notification again until at least 30 days later.
All of this can get a little technical, but the simplified explanation is that Android 13 is now monitoring more and more diverse aspects of the app’s background behavior. Not only this but also some of its front-end elements, such as foreground services. These are services that perform operations that should be noticeable to the user and have a notice attached to them that cannot be refused until the service is discontinued or removed from the offering. Examples of such behavior include things like fitness tracking apps because they are “in exercise” and actively collecting data, or a multimedia player that plays with a foreground service and may display things like the current song and multimedia controls in a notification.
As you can imagine, there are many legitimate apps that might have such behavior without the need for a battery warning alert. Android 13 has more than a few exceptions to tracking. Both of our examples above are actually covered because the notification doesn’t appear for foreground services of type FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK or FOREGROUND_SERVICE_TYPE_LOCATION. Furthermore, the following situations exclude apps from all battery conservation measures introduced in Android 13:
- System apps and system-related apps
- Companion device apps
- Apps running on a device in beta mode
- Device owner apps
- Profile owner apps
- Continuous applications
- VPN apps
- Applications with ROLE_DIALER
- Applications that the user has explicitly set to provide “unrestricted” functionality in the system settings
Of course, some third-party ROMs and other apps and managers offer similar features for background battery monitoring, but not with the same level of depth. You may also remember that since Android 8 Oreo, Google has already made a similar push, resulting in background battery drain warnings. The monitoring logic for these, though, is more primitive and the notifications themselves can be more obnoxious with no clever limitations, such as only showing one notification every 24 hours.
Provided the new Battery Monitor passes all beta testing and ends up doing well, we can look forward to it making its appearance in practically any future Android 13 smartphone since it’s part of the core of Google’s AOSP. We hope all of our battery packs will benefit from this move in the long run.
source | Across