Marco Chen <mc...@mozilla.com> writes:

> Hi Thomas,
>
>>> There is already PowerManager.cpuSleepAllowed for keeping the CPU running.
> Yes, you are right. But does PowerManager.screenEnabled API told developers
> that "you should request a wakelock first or system will go into sleep not
> just turn off the screen"?  It didn't make sense for this naming.  As a
> developer or as a Web API, "screenEnabled" should be acted like what it
> shows. (for screen only and not related to others) (Currently developers
> should lock a wakelock by navigator.requestWakeLock instead of touching
> PowerManager.cpuSleepAllowed directly.)

Developers also don't use PowerManager.screenEnabled directly but I get your
point.  The original API design is tightly coupled to the underlying power
management method, but we should design the API for the API users not the
ease of implementors.

>>> If we want to change the API, I'd suggest to expose different levels of
>>> power saving, as described in [1].
> Based on the types of wakelocks in [1]. I would suggest
>
>   1. Rename the PowerManager.screenEnabled to the one which focuses on asking
>      system go into power saving mode.
>   2. Consider to extend the types of wakelock for apps to choose the minimal
>      power levels they required. (Maybe rename navigator.requestWakeLock to
>      navigator.requestMinPowerLevel too.)

The current design is based on the opportunistic suspend method. When
PowerManager.cpuSleepAllowed is true, the device could suspend at anytime.
Changing PowerManager.screenEnabled is just one way to trigger the suspend.

If we want the system app has more control over when to suspend, how about
adding a suspend method and remove the cpuSleepAllowed attribute from 
PowerManager?

  partial interface PowerManager {
    // Ask the system to suspend. Return true on success, false otherwise.
    boolean suspend();

    // Is the device's screen currently enabled?
    attribute boolean screenEnabled;

    // removed
    // attribute boolean cpuSleepAllowed
  };

The gaia power manager could then try to suspend after the cpu wake lock count
hits zero (maybe wait a few seconds).

Kanru
_______________________________________________
dev-b2g mailing list
dev-b2g@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-b2g

Reply via email to