减少通过智能手机收音机下载内容的应用程序对电池的影响 [英] Reducing the battery impact of apps that downloads content over a smartphone radio

查看:16
本文介绍了减少通过智能手机收音机下载内容的应用程序对电池的影响的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我正在构建一个定期从服务器下载数据并间歇性上传数据(分析、广告等)的智能手机应用,我可以做些什么来最大限度地减少这些传输对电池寿命的影响?

If I'm building a smartphone app that regularly downloads data from a server, and also intermittently uploads data (analytics, ads, etc.) what can I do to minimize the battery life impact of those transfers?

使用无线电(2G、3G、LTE 等)进行传输对电池的影响尤为显着.是否有任何关于无线电的功耗配置文件会影响我选择传输数据的时间、内容和方式,以尽量减少其对电池寿命的影响?

The battery impact of transfers using the wireless radio (2G, 3G, LTE, etc.) is particularly significant. Is there anything about the power-use profile of the wireless radio that should affect my choices of when, what, and how to transfer data in order to minimize its impact on battery life?

推荐答案

这个答案是从 The Android Training 课程中总结出来的,传输数据而不消耗电池解释如何最大限度地减少下载对电池寿命的影响和网络连接,特别是与无线电.

This answer is summarized from The Android Training class, Transferring Data Without Draining the Battery which explains how to minimize the battery life impact of downloads and network connections, particularly in relation to the wireless radio.

特别是优化下载以实现高效的网络访问详细解释无线电状态机并继续解释您的应用程序的连接模型应如何与其交互以尽量减少相关的电池消耗.

In particular Optimizing Downloads for Efficient Network Access explains the wireless radio state machine in some detail and goes on to explain how your app's connectivity model should interact with it to minimize the related battery drain.

无线电状态机

参考

每次创建新的网络连接时,无线电都会转换到全功率状态.此转换通常需要大约 2 秒,因此为了最大限度地减少延迟,无线电会引入延迟以推迟转换到较低能量状态.

Every time you create a new network connection the radio will transition to the full power state. This transition typically takes around 2 seconds, so to minimize latency, the radio introduces a delay to postpone the transition to lower energy states.

传输完成后,典型的 3G 无线电将保持全功率 5 秒,然后在低能量状态下再等待 12 秒,然后再进入待机状态.每次建立连接时,无线电总共会消耗近 20 秒的电量.

A typical 3G radio will remain at full power for 5 seconds after your transfer is complete, before waiting a further 12 seconds at the low energy state before moving to standby. In total the radio will draw power for nearly 20 seconds every time you make a connection.

这种方法可能导致在现代智能手机操作系统上运行的应用效率低下,应用在前台(延迟很重要)和后台(应优先考虑电池寿命)运行.

This approach can lead to inefficiencies for apps running on modern smartphone OSs, where apps run both in the foreground (where latency is important) and in the background (where battery life should be prioritized).

解决方案

最大限度地减少下载对电池影响的关键是认识到传输频率的影响比下载大小的影响更大.实际上,预取和排队/捆绑传输特别有效.

The key to minimizing the effect of downloads on your battery is recognizing that the frequency of transfers has a more dramatic impact than the size of the downloads. In practical terms prefetching and and queuing / bundling your transfers are particularly effective.

知道每次启动连接时都可能导致无线电耗电近 20 秒,因此捆绑数据传输非常重要,这样您就可以有效地将在相似时间内发生的相移传输窗口,以便您在每次传输会话期间传输尽可能多的数据,以最大限度地减少会话数量.

Knowing that every time you initiate a connection you potentially cause the radio to draw power for nearly 20 seconds, it's important to bundle your data transfers so that you're effectively phase-shift transfers that are due to occur within a similar time window so that you're transferring as much data as possible during each transfer session to minimize the number of sessions.

同样,预取允许您在单个突发中、通过单个连接、满负荷下载在给定时间段内可能需要的所有数据.通过预先加载传输,您可以减少下载数据所需的无线电激活次数、延长电池寿命、改善延迟、降低带宽并减少下载时间.

Similarly, prefetching allows you to download all the data you are likely to need for a given time period in a single burst, over a single connection, at full capacity. By front loading your transfers, you reduce the number of radio activations required to download the data, conserving battery life, improving latency, lowering bandwidth, and reducing download times.

但是,通过下载未使用的数据,预取也会带来增加电池消耗和带宽使用的风险.

However, prefetching also introduces the risk of increasing battery drain and bandwidth use by downloading data that isn't used.

预取的积极程度取决于正在下载的数据的大小及其被使用的可能性.一般来说,预取数据是一种很好的做法,这样您只需每 2 到 5 分钟启动一次下载,大约为 1 到 5 兆字节.

How aggressively you prefetch depends on the size of the data being downloaded and the likelihood of it being used. Generally speaking, it's good practice to prefetch data such that you will only need to initiate another download every 2 to 5 minutes, and in the order of 1 to 5 megabytes.

重用现有网络连接通常也比创建新网络更有效.重用连接还允许网络更智能地应对拥塞和相关网络数据问题.

It's also generally more efficient to reuse existing network connections rather than creating new ones. Reusing connections also allows the network to more intelligently react to congestion and related network data issues.

这篇关于减少通过智能手机收音机下载内容的应用程序对电池的影响的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆