Symbian 中的电源管理

发布于 2024-09-16 13:25:14 字数 299 浏览 2 评论 0原文

在 Symbian 中是否有编写节能后台应用程序的“最佳实践”?

具体来说,Symbian 应用程序是否有任何方法(即 API)向操作系统提示其当前状态,以减少电池消耗? 例如,在 Android 中,有唤醒锁的概念,它可以防止设备进入待机模式 - Symbian 中有类似的东西吗?

编辑:
当使用 Open-C 库作为单独的线程而不是作为“本机”Symbian C++、使用活动对象等运行代码时,是否有任何影响? (Open-C 代码大部分时间都在 IO 上阻塞)。

Are there any "best practices" for writing a power-efficient background application in Symbian?

Specifically, is there any way (i.e. API) for a Symbian app to hint the OS regarding its current state in order to reduce battery consumption?
In Android, for instance, there is the notion of Wake Locks, which prevents the device from going into standby mode - Is there anything similar in Symbian?

EDIT:
Are there any implications when running code as a separate thread with the Open-C library, and not as "native" Symbian C++, using Active Objects etc.? (the Open-C code is blocking on IO most of the time).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

聚集的泪 2024-09-23 13:25:14
  1. 您可以使用 RTimer::Inactivity() 方法检查用户(in-)活动。 论坛诺基亚 Wiki 页面中描述了这种方式。其中还描述了如何重置不活动计时器。
  2. 您可以使用 HAL API 检查设备屏幕是否打开或关闭。请参阅 HAL 和 HALData 类。您可以使用这样的调用:


Tint 显示状态;
HAL::Get(HALData::EDisplayState, displayState);

如果显示关闭,则 displayState 将保持为 0,否则将保持为 1。

通过这些 API,您将了解用户现在是否处于活动状态,因此您将能够更改后台服务的行为以降低其功耗。

您还可以使用 Nokia Energy Profiler 应用程序可记录手机的功耗,并为您的后台服务提供不同的省电选项。另请参阅诺基亚的 文档描述了节省设备电量的最佳实践。该文档非常简单,但仍然很有用。

希望这有帮助。

编辑:关于单独的线程和Open C。据我所知,Open C只是一个插件,并且在深处所有实现仍然是“本机Symbian”。因此,只要您避免定期轮询某些资源并仅使用常用的阻塞 IO,您的代码在功耗方面与标准 Symbian 活动对象技术(使用 Symbian 特定信号量来阻塞线程)相当经济。

  1. You can check user (in-)activity with a RTimer::Inactivity() method. This way is described in Forum Nokia Wiki page. There it's also described how you can reset inactivity timer.
  2. You can check whether device screen is turned on or off using HAL API. See classes HAL and HALData. You may use such a call:


TInt displayState;
HAL::Get(HALData::EDisplayState, displayState);

And the displayState will hold either 0 if display is turned off or 1 in other case.

With these APIs you will know whether user is active now, so you'll be able to change behavior of your background service to reduce its power consumption.

You can also use Nokia Energy Profiler application to record power consumption of handset, with different power saving options of your background service. Also please refer to Nokia's document describing best practices to save power of device. This document is quite straightforward, but useful nonetheless.

Hope this helps.

EDIT: About separate thread and Open C. As far as I know, Open C is just a plugin and deep down all the implementations are still "native Symbian". So, as far as you avoid periodic polling of some resource and just use usual blocking IO, your code is quite same economical on power as standard Symbian Active Objects techniques (which use Symbian-specific semaphores to block threads).

红墙和绿瓦 2024-09-23 13:25:14

我在 Symbain 中没有发现任何特殊的东西可以使设备脱离待机模式。基本上,“最佳实践”与所有移动设备相同:

  • 不要循环等待,始终使用平台上可用的任何信令服务,例如 Symbain ActiveObjects / User::WaitForXxx
  • 限制后台线程的数量(目前所有移动设备仍然只有 1 个 CPU...)
  • 不要挂在系统服务上,尽快关闭它们(这通常是我的移动应用程序中的主要电池消耗,有时试图找出哪个系统服务导致电池消耗最多可能是一个真的很痛苦,WinMo对此非常糟糕)。

对我来说,我发现这主要取决于应用程序的电池寿命和性能/响应能力之间的权衡。不幸的是,电源似乎总是与性能/响应能力一边,而且该死的电池消耗......

I have not come across anything special in Symbain to keep the device out of stand-by mode. Basically the "best practices" would be the same as all mobile devices:

  • Don't loop waiting for things, always use whatever signaling services avaialble on the platform, for Symbain ActiveObjects / User::WaitForXxx
  • Limit the number of background threads (currently all mobile devices are still only 1 CPU...)
  • Don't hang onto system services, close them ASAP (this is normally my main battery drain in my mobile applications, sometimes trying to find which system service causes the most battery drain can be a real pain, WinMo is very bad for this).

For me, I find that it mostly comes down to a tradeoff between battery life and performance / responsiveness for the application. Unfortunately power that be always seem to side with the performance / responsiveness side and damn the battery drain.....

上课铃就是安魂曲 2024-09-23 13:25:14

为您的应用程序设置低优先级(请参阅 RProcess 和 RThread 类)。您的方法实际上取决于您的后台应用程序的功能。这些东西消耗最多的电池:无线电(GSM/3G/WIFI/蓝牙)、屏幕背光、文件访问。

Symbian 操作系统将始终尝试让您的应用程序进入睡眠状态,您不需要告诉它这样做。只要确保你的方法能让它有机会让它进入睡眠状态即可。

Give your application low priority (see RProcess and RThread classes). Your approach will really depend on what your background application does. These things consume most battery: radio (GSM/3G/WIFI/BlueTooth), screen backlight, file accesses.

Symbian OS will always try to put your application to sleep, you don't need to tell it to do this. Just make sure your approach gives it the opportunity to put it to sleep.

ゝ杯具 2024-09-23 13:25:14

电源管理是开发应用程序时非常重要的问题。

在 Symbian 中,这取决于您用来运行后台活动的内容。

无论您使用的是Thread还是ActiveX控件。

对于例如。您正在开发应用程序浏览器,您希望浏览器下载某些内容,然后下载活动应该在后台进行,并且能够启动活动,何时显示进度以及何时完成,它应该再次到达前端。

如果您使用线程,这取决于您如何管理线程。您可以像在长时间活动开始时暂停哪个线程以及在后台活动完成执行时何时恢复一样。

事实上,这是您遇到的非常好的主题

Power management is an very most important issue while developing application.

In Symbian it depends on what you are using to run background activities .

Whether you are using Thread or ActiveX control.

For Eg. you are developing application browser that you want the browser to download something then that downloading activity should go in background and able activity starts and when to show progress and when it finishes it should again come to fore end.

It depends on how you are managing thread if you are using thread. You can do like which thread to pause when the long time taking activity starts and when to resume when background activity has finishes execution..

In fact this is the very good topic u have come across

_蜘蛛 2024-09-23 13:25:14

曾经有一个不活动计时器可以由应用程序重置。这将防止屏幕进入任何屏幕保护模式。

如果您使用 Symbian 中的各种异步功能,您的应用程序将在适当的时候运行。

其中一种方法应该根据您的需要而起作用。如果您更详细地描述您想要实现的目标,那么会更容易为您提供帮助。

There used to be an inactivity timer which could be reset by the application. This would prevent the screen from going into any screen saver mode.

If you use the various asynchronous function in Symbian, your app will run when appropriate.

One of these methods should work depending on your needs. If you describe what you want to achieve in more detail it would be easier to help you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文