summaryrefslogtreecommitdiff
path: root/dom/webidl/MozPowerManager.webidl
blob: becf6ff3ab54eecb7763e8317d3b3d5ec40dac46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

interface MozWakeLockListener;

/**
  * The reason for the factory reset.
  * "normal" : simple factory reset.
  * "wipe"   : will also attempt to wipe all user storage areas.
  * "root"   : simple factory reset that also root the phone to get more
  *            privileges when using devtools.
  */
enum FactoryResetReason {
    "normal",
    "wipe",
    "root"
};

/**
 * This interface implements navigator.mozPower
 */
[ChromeOnly]
interface MozPowerManager
{
    [Throws]
    void    powerOff();
    [Throws]
    void    reboot();
    void    factoryReset(optional FactoryResetReason reason = "normal");

    /**
     * The listeners are notified when a resource changes its lock state to:
     *  - unlocked
     *  - locked but not visible
     *  - locked and visible
     */
    void    addWakeLockListener(MozWakeLockListener aListener);
    void    removeWakeLockListener(MozWakeLockListener aListener);

    /**
     * Query the wake lock state of the topic.
     *
     * Possible states are:
     *
     *  - "unlocked" - nobody holds the wake lock.
     *
     *  - "locked-foreground" - at least one window holds the wake lock,
     *    and it is visible.
     *
     *  - "locked-background" - at least one window holds the wake lock,
     *    but all of them are hidden.
     *
     * @param aTopic The resource name related to the wake lock.
     */
    [Throws]
    DOMString getWakeLockState(DOMString aTopic);

    /**
     * Is the device's screen currently enabled?  This attribute controls the
     * device's screen, so setting it to false will turn off the screen.
     */
    attribute boolean screenEnabled;

    /**
     * Is the device's keypad/button backlight enabled? Setting it to false will
     * turn off the device's keypad/button backlight. And the brightness level
     * is the same as |screenBrightness|.
     */
    attribute boolean keyLightEnabled;

    /**
     * How bright is the screen's backlight, on a scale from 0 (very dim) to 1
     * (full brightness)?  Setting this attribute modifies the screen's
     * brightness.
     *
     * You can read and write this attribute even when the screen is disabled,
     * but the backlight is off while the screen is disabled.
     *
     * If you write a value of X into this attribute, the attribute may not have
     * the same value X when you later read it.  Most screens don't support as
     * many different brightness levels as there are doubles between 0 and 1, so
     * we may reduce the value's precision before storing it.
     *
     * @throw NS_ERROR_INVALID_ARG if brightness is not in the range [0, 1].
     */
    [SetterThrows]
    attribute double screenBrightness;

    /**
     * Is it possible that the device's CPU will sleep after the screen is
     * disabled?  Setting this attribute to false will prevent the device
     * entering suspend state.
     */
    attribute boolean cpuSleepAllowed;
};