[System] Add power internal APIs
authorYunhee Seo <yuni.seo@samsung.com>
Thu, 2 Nov 2023 12:53:34 +0000 (21:53 +0900)
committerChanwoo Choi <chanwoo@kernel.org>
Wed, 8 Nov 2023 00:41:04 +0000 (09:41 +0900)
commit852f167d77b55b6bcec514c558de05e238dc5227
treeadc9481564131800bbbe3af63afd97c5e611a4bf
parent15302150c47ae1921abc5026224995706a6a84c5
[System] Add power internal APIs

Allows using native power internal APIs.

These are newly added to System/Device/Power
- public static void ConfirmWaitCallback(UInt64 wait_callback_id)
-> It informs the deviced that it is okay to take actual action to change state.
- public static void CancelWaitCallback(UInt64 wait_callback_id)
-> It informs the deviced of that it needs to undo the current transition.
- public static int ChangeState(PowerState state, int timeout_sec)
-> It Sends a request for changing power state asynchronously with timeout sec.
- public static int CheckRebootAllowed()
-> It checks if reboot is possible on the current device state.
- public static PowerTransitionReason GetWakeupReason()
-> It returns power wake up reason.
- public static PowerLockState GetLockState(PowerLock type)
-> It returns the status of power lock(locked/unlocked).

To notify callback event, 4 types EventHandler is added.
- public static event EventHandler<PowerStateChangeRequestEventArgs> StartStateChangeRequestCallback
- public static event EventHandler<PowerStateChangeRequestEventArgs> NormalStateChangeRequestCallback
- public static event EventHandler<PowerStateChangeRequestEventArgs> SleepStateChangeRequestCallback
- public static event EventHandler<PowerStateChangeRequestEventArgs> PoweroffStateChangeRequestCallback
- public static event EventHandler<PowerStateChangeRequestEventArgs> RebootStateChangeRequestCallback
- public static event EventHandler<PowerStateChangeRequestEventArgs> ExitStateChangeRequestCallback
-> With this eventhandler, it is possible to get event from ChangeState handling.
For example,
1. Add callback event to NormalStateChangeRequestCallback.
2. Request power state change with ChangeState(PowerState.Normal, timeout_sec)
3. After power state change request done, it returns result as invoke callback event.

- public static event EventHandler<PowerStateWaitEventArgs> StartStateWaitCallback
- public static event EventHandler<PowerStateWaitEventArgs> NormalStateWaitCallback
- public static event EventHandler<PowerStateWaitEventArgs> SleepStateWaitCallback
- public static event EventHandler<PowerStateWaitEventArgs> PoweroffStateWaitCallback
- public static event EventHandler<PowerStateWaitEventArgs> RebootStateWaitCallback
- public static event EventHandler<PowerStateWaitEventArgs> ExitStateWaitCallback
-> As adding event callback to above eventhandler, it is possible to get event
    when the power state changes to Specific Power state.
For example,
1. Add callback event to SleepStateWaitCallback.
2. When the power state changes to Sleep state, callback event will be invoked.

- public static event EventHandler<PowerTransientStateWaitEventArgs> TransientResumingEarlyStateWaitCallback
- public static event EventHandler<PowerTransientStateWaitEventArgs> TransientResumingStateWaitCallback
- public static event EventHandler<PowerTransientStateWaitEventArgs> TransientResumingLateStateWaitCallback
- public static event EventHandler<PowerTransientStateWaitEventArgs> TransientSuspendingEarlyStateWaitCallback
- public static event EventHandler<PowerTransientStateWaitEventArgs> TransientSuspendingStateWaitCallback
- public static event EventHandler<PowerTransientStateWaitEventArgs> TransientSuspendingLateStateWaitCallback
-> As adding event callback to above eventhandler, it is possible to get event
    during the power transition.
For example,
1. Add callback event to TransientResumingLateStateWaitCallback.
2. When the power transient state changes to ResumingLate state, callback event will be invoked.

- public static event EventHandler<PowerLockStateChangedEventArgs> CpuLockStateChangedCallback
- public static event EventHandler<PowerLockStateChangedEventArgs> DisplayNormalLockStateChangedCallback
- public static event EventHandler<PowerLockStateChangedEventArgs> DisplayDimLockStateChangedCallback
-> As adding event callback to above eventhandler, it is possible to get event
    when the power lock state is changed.
For example,
1. Add callback event to DisplayNormalLockStateChangedCallback.
2. When the DisplayNormal power lock state is changed, callback event will be invoked.

To use new APIs, below enumeration is also added.
- public enum PowerTransitionReason
-> It represents power transition reason
- public enum PowerState : uint
-> It represents power state.
- public enum PowerTransientState : uint
-> It represents power transient state.
- public enum PowerLockState
-> It represents power lock state locked or unlocked.

Detailed example, information is added to API/EventHandler/Enumeration definition.

Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
src/Tizen.System/Device/DeviceEventArgs.cs
src/Tizen.System/Device/Power.cs
src/Tizen.System/Interop/Interop.Device.cs