Class Power
Definition
- Assembly:
- Tizen.System.dll
The Power class provides methods to control the power service.
public static class Power
- Inheritance
-
objectPower
Remarks
The Power API provides the way to control the power service. It can be made to hold the specific state to avoid the CPU state internally.
Methods
View SourceCancelWaitCallback(UInt64)
Notify the deviced that it needs undoing the current transition.
Declaration
public static void CancelWaitCallback(UInt64 wait_callback_id)
Parameters
| Type | Name | Description |
|---|---|---|
| UInt64 | wait_callback_id | Wait callback id to cancel. |
Remarks
Notify the deviced that the current transition should be rewinded. This function only works on the id received from device_power_state_wait_callback() and device_power_transient_state_wait_callback(). Above functions are mapped to (PowerState)StateWaitCallback/(PowerTransientState)StateWaitCallback Event handler.
Examples
public static void MyPowerCallback(object sender, PowerStateWaitEventArgs args)
{
Do something with args...
Power.CancelWaitCallback(args.WaitCallbackId);
}
See Also
View SourceChangeState(PowerState, int)
Send request for changing power state asynchronously.
Declaration
public static void ChangeState(PowerState state, int timeout_sec)
Parameters
| Type | Name | Description |
|---|---|---|
| PowerState | state | Target state. |
| int | timeout_sec | Timeout for the async reply in second, maximum of 10 seconds. If you put 0, then it will be set 10 sec automatically. |
Remarks
If it is need to get result callback event, then follow below description. However, if it is not necessary, skip add callback event. After change state request, callback event is called only once per change request.
- Add callback event to power state request callback that you want to change.
- This callback event will be invoked later by timeout or success/failure.
- After callback event is called, it is better to clean up that subscribed callback events.
Examples
public static void PowerStateChangedCallback(Object sender, PowerStateChangeRequestEventArgs args)
{
args.Retval // If this value is negative, this means that the request failed.
Do something with args...
}
Power.SleepStateChangeRequestCallback += PowerStateChangedCallback;
Power.ChangeState(PowerState.Sleep, 5);
or just use like below
Power.ChangeState(PowerState.Normal, 10);
See Also
View SourceCheckRebootAllowed()
Check if reboot is possible on the current device state.
Declaration
public static int CheckRebootAllowed()
Returns
| Type | Description |
|---|---|
| int |
Remarks
The return value will be 0(not possible) or 1(possible).
Examples
int retval = 0;
retval = Power.CheckRebootAllowed();
View Source
ConfirmWaitCallback(UInt64)
Notify the deviced that it is ready for the actual action.
Declaration
public static void ConfirmWaitCallback(UInt64 wait_callback_id)
Parameters
| Type | Name | Description |
|---|---|---|
| UInt64 | wait_callback_id | Wait callback id to confirm. |
Remarks
Notify the deviced that it is ok to take an actual action of change state. This function only works on the id received from device_power_state_wait_callback() and device_power_transient_state_wait_callback(). Above functions are mapped to (PowerState)StateWaitCallback/(PowerTransientState)StateWaitCallback Event handler.
Examples
public static void MyPowerCallback(object sender, PowerStateWaitEventArgs args)
{
Do Something...
Power.ConfirmWaitCallback(args.WaitCallbackId);
}
See Also
View SourceGetLockState(PowerLock)
Gets the status of power lock is locked or not based on specific power lock type.
Declaration
public static PowerLockState GetLockState(PowerLock type)
Parameters
| Type | Name | Description |
|---|---|---|
| PowerLock | type | Type of power lock. |
Returns
| Type | Description |
|---|---|
| PowerLockState |
Remarks
Retrieves the status of a power lock.
Examples
PowerLockState lock_state = Power.GetLockState(PowerLock.Cpu);
See Also
View SourceGetWakeupReason()
Gets the reason for the last device wakeup based on the scenario.
Declaration
public static PowerTransitionReason GetWakeupReason()
Returns
| Type | Description |
|---|---|
| PowerTransitionReason |
Remarks
This api is not supported at TV profile.
Examples
PowerTransitionReason transition_reason = Power.GetWakeupReason();
See Also
View SourcePowerOff()
Requests the current device's power state change to be changed to powered off.
Declaration
public static void PowerOff()
Remarks
It operates synchronously and powers off the current device.
Examples
Tizen.System.Power.PowerOff();
View Source
Reboot(string)
Sends a request to the deviced Rebooting the current device.
Declaration
public static void Reboot(string reason)
Parameters
| Type | Name | Description |
|---|---|---|
| string | reason |
Remarks
It operates asynchronously.
Examples
Tizen.System.Power.Reboot(null);
See Also
View SourceReleaseCpuLock()
[Obsolete("Please do not use! this will be deprecated")]
Declaration
public static void ReleaseCpuLock()
Remarks
The Power API provides the way to control the power service. It can be made to hold the specific state to avoid the CPU state internally.
ReleaseLock(PowerLock)
Releases the given specific power lock type which was locked before.
Declaration
public static void ReleaseLock(PowerLock type)
Parameters
| Type | Name | Description |
|---|---|---|
| PowerLock | type | The power type to request lock. |
Remarks
If display feature(http://tizen.org/feature/display) is false, then only the type POWER_LOCK_CPU is effective,
and the other type returns DEVICE_ERROR_NOT_SUPPORTED.
And even thoguh the display feature is false,
it requires display privilege(http://tizen.org/privilege/display).
Examples
Tizen.System.Power.ReleaseLock(Tizen.System.Power.PowerLock.Cpu);
See Also
View SourceRequestCpuLock(int)
[Obsolete("Please do not use! this will be deprecated")]
Declaration
public static void RequestCpuLock(int timeout)
Parameters
| Type | Name | Description |
|---|---|---|
| int | timeout | The positive number in milliseconds or 0 for the permanent lock. So you must release the permanent lock of the power state with ReleaseCpuLock() if timeout_ms is zero. |
Remarks
If the process dies, then every lock will be removed.
RequestLock(PowerLock, int)
Locks the given lock state for a specified time. After the given timeout (in milliseconds), unlock the given lock state automatically.
Declaration
public static void RequestLock(PowerLock type, int timeout)
Parameters
| Type | Name | Description |
|---|---|---|
| PowerLock | type | The power type to request lock. |
| int | timeout | The positive number in milliseconds or 0 for the permanent lock. So you must release the permanent lock of the power state with ReleaseLock() if timeout_ms is zero. |
Remarks
If display feature(http://tizen.org/feature/display) is false, then only the type POWER_LOCK_CPU is effective,
and the other type returns DEVICE_ERROR_NOT_SUPPORTED.
And even thoguh the display feature is false,
it requires display privilege(http://tizen.org/privilege/display).
Scenario 1. If the same application requests the same power lock more than twice before it is released or expired,
the timeout will be updated to the latest requested time.
For example:
The first request has a timeout of 5000ms.
The second request has a timeout of 1000ms.
If the second request is made before the first request is released or expired,
the timeout will be updated to the latest requested time, which is 1000ms.
Scenario 2. If different applications request the same power lock type,
the power state timeout will be set to the maximum of the requested timeouts.
For example:
Application A requests POWER_LOCK_CPU with a timeout of 5000ms.
Application B requests the same POWER_LOCK_CPU with a timeout of 1000ms.
Unless Application A releases the POWER_LOCK_CPU lock,
the timeout for POWER_LOCK_CPU will remain at the maximum requested time, which is 5000ms.
Examples
Tizen.System.Power.RequestLock(Tizen.System.Power.PowerLock.Cpu, 2000);
See Also
Events
View SourceCpuLockStateChangedCallback
CpuLockStateChangedCallback is triggered when the PowerLock.Cpu status is changed to Lock or Unlock
Declaration
public static event EventHandler<PowerLockStateChangedEventArgs> CpuLockStateChangedCallback
Event Type
| Type | Description |
|---|---|
| EventHandler<><PowerLockStateChangedEventArgs> |
Remarks
The Power API provides the way to control the power service. It can be made to hold the specific state to avoid the CPU state internally.
Examples
public static void PowerLockStateChangeCallback(object sender, PowerLockStateChangedEventArgs args)
{
PowerLock lock_type = args.PowerLockType;
PowerLockState lock_state = args.PowerLockState;
}
Power.CpuLockStateChangedCallback += PowerLockStateChangeCallback;
See Also
View SourceDisplayDimLockStateChangedCallback
DisplayDimLockStateChangedCallback is triggered when the PowerLock.DisplayDim status is changed to Lock or Unlock
Declaration
public static event EventHandler<PowerLockStateChangedEventArgs> DisplayDimLockStateChangedCallback
Event Type
| Type | Description |
|---|---|
| EventHandler<><PowerLockStateChangedEventArgs> |
Remarks
The Power API provides the way to control the power service. It can be made to hold the specific state to avoid the CPU state internally.
Examples
public static void PowerLockStateChangeCallback(object sender, PowerLockStateChangedEventArgs args)
{
PowerLock lock_type = args.PowerLockType;
PowerLockState lock_state = args.PowerLockState;
}
Power.DisplayDimLockStateChangedCallback += PowerLockStateChangeCallback;
See Also
View SourceDisplayNormalLockStateChangedCallback
DisplayNormalLockStateChangedCallback is triggered when the PowerLock.DisplayNormal status is changed to Lock or Unlock
Declaration
public static event EventHandler<PowerLockStateChangedEventArgs> DisplayNormalLockStateChangedCallback
Event Type
| Type | Description |
|---|---|
| EventHandler<><PowerLockStateChangedEventArgs> |
Remarks
The Power API provides the way to control the power service. It can be made to hold the specific state to avoid the CPU state internally.
Examples
public static void PowerLockStateChangeCallback(object sender, PowerLockStateChangedEventArgs args)
{
PowerLock lock_type = args.PowerLockType;
PowerLockState lock_state = args.PowerLockState;
}
Power.DisplayNormalLockStateChangedCallback += PowerLockStateChangeCallback;
See Also
View SourceExitStateChangeRequestCallback
ExitStateChangeRequestCallback is triggered when the request to change to Exit power state is handled from deviced.
Declaration
public static event EventHandler<PowerStateChangeRequestEventArgs> ExitStateChangeRequestCallback
Event Type
| Type | Description |
|---|---|
| EventHandler<><PowerStateChangeRequestEventArgs> |
Remarks
The Power API provides the way to control the power service. It can be made to hold the specific state to avoid the CPU state internally.
Examples
public static void PowerStateChangeRequestCallback(object sender, PowerStateChangeRequestEventArgs args)
{
PowerState power_state = args.PowerState;
int retval = args.Retval;
}
Power.ExitStateChangeRequestCallback += PowerStateChangeRequestCallback;
See Also
View SourceExitStateWaitCallback
ExitStateWaitCallback is triggered when the Power state changes to Exit.
Declaration
public static event EventHandler<PowerStateWaitEventArgs> ExitStateWaitCallback
Event Type
| Type | Description |
|---|---|
| EventHandler<><PowerStateWaitEventArgs> |
Remarks
The Power API provides the way to control the power service. It can be made to hold the specific state to avoid the CPU state internally.
Examples
public static void PowerStateWaitCallback(object sender, PowerStateWaitEventArgs args)
{
PowerState prev_state = args.PrevState;
PowerState next_state = args.NextState;
ulong wait_callback_id = args.WaitCallbackId;
PowerTransitionReason transition_reason = args.TransitionReason;
}
Power.ExitStateWaitCallback += PowerStateWaitCallback;
See Also
View SourceNormalStateChangeRequestCallback
NormalStateChangeRequestCallback is triggered when the request to change to Normal power state is handled from deviced.
Declaration
public static event EventHandler<PowerStateChangeRequestEventArgs> NormalStateChangeRequestCallback
Event Type
| Type | Description |
|---|---|
| EventHandler<><PowerStateChangeRequestEventArgs> |
Remarks
The Power API provides the way to control the power service. It can be made to hold the specific state to avoid the CPU state internally.
Examples
public static void PowerStateChangeRequestCallback(object sender, PowerStateChangeRequestEventArgs args)
{
PowerState power_state = args.PowerState;
int retval = args.Retval;
}
Power.NormalStateChangeRequestCallback += PowerStateChangeRequestCallback;
View Source
NormalStateWaitCallback
NormalStateWaitCallback is triggered when the Power state changes to Normal.
Declaration
public static event EventHandler<PowerStateWaitEventArgs> NormalStateWaitCallback
Event Type
| Type | Description |
|---|---|
| EventHandler<><PowerStateWaitEventArgs> |
Remarks
The Power API provides the way to control the power service. It can be made to hold the specific state to avoid the CPU state internally.
Examples
public static void PowerStateWaitCallback(object sender, PowerStateWaitEventArgs args)
{
PowerState prev_state = args.PrevState;
PowerState next_state = args.NextState;
ulong wait_callback_id = args.WaitCallbackId;
PowerTransitionReason transition_reason = args.TransitionReason;
}
Power.NormalStateWaitCallback += PowerStateWaitCallback;
See Also
View SourcePoweroffStateChangeRequestCallback
PoweroffStateChangeRequestCallback is triggered when the request to change to Poweroff power state is handled from deviced.
Declaration
public static event EventHandler<PowerStateChangeRequestEventArgs> PoweroffStateChangeRequestCallback
Event Type
| Type | Description |
|---|---|
| EventHandler<><PowerStateChangeRequestEventArgs> |
Remarks
The Power API provides the way to control the power service. It can be made to hold the specific state to avoid the CPU state internally.
Examples
public static void PowerStateChangeRequestCallback(object sender, PowerStateChangeRequestEventArgs args)
{
PowerState power_state = args.PowerState;
int retval = args.Retval;
}
Power.PoweroffStateChangeRequestCallback += PowerStateChangeRequestCallback;
See Also
View SourcePoweroffStateWaitCallback
PoweroffStateWaitCallback is triggered when the Power state changes to Poweroff.
Declaration
public static event EventHandler<PowerStateWaitEventArgs> PoweroffStateWaitCallback
Event Type
| Type | Description |
|---|---|
| EventHandler<><PowerStateWaitEventArgs> |
Remarks
The Power API provides the way to control the power service. It can be made to hold the specific state to avoid the CPU state internally.
Examples
public static void PowerStateWaitCallback(object sender, PowerStateWaitEventArgs args)
{
PowerState prev_state = args.PrevState;
PowerState next_state = args.NextState;
ulong wait_callback_id = args.WaitCallbackId;
PowerTransitionReason transition_reason = args.TransitionReason;
}
Power.PoweroffStateWaitCallback += PowerStateWaitCallback;
See Also
View SourceRebootStateChangeRequestCallback
RebootStateChangeRequestCallback is triggered when the request to change to Reboot power state is handled from deviced.
Declaration
public static event EventHandler<PowerStateChangeRequestEventArgs> RebootStateChangeRequestCallback
Event Type
| Type | Description |
|---|---|
| EventHandler<><PowerStateChangeRequestEventArgs> |
Remarks
The Power API provides the way to control the power service. It can be made to hold the specific state to avoid the CPU state internally.
Examples
public static void PowerStateChangeRequestCallback(object sender, PowerStateChangeRequestEventArgs args)
{
PowerState power_state = args.PowerState;
int retval = args.Retval;
}
Power.RebootStateChangeRequestCallback += PowerStateChangeRequestCallback;
See Also
View SourceRebootStateWaitCallback
RebootStateWaitCallback is triggered when the Power state changes to Reboot.
Declaration
public static event EventHandler<PowerStateWaitEventArgs> RebootStateWaitCallback
Event Type
| Type | Description |
|---|---|
| EventHandler<><PowerStateWaitEventArgs> |
Remarks
The Power API provides the way to control the power service. It can be made to hold the specific state to avoid the CPU state internally.
Examples
public static void PowerStateWaitCallback(object sender, PowerStateWaitEventArgs args)
{
PowerState prev_state = args.PrevState;
PowerState next_state = args.NextState;
ulong wait_callback_id = args.WaitCallbackId;
PowerTransitionReason transition_reason = args.TransitionReason;
}
Power.RebootStateWaitCallback += PowerStateWaitCallback;
See Also
View SourceSleepStateChangeRequestCallback
SleepStateChangeRequestCallback is triggered when the request to change to Sleep power state is handled from deviced.
Declaration
public static event EventHandler<PowerStateChangeRequestEventArgs> SleepStateChangeRequestCallback
Event Type
| Type | Description |
|---|---|
| EventHandler<><PowerStateChangeRequestEventArgs> |
Remarks
The Power API provides the way to control the power service. It can be made to hold the specific state to avoid the CPU state internally.
Examples
public static void PowerStateChangeRequestCallback(object sender, PowerStateChangeRequestEventArgs args)
{
PowerState power_state = args.PowerState;
int retval = args.Retval;
}
Power.SleepStateChangeRequestCallback += PowerStateChangeRequestCallback;
See Also
View SourceSleepStateWaitCallback
SleepStateWaitCallback is triggered when the Power state changes to Sleep.
Declaration
public static event EventHandler<PowerStateWaitEventArgs> SleepStateWaitCallback
Event Type
| Type | Description |
|---|---|
| EventHandler<><PowerStateWaitEventArgs> |
Remarks
The Power API provides the way to control the power service. It can be made to hold the specific state to avoid the CPU state internally.
Examples
public static void PowerStateWaitCallback(object sender, PowerStateWaitEventArgs args)
{
PowerState prev_state = args.PrevState;
PowerState next_state = args.NextState;
ulong wait_callback_id = args.WaitCallbackId;
PowerTransitionReason transition_reason = args.TransitionReason;
}
Power.SleepStateWaitCallback += PowerStateWaitCallback;
See Also
View SourceStartStateChangeRequestCallback
StartStateChangeRequestCallback is triggered when the request to change to Start power state is handled from deviced.
Declaration
public static event EventHandler<PowerStateChangeRequestEventArgs> StartStateChangeRequestCallback
Event Type
| Type | Description |
|---|---|
| EventHandler<><PowerStateChangeRequestEventArgs> |
Remarks
The Power API provides the way to control the power service. It can be made to hold the specific state to avoid the CPU state internally.
Examples
public static void PowerStateChangeRequestCallback(object sender, PowerStateChangeRequestEventArgs args)
{
PowerState power_state = args.PowerState;
int retval = args.Retval;
}
Power.StartStateChangeRequestCallback += PowerStateChangeRequestCallback;
See Also
View SourceStartStateWaitCallback
StartStateWaitCallback is triggered when the Power state changes to Start.
Declaration
public static event EventHandler<PowerStateWaitEventArgs> StartStateWaitCallback
Event Type
| Type | Description |
|---|---|
| EventHandler<><PowerStateWaitEventArgs> |
Remarks
The Power API provides the way to control the power service. It can be made to hold the specific state to avoid the CPU state internally.
Examples
public static void PowerStateWaitCallback(object sender, PowerStateWaitEventArgs args)
{
PowerState prev_state = args.PrevState;
PowerState next_state = args.NextState;
ulong wait_callback_id = args.WaitCallbackId;
PowerTransitionReason transition_reason = args.TransitionReason;
}
Power.StartStateWaitCallback += PowerStateWaitCallback;
See Also
View SourceTransientResumingEarlyStateWaitCallback
TransientResumingEarlyStateWaitCallback is triggered when the Power transient state changes to ResumingEarly.
Declaration
public static event EventHandler<PowerTransientStateWaitEventArgs> TransientResumingEarlyStateWaitCallback
Event Type
| Type | Description |
|---|---|
| EventHandler<><PowerTransientStateWaitEventArgs> |
Remarks
The Power API provides the way to control the power service. It can be made to hold the specific state to avoid the CPU state internally.
Examples
public static void PowerTransientStateWaitCallback(object sender, PowerTransientStateWaitEventArgs args)
{
PowerTransientState transient_state = args.TransientState;
ulong wait_callback_id = args.WaitCallbackId;
PowerTransitionReason transition_reason = args.TransitionReason;
}
Power.TransientResumingEarlyStateWaitCallback += PowerTransientStateWaitCallback;
See Also
View SourceTransientResumingLateStateWaitCallback
TransientResumingLateStateWaitCallback is triggered when the Power transient state changes to ResumingLate.
Declaration
public static event EventHandler<PowerTransientStateWaitEventArgs> TransientResumingLateStateWaitCallback
Event Type
| Type | Description |
|---|---|
| EventHandler<><PowerTransientStateWaitEventArgs> |
Remarks
The Power API provides the way to control the power service. It can be made to hold the specific state to avoid the CPU state internally.
Examples
public static void PowerTransientStateWaitCallback(object sender, PowerTransientStateWaitEventArgs args)
{
PowerTransientState transient_state = args.TransientState;
ulong wait_callback_id = args.WaitCallbackId;
PowerTransitionReason transition_reason = args.TransitionReason;
}
Power.TransientResumingLateStateWaitCallback += PowerTransientStateWaitCallback;
See Also
View SourceTransientResumingStateWaitCallback
TransientResumingStateWaitCallback is triggered when the Power transient state changes to Resuming.
Declaration
public static event EventHandler<PowerTransientStateWaitEventArgs> TransientResumingStateWaitCallback
Event Type
| Type | Description |
|---|---|
| EventHandler<><PowerTransientStateWaitEventArgs> |
Remarks
The Power API provides the way to control the power service. It can be made to hold the specific state to avoid the CPU state internally.
Examples
public static void PowerTransientStateWaitCallback(object sender, PowerTransientStateWaitEventArgs args)
{
PowerTransientState transient_state = args.TransientState;
ulong wait_callback_id = args.WaitCallbackId;
PowerTransitionReason transition_reason = args.TransitionReason;
}
Power.TransientResumingStateWaitCallback += PowerTransientStateWaitCallback;
See Also
View SourceTransientSuspendingEarlyStateWaitCallback
TransientSuspendingEarlyStateWaitCallback is triggered when the Power transient state changes to SuspendingEarly.
Declaration
public static event EventHandler<PowerTransientStateWaitEventArgs> TransientSuspendingEarlyStateWaitCallback
Event Type
| Type | Description |
|---|---|
| EventHandler<><PowerTransientStateWaitEventArgs> |
Remarks
The Power API provides the way to control the power service. It can be made to hold the specific state to avoid the CPU state internally.
Examples
public static void PowerTransientStateWaitCallback(object sender, PowerTransientStateWaitEventArgs args)
{
PowerTransientState transient_state = args.TransientState;
ulong wait_callback_id = args.WaitCallbackId;
PowerTransitionReason transition_reason = args.TransitionReason;
}
Power.TransientSuspendingEarlyStateWaitCallback += PowerTransientStateWaitCallback;
See Also
View SourceTransientSuspendingLateStateWaitCallback
TransientSuspendingLateStateWaitCallback is triggered when the Power transient state changes to SuspendingLate.
Declaration
public static event EventHandler<PowerTransientStateWaitEventArgs> TransientSuspendingLateStateWaitCallback
Event Type
| Type | Description |
|---|---|
| EventHandler<><PowerTransientStateWaitEventArgs> |
Remarks
The Power API provides the way to control the power service. It can be made to hold the specific state to avoid the CPU state internally.
Examples
public static void PowerTransientStateWaitCallback(object sender, PowerTransientStateWaitEventArgs args)
{
PowerTransientState transient_state = args.TransientState;
ulong wait_callback_id = args.WaitCallbackId;
PowerTransitionReason transition_reason = args.TransitionReason;
}
Power.TransientSuspendingLateStateWaitCallback += PowerTransientStateWaitCallback;
See Also
View SourceTransientSuspendingStateWaitCallback
TransientSuspendingStateWaitCallback is triggered when the Power transient state changes to Suspending.
Declaration
public static event EventHandler<PowerTransientStateWaitEventArgs> TransientSuspendingStateWaitCallback
Event Type
| Type | Description |
|---|---|
| EventHandler<><PowerTransientStateWaitEventArgs> |
Remarks
The Power API provides the way to control the power service. It can be made to hold the specific state to avoid the CPU state internally.
Examples
public static void PowerTransientStateWaitCallback(object sender, PowerTransientStateWaitEventArgs args)
{
PowerTransientState transient_state = args.TransientState;
ulong wait_callback_id = args.WaitCallbackId;
PowerTransitionReason transition_reason = args.TransitionReason;
}
Power.TransientSuspendingStateWaitCallback += PowerTransientStateWaitCallback;