Class Power

Definition

Namespace:
Tizen.System
Assembly:
Tizen.System.dll
API Level:
3
Privilege Level:
public
Privilege:
http://tizen.org/privilege/display

The Power class provides methods to control the power service.

C#
Copy
public static class Power : object
Inheritance
Power
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 Source

CancelWaitCallback(UInt64)

Notify the deviced that it needs undoing the current transition.

Declaration
C#
Copy
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
Copy
public static void MyPowerCallback(object sender, PowerStateWaitEventArgs args) { Do something with args... Power.CancelWaitCallback(args.WaitCallbackId); }
API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/display
View Source

ChangeState(PowerState, Int32)

Send request for changing power state asynchronously.

Declaration
C#
Copy
public static void ChangeState(PowerState state, int timeout_sec)
Parameters
Type Name Description
PowerState state

Target state.

Int32 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.

  1. Add callback event to power state request callback that you want to change.
  2. This callback event will be invoked later by timeout or success/failure.
  3. After callback event is called, it is better to clean up that subscribed callback events.
Examples
Copy
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);
API Level: 10
View Source

CheckRebootAllowed()

Check if reboot is possible on the current device state.

Declaration
C#
Copy
public static int CheckRebootAllowed()
Returns
Type Description
Int32
Remarks

The return value will be 0(not possible) or 1(possible).

Examples
Copy
int retval = 0; retval = Power.CheckRebootAllowed();
API Level: 10
View Source

ConfirmWaitCallback(UInt64)

Notify the deviced that it is ready for the actual action.

Declaration
C#
Copy
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
Copy
public static void MyPowerCallback(object sender, PowerStateWaitEventArgs args) { Do Something... Power.ConfirmWaitCallback(args.WaitCallbackId); }
API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/display
View Source

GetLockState(PowerLock)

Gets the status of power lock.

Declaration
C#
Copy
public static PowerLockState GetLockState(PowerLock type)
Parameters
Type Name Description
PowerLock type

Type of power lock.

Returns
Type Description
PowerLockState
Examples
Copy
PowerLockState lock_state = Power.GetLockState(PowerLock.Cpu);
API Level: 10
View Source

GetWakeupReason()

Get wakeup reason.

Declaration
C#
Copy
public static PowerTransitionReason GetWakeupReason()
Returns
Type Description
PowerTransitionReason
Remarks

This api is not supported at TV profile.

Examples
Copy
PowerTransitionReason transition_reason = Power.GetWakeupReason();
API Level: 10
View Source

PowerOff()

Power off the device.

Declaration
C#
Copy
public static void PowerOff()
Examples
Copy
Tizen.System.Power.PowerOff();
Privilege Level: platform
Privilege: http://tizen.org/privilege/reboot
View Source

Reboot(String)

Reboot the device.

Declaration
C#
Copy
public static void Reboot(string reason)
Parameters
Type Name Description
String reason
Examples
Copy
Tizen.System.Power.Reboot(null);
Privilege Level: platform
Privilege: http://tizen.org/privilege/reboot
View Source

ReleaseCpuLock()

[Obsolete("Please do not use! this will be deprecated")]

Declaration
C#
Copy
public static void ReleaseCpuLock()
API Level: 3
View Source

ReleaseLock(PowerLock)

Releases the lock state.

Declaration
C#
Copy
public static void ReleaseLock(PowerLock type)
Parameters
Type Name Description
PowerLock type

The power type to request lock.

Examples
Copy
Tizen.System.Power.ReleaseLock(Tizen.System.Power.PowerLock.Cpu);
API Level: 5
View Source

RequestCpuLock(Int32)

[Obsolete("Please do not use! this will be deprecated")]

Declaration
C#
Copy
public static void RequestCpuLock(int timeout)
Parameters
Type Name Description
Int32 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.

API Level: 3
View Source

RequestLock(PowerLock, Int32)

Locks the given lock state for a specified time. After the given timeout (in milliseconds), unlock the given lock state automatically.

Declaration
C#
Copy
public static void RequestLock(PowerLock type, int timeout)
Parameters
Type Name Description
PowerLock type

The power type to request lock.

Int32 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 the process dies, then every lock will be removed.

Examples
Copy
Tizen.System.Power.RequestLock(Tizen.System.Power.PowerLock.Cpu, 2000);
API Level: 5

Events

View Source

CpuLockStateChangedCallback

CpuLockStateChangedCallback is triggered when the PowerLock.Cpu status is changed to Lock or Unlock

Declaration
C#
Copy
public static event EventHandler<PowerLockStateChangedEventArgs> CpuLockStateChangedCallback
Event Type
Type Description
EventHandler<PowerLockStateChangedEventArgs>
Examples
Copy
public static void PowerLockStateChangeCallback(object sender, PowerLockStateChangedEventArgs args) { PowerLock lock_type = args.PowerLockType; PowerLockState lock_state = args.PowerLockState; } Power.CpuLockStateChangedCallback += PowerLockStateChangeCallback;
API Level: 10
View Source

DisplayDimLockStateChangedCallback

DisplayDimLockStateChangedCallback is triggered when the PowerLock.DisplayDim status is changed to Lock or Unlock

Declaration
C#
Copy
public static event EventHandler<PowerLockStateChangedEventArgs> DisplayDimLockStateChangedCallback
Event Type
Type Description
EventHandler<PowerLockStateChangedEventArgs>
Examples
Copy
public static void PowerLockStateChangeCallback(object sender, PowerLockStateChangedEventArgs args) { PowerLock lock_type = args.PowerLockType; PowerLockState lock_state = args.PowerLockState; } Power.DisplayDimLockStateChangedCallback += PowerLockStateChangeCallback;
API Level: 10
View Source

DisplayNormalLockStateChangedCallback

DisplayNormalLockStateChangedCallback is triggered when the PowerLock.DisplayNormal status is changed to Lock or Unlock

Declaration
C#
Copy
public static event EventHandler<PowerLockStateChangedEventArgs> DisplayNormalLockStateChangedCallback
Event Type
Type Description
EventHandler<PowerLockStateChangedEventArgs>
Examples
Copy
public static void PowerLockStateChangeCallback(object sender, PowerLockStateChangedEventArgs args) { PowerLock lock_type = args.PowerLockType; PowerLockState lock_state = args.PowerLockState; } Power.DisplayNormalLockStateChangedCallback += PowerLockStateChangeCallback;
API Level: 10
View Source

ExitStateChangeRequestCallback

ExitStateChangeRequestCallback is triggered when the request to change to Exit power state is handled from deviced.

Declaration
C#
Copy
public static event EventHandler<PowerStateChangeRequestEventArgs> ExitStateChangeRequestCallback
Event Type
Type Description
EventHandler<PowerStateChangeRequestEventArgs>
Examples
Copy
public static void PowerStateChangeRequestCallback(object sender, PowerStateChangeRequestEventArgs args) { PowerState power_state = args.PowerState; int retval = args.Retval; } Power.ExitStateChangeRequestCallback += PowerStateChangeRequestCallback;
API Level: 10
View Source

ExitStateWaitCallback

ExitStateWaitCallback is triggered when the Power state changes to Exit.

Declaration
C#
Copy
public static event EventHandler<PowerStateWaitEventArgs> ExitStateWaitCallback
Event Type
Type Description
EventHandler<PowerStateWaitEventArgs>
Examples
Copy
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;
API Level: 10
View Source

NormalStateChangeRequestCallback

NormalStateChangeRequestCallback is triggered when the request to change to Normal power state is handled from deviced.

Declaration
C#
Copy
public static event EventHandler<PowerStateChangeRequestEventArgs> NormalStateChangeRequestCallback
Event Type
Type Description
EventHandler<PowerStateChangeRequestEventArgs>
Examples
Copy
public static void PowerStateChangeRequestCallback(object sender, PowerStateChangeRequestEventArgs args) { PowerState power_state = args.PowerState; int retval = args.Retval; } Power.NormalStateChangeRequestCallback += PowerStateChangeRequestCallback;
API Level: 10
View Source

NormalStateWaitCallback

NormalStateWaitCallback is triggered when the Power state changes to Normal.

Declaration
C#
Copy
public static event EventHandler<PowerStateWaitEventArgs> NormalStateWaitCallback
Event Type
Type Description
EventHandler<PowerStateWaitEventArgs>
Examples
Copy
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;
API Level: 10
View Source

PoweroffStateChangeRequestCallback

PoweroffStateChangeRequestCallback is triggered when the request to change to Poweroff power state is handled from deviced.

Declaration
C#
Copy
public static event EventHandler<PowerStateChangeRequestEventArgs> PoweroffStateChangeRequestCallback
Event Type
Type Description
EventHandler<PowerStateChangeRequestEventArgs>
Examples
Copy
public static void PowerStateChangeRequestCallback(object sender, PowerStateChangeRequestEventArgs args) { PowerState power_state = args.PowerState; int retval = args.Retval; } Power.PoweroffStateChangeRequestCallback += PowerStateChangeRequestCallback;
API Level: 10
View Source

PoweroffStateWaitCallback

PoweroffStateWaitCallback is triggered when the Power state changes to Poweroff.

Declaration
C#
Copy
public static event EventHandler<PowerStateWaitEventArgs> PoweroffStateWaitCallback
Event Type
Type Description
EventHandler<PowerStateWaitEventArgs>
Examples
Copy
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;
API Level: 10
View Source

RebootStateChangeRequestCallback

RebootStateChangeRequestCallback is triggered when the request to change to Reboot power state is handled from deviced.

Declaration
C#
Copy
public static event EventHandler<PowerStateChangeRequestEventArgs> RebootStateChangeRequestCallback
Event Type
Type Description
EventHandler<PowerStateChangeRequestEventArgs>
Examples
Copy
public static void PowerStateChangeRequestCallback(object sender, PowerStateChangeRequestEventArgs args) { PowerState power_state = args.PowerState; int retval = args.Retval; } Power.RebootStateChangeRequestCallback += PowerStateChangeRequestCallback;
API Level: 10
View Source

RebootStateWaitCallback

RebootStateWaitCallback is triggered when the Power state changes to Reboot.

Declaration
C#
Copy
public static event EventHandler<PowerStateWaitEventArgs> RebootStateWaitCallback
Event Type
Type Description
EventHandler<PowerStateWaitEventArgs>
Examples
Copy
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;
API Level: 10
View Source

SleepStateChangeRequestCallback

SleepStateChangeRequestCallback is triggered when the request to change to Sleep power state is handled from deviced.

Declaration
C#
Copy
public static event EventHandler<PowerStateChangeRequestEventArgs> SleepStateChangeRequestCallback
Event Type
Type Description
EventHandler<PowerStateChangeRequestEventArgs>
Examples
Copy
public static void PowerStateChangeRequestCallback(object sender, PowerStateChangeRequestEventArgs args) { PowerState power_state = args.PowerState; int retval = args.Retval; } Power.SleepStateChangeRequestCallback += PowerStateChangeRequestCallback;
API Level: 10
View Source

SleepStateWaitCallback

SleepStateWaitCallback is triggered when the Power state changes to Sleep.

Declaration
C#
Copy
public static event EventHandler<PowerStateWaitEventArgs> SleepStateWaitCallback
Event Type
Type Description
EventHandler<PowerStateWaitEventArgs>
Examples
Copy
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;
API Level: 10
View Source

StartStateChangeRequestCallback

StartStateChangeRequestCallback is triggered when the request to change to Start power state is handled from deviced.

Declaration
C#
Copy
public static event EventHandler<PowerStateChangeRequestEventArgs> StartStateChangeRequestCallback
Event Type
Type Description
EventHandler<PowerStateChangeRequestEventArgs>
Examples
Copy
public static void PowerStateChangeRequestCallback(object sender, PowerStateChangeRequestEventArgs args) { PowerState power_state = args.PowerState; int retval = args.Retval; } Power.StartStateChangeRequestCallback += PowerStateChangeRequestCallback;
API Level: 10
View Source

StartStateWaitCallback

StartStateWaitCallback is triggered when the Power state changes to Start.

Declaration
C#
Copy
public static event EventHandler<PowerStateWaitEventArgs> StartStateWaitCallback
Event Type
Type Description
EventHandler<PowerStateWaitEventArgs>
Examples
Copy
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;
API Level: 10
View Source

TransientResumingEarlyStateWaitCallback

TransientResumingEarlyStateWaitCallback is triggered when the Power transient state changes to ResumingEarly.

Declaration
C#
Copy
public static event EventHandler<PowerTransientStateWaitEventArgs> TransientResumingEarlyStateWaitCallback
Event Type
Type Description
EventHandler<PowerTransientStateWaitEventArgs>
Examples
Copy
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;
API Level: 10
View Source

TransientResumingLateStateWaitCallback

TransientResumingLateStateWaitCallback is triggered when the Power transient state changes to ResumingLate.

Declaration
C#
Copy
public static event EventHandler<PowerTransientStateWaitEventArgs> TransientResumingLateStateWaitCallback
Event Type
Type Description
EventHandler<PowerTransientStateWaitEventArgs>
Examples
Copy
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;
API Level: 10
View Source

TransientResumingStateWaitCallback

TransientResumingStateWaitCallback is triggered when the Power transient state changes to Resuming.

Declaration
C#
Copy
public static event EventHandler<PowerTransientStateWaitEventArgs> TransientResumingStateWaitCallback
Event Type
Type Description
EventHandler<PowerTransientStateWaitEventArgs>
Examples
Copy
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;
API Level: 10
View Source

TransientSuspendingEarlyStateWaitCallback

TransientSuspendingEarlyStateWaitCallback is triggered when the Power transient state changes to SuspendingEarly.

Declaration
C#
Copy
public static event EventHandler<PowerTransientStateWaitEventArgs> TransientSuspendingEarlyStateWaitCallback
Event Type
Type Description
EventHandler<PowerTransientStateWaitEventArgs>
Examples
Copy
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;
API Level: 10
View Source

TransientSuspendingLateStateWaitCallback

TransientSuspendingLateStateWaitCallback is triggered when the Power transient state changes to SuspendingLate.

Declaration
C#
Copy
public static event EventHandler<PowerTransientStateWaitEventArgs> TransientSuspendingLateStateWaitCallback
Event Type
Type Description
EventHandler<PowerTransientStateWaitEventArgs>
Examples
Copy
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;
API Level: 10
View Source

TransientSuspendingStateWaitCallback

TransientSuspendingStateWaitCallback is triggered when the Power transient state changes to Suspending.

Declaration
C#
Copy
public static event EventHandler<PowerTransientStateWaitEventArgs> TransientSuspendingStateWaitCallback
Event Type
Type Description
EventHandler<PowerTransientStateWaitEventArgs>
Examples
Copy
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;
API Level: 10