For more information on the Power features, see Power Guide.
Since: 2.0
Interface | Method |
---|---|
PowerManagerObject | |
PowerManager | void request (PowerResource resource, PowerState state) void release (PowerResource resource) void setScreenStateChangeListener (ScreenStateChangeCallback listener) void unsetScreenStateChangeListener () double getScreenBrightness () void setScreenBrightness (double brightness) boolean isScreenOn () void restoreScreenBrightness () void turnScreenOn () void turnScreenOff () |
ScreenStateChangeCallback | void onchanged (PowerScreenState previousState, PowerScreenState changedState) |
enum PowerResource { "SCREEN", "CPU" };
Since: 2.0
Screen and CPU resources are supported at present. Supported power resource states are provided in PowerScreenState and PowerCpuState enums respectively prefixed by the corresponding resource type.
Deprecated. SCREEN_BRIGHT is deprecated.
enum PowerScreenState { "SCREEN_OFF", "SCREEN_DIM", "SCREEN_NORMAL", "SCREEN_BRIGHT" };
Since: 2.0
The supported values are:
DIM state refers to the screen that the backlight is turned off. NORMAL state refers to the default screen brightness that a user has configured for the device. BRIGHT(Deprecated) state refers to the maximum screen brightness that the device provides. Note that the change in brightness does not affect the system brightness setting, i.e., the system brightness value is automatically restored when the resource is released or the process is completed.
enum PowerCpuState { "CPU_AWAKE" };
Since: 2.0
The supported values are:
typedef (PowerScreenState or PowerCpuState) PowerState;
Since: 2.0
[NoInterfaceObject] interface PowerManagerObject { readonly attribute PowerManager power; };
Tizen implements PowerManagerObject;
Since: 2.0
There will be a tizen.power object that allows accessing of a functionality of the Power API.
[NoInterfaceObject] interface PowerManager { void request(PowerResource resource, PowerState state) raises(WebAPIException); void release(PowerResource resource) raises(WebAPIException); void setScreenStateChangeListener(ScreenStateChangeCallback listener) raises(WebAPIException); void unsetScreenStateChangeListener() raises(WebAPIException); double getScreenBrightness() raises(WebAPIException); void setScreenBrightness(double brightness) raises(WebAPIException); boolean isScreenOn() raises(WebAPIException); void restoreScreenBrightness() raises(WebAPIException); void turnScreenOn() raises(WebAPIException); void turnScreenOff() raises(WebAPIException); };
Since: 2.0
However, these requests can be overridden by the system. If the requests are overridden, the application is notified with the provided listener callback.
request
void request(PowerResource resource, PowerState state);
Since: 2.0
Privilege level: public
Privilege: http://tizen.org/privilege/power
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type.
with error type NotSupportedError, if this feature is not supported.
with error type InvalidValuesError, if any of the input parameters contain an invalid value.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError in any other error case.
Code example:
tizen.power.request("SCREEN", "SCREEN_NORMAL");
release
void release(PowerResource resource);
Since: 2.0
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type.
with error type NotSupportedError, if this feature is not supported.
with error type InvalidValuesError, if any of the input parameters contain an invalid value.
with error type UnknownError in any other error case.
Code example:
// Release SCREEN resource. tizen.power.release("SCREEN");
setScreenStateChangeListener
void setScreenStateChangeListener(ScreenStateChangeCallback listener);
Since: 2.0
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type.
with error type NotSupportedError, if this feature is not supported.
with error type InvalidValuesError, if any of the input parameters contain an invalid value.
with error type UnknownError in any other error case.
Code example:
function onScreenStateChanged(previousState, changedState) { console.log("Screen state changed from " + previousState + " to " + changedState); } // Sets the screen state change listener. tizen.power.setScreenStateChangeListener(onScreenStateChanged);
unsetScreenStateChangeListener
void unsetScreenStateChangeListener();
Since: 2.0
Exceptions:
with error type NotSupportedError, if this feature is not supported.
with error type UnknownError in any other error case.
Code example:
// Unsets the screen state change listener. tizen.power.unsetScreenStateChangeListener();
getScreenBrightness
double getScreenBrightness();
Since: 2.0
Return value:
double Current screen brightness valueExceptions:
with error type NotSupportedError, if this feature is not supported.
with error type UnknownError in any other error case.
Code example:
// Gets the current screen brightness value. var screenBrightness = tizen.power.getScreenBrightness();
setScreenBrightness
void setScreenBrightness(double brightness);
Since: 2.0
An approximation is made for best effort when the given value is not exactly applicable by the hardware or system.
Privilege level: public
Privilege: http://tizen.org/privilege/power
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type.
with error type NotSupportedError, if this feature is not supported.
with error type InvalidValuesError, if any of the input parameters contain an invalid value.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError in any other error case.
Code example:
// Sets the screen brightness value for the application. tizen.power.setScreenBrightness(1);
isScreenOn
boolean isScreenOn();
Since: 2.0
Return value:
boolean true if screen is on, otherwise false if the screen is offExceptions:
with error type NotSupportedError, if this feature is not supported.
with error type UnknownError in any other error case.
Code example:
// Checks whether the screen is on or off. var isScreenOn = tizen.power.isScreenOn();
restoreScreenBrightness
void restoreScreenBrightness();
Since: 2.0
Exceptions:
with error type NotSupportedError, if this feature is not supported.
with error type UnknownError in any other error case.
Code example:
// Restores the screen brightness value to the system default setting value. tizen.power.restoreScreenBrightness();
turnScreenOn
void turnScreenOn();
Since: 2.0
This API triggers turn-on process and then updates the status when it completes. While the operation is on-going, the isScreenOn() method returns false.
Privilege level: public
Privilege: http://tizen.org/privilege/power
Exceptions:
with error type NotSupportedError, if this feature is not supported.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError in any other error case.
Code example:
// Turns the screen on. tizen.power.turnScreenOn();
turnScreenOff
void turnScreenOff();
Since: 2.0
This API triggers turn-off process and then updates the status when it completes. While the operation is on-going, the isScreenOn() method returns true.
Privilege level: public
Privilege: http://tizen.org/privilege/power
Exceptions:
with error type NotSupportedError, if this feature is not supported.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError in any other error case.
Code example:
// Turns the screen off. tizen.power.turnScreenOff();
[Callback=FunctionOnly, NoInterfaceObject] interface ScreenStateChangeCallback { void onchanged(PowerScreenState previousState, PowerScreenState changedState); };
Since: 2.0
onchanged
void onchanged(PowerScreenState previousState, PowerScreenState changedState);
Since: 2.0
Parameters:
module Power { enum PowerResource { "SCREEN", "CPU" }; enum PowerScreenState { "SCREEN_OFF", "SCREEN_DIM", "SCREEN_NORMAL", "SCREEN_BRIGHT" }; enum PowerCpuState { "CPU_AWAKE" }; typedef (PowerScreenState or PowerCpuState) PowerState; [NoInterfaceObject] interface PowerManagerObject { readonly attribute PowerManager power; }; Tizen implements PowerManagerObject; [NoInterfaceObject] interface PowerManager { void request(PowerResource resource, PowerState state) raises(WebAPIException); void release(PowerResource resource) raises(WebAPIException); void setScreenStateChangeListener(ScreenStateChangeCallback listener) raises(WebAPIException); void unsetScreenStateChangeListener() raises(WebAPIException); double getScreenBrightness() raises(WebAPIException); void setScreenBrightness(double brightness) raises(WebAPIException); boolean isScreenOn() raises(WebAPIException); void restoreScreenBrightness() raises(WebAPIException); void turnScreenOn() raises(WebAPIException); void turnScreenOff() raises(WebAPIException); }; [Callback=FunctionOnly, NoInterfaceObject] interface ScreenStateChangeCallback { void onchanged(PowerScreenState previousState, PowerScreenState changedState); }; };