From: newb1e-kim Date: Wed, 9 Apr 2025 04:54:09 +0000 (+0900) Subject: [Applications.Common] Add internal API to toggle watchdog X-Git-Tag: submit/tizen/20250409.151045~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c899ea0432fae7760512a4cd6e778821b0b1c893;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [Applications.Common] Add internal API to toggle watchdog Add internal APIs to handling watchdog timer Implement WatchdogTimer, for application to request related operation --- diff --git a/src/Tizen.Applications.Common/Interop/Interop.AppCommon.cs b/src/Tizen.Applications.Common/Interop/Interop.AppCommon.cs index c620853a8..5b86d6ab4 100644 --- a/src/Tizen.Applications.Common/Interop/Interop.AppCommon.cs +++ b/src/Tizen.Applications.Common/Interop/Interop.AppCommon.cs @@ -113,6 +113,15 @@ internal static partial class Interop [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_time_zone")] internal static extern ErrorCode AppEventGetTimeZone(IntPtr handle, out string timeZone, out string timeZoneId); + + [DllImport(Libraries.AppCommon, EntryPoint = "app_watchdog_timer_enable")] + internal static extern AppCommonErrorCode AppWatchdogTimerEnable(); + + [DllImport(Libraries.AppCommon, EntryPoint = "app_watchdog_timer_disable")] + internal static extern AppCommonErrorCode AppWatchdogTimerDisable(); + + [DllImport(Libraries.AppCommon, EntryPoint = "app_watchdog_timer_kick")] + internal static extern AppCommonErrorCode AppWatchdogTimerKick(); } } diff --git a/src/Tizen.Applications.Common/Tizen.Applications/WatchdogTimer.cs b/src/Tizen.Applications.Common/Tizen.Applications/WatchdogTimer.cs new file mode 100644 index 000000000..50d84ab61 --- /dev/null +++ b/src/Tizen.Applications.Common/Tizen.Applications/WatchdogTimer.cs @@ -0,0 +1,72 @@ +using System; +using System.ComponentModel; + +namespace Tizen.Applications +{ + /// + /// A class to send request about watchdog timer. + /// + /// + /// This class provides functionality for managing watchdog timer of caller. + /// An application can toggle watchdog timer of itself. + /// + /// 13 + [EditorBrowsable(EditorBrowsableState.Never)] + public static class WatchdogTimer + { + /// + /// Sends a disable request to deactivate the watchdog timer. + /// + /// + /// After this function is called, the system doesn't detect a timeout error. + /// If the running application has to process a lot of operations, the application should disable or reset the watchdog timer. + /// Trying to disable watchdog timer already disabled will generate error. + /// + /// Invalid watchdog context + /// 13 + public static void Disable() + { + Interop.AppCommon.AppCommonErrorCode err = Interop.AppCommon.AppWatchdogTimerDisable(); + if (err == Interop.AppCommon.AppCommonErrorCode.InvalidContext) + { + throw new InvalidOperationException("Invalid watchdog context"); + } + return; + } + + /// + /// Sends an enable request to activate the watchdog timer. + /// + /// + /// After this function is called, the system detects a timeout error. + /// If, due to a program error as ANR (Application Not Responding), the system fails to reset the watchdog, + /// the timer will elapse and generate a signal to terminate the running application. + /// + /// Invalid watchdog context + /// 13 + public static void Enable() + { + Interop.AppCommon.AppCommonErrorCode err = Interop.AppCommon.AppWatchdogTimerEnable(); + if (err == Interop.AppCommon.AppCommonErrorCode.InvalidContext) + { + throw new InvalidOperationException("Invalid watchdog context"); + } + return; + } + + /// + /// Sends a kick request to the watchdog timer. + /// + /// Invalid watchdog context + /// 13 + public static void Kick() + { + Interop.AppCommon.AppCommonErrorCode err = Interop.AppCommon.AppWatchdogTimerKick(); + if (err == Interop.AppCommon.AppCommonErrorCode.InvalidContext) + { + throw new InvalidOperationException("Invalid watchdog context"); + } + return; + } + } +}