none
wm6.0如何让程序在待机的情况也能运行 RRS feed

  • 问题

  • 我目前写了一个程序要在WM6.0的手机系统上运行,但是在手机处于待机的情况下就不能运行,该软件在待机的同时也要进行GPRS通信以及获取GPS定位的。
    2009年12月18日 13:18

答案

  • 在xda-developers上,mligor提供了两种解决方法(主要看是否需要LCD一直亮着)。
    链接地址如下:http://forum.xda-developers.com/archive/index.php/t-379366.html

    I have tried and using GPSID works great.

    basically to keep GPS signal alive there are two possibilities (depends what you need):

    1) in case that you want to keep LCD ON

    - inform OS that you need always D0 state for GPD0: (SetPowerRequirement)
    - inform OS that your application needs Unattended mode (PowerPolicyNotify)
    - register for PowerState notifications (RequestPowerNotifications)
    - call SystemIdleTimerReset() often enough that LCD will not go OFF and/or device to go to sleep.

    in this case when user Press Power button, your will get notification that device is going in Unattended mode, and you have to keep device alive with SystemIdleTimerReset() and to prevent never going in Sleep mode.

    in this case user will be able to "switch off" device, but your application will continue running. You can also optimize application that in Unattended mode, nothing is updated on the screen, and less CPU to use (to save a bit battery)

    2) in case that you do not want to keep LCD On all the time

    - inform OS that you need always D0 state for GPD0: (SetPowerRequirement)
    - inform OS that your application needs Unattended mode (PowerPolicyNotify)
    - register for PowerState notifications (RequestPowerNotifications)
    - but DO NOT call SystemIdleTimerReset() unless device is in Unattended mode

    when user press Power button or device automatically switch off LCD after timeout, you will get notification about it and THEN call SystemIdleTimerReset to keep device alive. When device is again in ON mode, SystemIdleTimerReset should not be called.

    This will ensure your application to work transparent, and it is perfect for some kind of GPS logger etc...

    由于我手头没有GPS设备,所以没法测试,希望楼主可以试试看。


    施炯
    2009年12月21日 5:08
    版主
  • 在待机的情况下设备是不工作的,cpu都停止工作了。我们可以让程序工作在unattended状态下,屏幕是不亮的,但是程序是运行的。需要调用PowerPolicyNotify API, mvp也提到了这个方法了,在我的链接中也讲到了这个方法。


    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    • 已标记为答案 evanlee 2009年12月23日 9:43
    2009年12月23日 4:01
    版主
  • To Guang-Ming

    目前已经实现出来了。
    是通过的PowerPolicyNotify API来设置unattended的状态,再结合CeRunAppAtTime API不断的激活程序就可以了,但是被激活的程序有一个问题,就是如果是控制程序的话,激活时是打开一个新控制台程序。如果是Form程序的话,那么被激活的程序就是当前所运行的程序了。
    • 已标记为答案 evanlee 2009年12月23日 9:43
    2009年12月23日 9:42

全部回复

  • evanlee,

    你好。

    windows mobile设备在powering down模式下是无法和一些外设通信的(如串口,而GPS一般就是通过串口和WM设备通信)。
    一般的方法是,在应用程序中,周期性的调用SystemIdleTimerReset() 函数,阻止设备进入powering down模式。
    具体可以参考codeproject上的一篇文章:http://www.codeproject.com/KB/mobile/WiMoPower1.aspx
    在Problem "Don't Let the Device Sleep"这节中作者详细描述了解决方法。


    施炯
    2009年12月21日 3:05
    版主
  • 在xda-developers上,mligor提供了两种解决方法(主要看是否需要LCD一直亮着)。
    链接地址如下:http://forum.xda-developers.com/archive/index.php/t-379366.html

    I have tried and using GPSID works great.

    basically to keep GPS signal alive there are two possibilities (depends what you need):

    1) in case that you want to keep LCD ON

    - inform OS that you need always D0 state for GPD0: (SetPowerRequirement)
    - inform OS that your application needs Unattended mode (PowerPolicyNotify)
    - register for PowerState notifications (RequestPowerNotifications)
    - call SystemIdleTimerReset() often enough that LCD will not go OFF and/or device to go to sleep.

    in this case when user Press Power button, your will get notification that device is going in Unattended mode, and you have to keep device alive with SystemIdleTimerReset() and to prevent never going in Sleep mode.

    in this case user will be able to "switch off" device, but your application will continue running. You can also optimize application that in Unattended mode, nothing is updated on the screen, and less CPU to use (to save a bit battery)

    2) in case that you do not want to keep LCD On all the time

    - inform OS that you need always D0 state for GPD0: (SetPowerRequirement)
    - inform OS that your application needs Unattended mode (PowerPolicyNotify)
    - register for PowerState notifications (RequestPowerNotifications)
    - but DO NOT call SystemIdleTimerReset() unless device is in Unattended mode

    when user press Power button or device automatically switch off LCD after timeout, you will get notification about it and THEN call SystemIdleTimerReset to keep device alive. When device is again in ON mode, SystemIdleTimerReset should not be called.

    This will ensure your application to work transparent, and it is perfect for some kind of GPS logger etc...

    由于我手头没有GPS设备,所以没法测试,希望楼主可以试试看。


    施炯
    2009年12月21日 5:08
    版主
  • mvp回答的很好也很详细,我这里补充一下电源的知识的汇总,点击下面链接:
    http://www.codeproject.com/KB/mobile/WiMoPower1.aspx


    如果你不是很明白mvp的回答,看完这篇文章你会明白的。
    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    2009年12月21日 6:19
    版主
  • TO dearsj001

    不知道有没有注意到这个呢?Problem "Wake up and Quietly Work"
    应该是可以通过系统的时间去重新启用一个新的程序在待机情况下执行的.

    2009年12月22日 12:18
  • 在待机的情况下设备是不工作的,cpu都停止工作了。我们可以让程序工作在unattended状态下,屏幕是不亮的,但是程序是运行的。需要调用PowerPolicyNotify API, mvp也提到了这个方法了,在我的链接中也讲到了这个方法。


    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    • 已标记为答案 evanlee 2009年12月23日 9:43
    2009年12月23日 4:01
    版主
  • To Guang-Ming

    目前已经实现出来了。
    是通过的PowerPolicyNotify API来设置unattended的状态,再结合CeRunAppAtTime API不断的激活程序就可以了,但是被激活的程序有一个问题,就是如果是控制程序的话,激活时是打开一个新控制台程序。如果是Form程序的话,那么被激活的程序就是当前所运行的程序了。
    • 已标记为答案 evanlee 2009年12月23日 9:43
    2009年12月23日 9:42
  • To evanlee,

    MVP回答很好啊,只是你没有仔细看。也应该mark他的。:)


    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    2009年12月24日 3:29
    版主