Hi Kan-Ru,
Thanks for your reply first.
> Changing PowerManager.screenEnabled is just one way to trigger the suspend.
As I knew,
1. Changing PowerManager.screenEnabled is THE ONLY WAY to trigger the suspend.
> and remove the cpuSleepAllowed attribute from PowerManager
1. Currently PowerManager.cpuSleepAllowed is set by System app and depends on
any apps tried to call navigator.requestWakeLock or not.
2. Then gonk implementation will help to acquire a wakelock from linux kernel
corresponding to value of cpuSleepAllowed.
3. Then this mechanism can prevent system go into suspend from setting
PowerManager.screenEnabled to false.
I agree that PowerManager.cpuSleepAllowed can be removed and system app can
take care this state by itself.
partial interface navigator {
boolean requestMinPowerLevel(DOMString powerLevel)
};
partial interface PowerManager {
// Ask the system to suspend. Return true on success, false otherwise.
boolean setPowerLevel(DOMString powerLevel);
void addPowerLevelListener(MozPowerLevelListener aListener);
void removePowerLevelListener(MozPowerLevelListener aListener);
// Is the device's screen currently enabled?
attribute boolean screenEnabled;
// removed
//void addWakeLockListener(MozWakeLockListener aListener);
//void removeWakeLockListener(MozWakeLockListener aListener);
// removed
// attribute boolean cpuSleepAllowed
};
1. System app can collect the minimal power level requests from each apps then
decide what is the minimal power level now.
2. Then calling setPowerLevel() when any condition is triggered. (ex: power key
handling, idle time out or proximity event during phone call).
3. App can really request screen to off by calling screenEnabled attribute.
Sincerely yours.
----- 原始郵件 -----
寄件者: "Kan-Ru Chen (陳侃如)" <[email protected]>
收件者: "Marco Chen" <[email protected]>
副本: "Thomas Zimmermann" <[email protected]>, "Mozilla mailing list"
<[email protected]>
寄件備份: 2013 11 月 26 星期二 下午 4:11:03
主旨: Re: [b2g] [WebAPI] The Naming of PowerManager.screenEnabled Misleads the
Gaia Developers
Marco Chen <[email protected]> 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
[email protected]
https://lists.mozilla.org/listinfo/dev-b2g