More updates: use string instead of integer to identify blocker type.

This commit is contained in:
Haojian Wu 2015-06-24 12:49:43 +08:00
parent 532f75fcab
commit 13784e6551
4 changed files with 29 additions and 43 deletions

View file

@ -8,7 +8,7 @@ An example is:
```javascript
var powerSaveBlocker = require('power-save-blocker');
var id = powerSaveBlocker.start(powerSaveBlocker.PREVENT_DISPLAY_SLEEP);
var id = powerSaveBlocker.start('prevent-display-sleep');
console.log(powerSaveBlocker.isStarted(id));
powerSaveBlocker.stop(id);
@ -16,25 +16,24 @@ powerSaveBlocker.stop(id);
## powerSaveBlocker.start(type)
* `type` - Power save blocker type
* powerSaveBlocker.PREVENT_APP_SUSPENSION - Prevent the application from being
suspended. Keeps system active, but allows screen to be turned off.
Example use cases: downloading a file, playing audio.
* powerSaveBlocker.PREVENT_DISPLAY_SLEEP - Prevent the display from going to sleep.
Keeps system and screen active.
Example use case: playing video.
* `type` String - Power save blocker type
* `prevent-app-suspension` - Prevent the application from being suspended.
Keeps system active, but allows screen to be turned off. Example use cases:
downloading a file, playing audio.
* `prevent-display-sleep`- Prevent the display from going to sleep. Keeps system
and screen active. Example use case: playing video.
Starts the power save blocker preventing the system entering lower-power mode.
Returns an integer identified the power save blocker.
**Note:**
`PREVENT_DISPLAY_SLEEP` has higher precedence level than `PREVENT_APP_SUSPENSION`.
Only the highest precedence type takes effect. In other words, `PREVENT_DISPLAY_SLEEP`
always take precedence over `PREVENT_APP_SUSPENSION`.
`prevent-display-sleep` has higher precedence level than `prevent-app-suspension`.
Only the highest precedence type takes effect. In other words, `prevent-display-sleep`
always take precedence over `prevent-app-suspension`.
For example, an API calling A requests for `PREVENT_APP_SUSPENSION`, and
another calling B requests for `PREVENT_DISPLAY_SLEEP`. `PREVENT_DISPLAY_SLEEP`
will be used until B stops its request. After that, `PREVENT_APP_SUSPENSION` is used.
For example, an API calling A requests for `prevent-app-suspension`, and
another calling B requests for `prevent-display-sleep`. `prevent-display-sleep`
will be used until B stops its request. After that, `prevent-app-suspension` is used.
## powerSaveBlocker.stop(id)