Android M -- Power-Saving Optimizations

来源:互联网 发布:mac口红see sheer试色 编辑:程序博客网 时间:2024/05/13 16:57

本人英文较差,翻译水平有限,请多加指正,谢谢。


Power-Saving Optimizations

Android M Preview helps prolong battery life by introducingnew power-saving optimizations: Doze mode improves the sleep efficiency ofidle devices. AppStandby prevents apps from eating up powerwhile idle.

Android M 预览版本 通过引入新的节电优化方式来延长电池寿命:采用doze模式提高闲置设备的睡眠效率。当设备处于idle状态时,使应用程序待机,避免应用程序耗光电量。

Doze


If a user leaves a device unplugged and stationary for a period of time, with the screen off, the device enters Doze mode. Doze attempts to keep the system in a sleep state as long as the device remains undisturbed. In this mode, devices periodically resume normal operations for brief periods of time so that the system can perform app syncing and any other pending operations.

如果用户将设备拔掉电源,灭屏状态下静止一段时间,设备就会进入Doze模式。只要设备保持原状,Doze模式将保持系统处于睡眠状态。在这种模式下,设备将周期性地恢复短暂的正常操作,以至系统可以执行应用程序的同步和其他挂起的操作。

The following restrictions apply to your apps while in Doze:

下面的一些限制适用于处于doze状态的应用程序:

·        Network access is disabled, unless your app receives a high-priority Google Cloud Messaging tickle.

·        The system ignores Wake locks.

·        Alarms scheduled using the AlarmManager class aredeferred, unless you have exempted them using thesetAndAllowWhileIdle() method.

·        The system does not perform Wi-Fi scans.

·        The system does not permit syncs or jobs for your sync adapters.

·        The system does not allow JobScheduler to run.

When thedevice exits Doze mode, it executes any jobs and syncs that are pending.

网络访问被禁止,除非你的应用程序收到一个高优先级的Google Cloud Messaging。

该系统会忽略唤醒锁。

使用AlarmManager类预定的警报将被推迟,除非你使用setAndAllowWhileIdle()方法免除了它们。

系统不会执行WiFi扫描。

系统不允许你的同步适配器执行同步或工作。

系统不允许JobScheduler执行。

当设备退出doze模式时,执行任何挂起的作业和同步。

Testing apps withDoze

You cantest Doze mode by connecting your development host to a device running the MPreview, and calling the following commands:

你可以将运行M Preview版本的设备连接到主机,运行下面的命令,来测试Doze模式。

$ adb shell dumpsys battery unplug$ adb shell dumpsys deviceidle step$ adb shell dumpsys deviceidle -h

Note: As of M Preview 3 release, Google CloudMessaging (GCM) letsyou designate high-priority messages. If your app receives ahigh-priority GCM message, the system grants brief network access even when thedevice is dozing.

自Android M的第三个预览版本发布,谷歌云消息允许你指定高优先级的消息。如果应用程序收到了高优先级的GCM消息,即使设备处于dozing状态,系统也会允许短暂的网络访问。

See the Testing Guide for tips on how to test Doze in yourapps.

App Standby


App Standby allows the system to determine that an app is idle when the user is notactively using it. The system makes this determination when the user does nottouch the app for a certain period of time, and none of the followingconditions applies:

当用户不频繁地使用某个应用程序时,应用程序待机允许系统决定它处于idle状态。当用户在一定时间内没有点击这个应用时,系统才有此决定。满足下面任何一点都不能执行此机制。

·        The user explicitly launches the app.

·        The app has a process currently in theforeground (either as an activity or foreground service, or in use by anotheractivity or foreground service).

·        The app generates a notification that userssee on the lock screen or in the notification tray.

·        The user explicitly asks for the app to beexempt from optimizations, via the Settings app.

用户明确地启动了应用程序。

应用程序当前在前台有一个进程在执行。

应用程序在锁屏界面或通知托盘中生成一个通知。

用户通过设置程序,明确要求应用程序免除此优化。

When theuser plugs the device into a power supply, the system releases apps from thestandby state, allowing them to freely access the network and to execute anypending jobs and syncs. If the device is idle for long periods of time, thesystem allows idle apps network access around once a day.

当设备接入电源时,系统释放待机状态的应用程序,允许他们自由地访问网络,执行任何挂起的作业和同步。如果设备长期处于idle状态,系统允许idle状态的apps每天访问一次网络。

Testing apps withApp Standby

You cantest App Standby by connecting your development host to a device running the MPreview, and calling the following commands:

$ adb shell dumpsys battery unplug$ adb shell am set-inactive <packageName> true$ adb shell am set-inactive <packageName> false$ adb shell am get-inactive <packageName>

Note: As of M Preview 3 release, Google CloudMessaging (GCM) letsyou designate high-priority messages. If your app receiveshigh-priority GCM messages, the system grants brief network access even whenthe app is idle.

See the Testing Guide for tips on how to test App Standby inyour apps.

 

 

1 0
原创粉丝点击