From ba41e287e1efc9224cbb0d0fade5d3a8eaeabb4b Mon Sep 17 00:00:00 2001 From: hjhun <36876573+hjhun@users.noreply.github.com> Date: Tue, 24 May 2022 13:20:23 +0900 Subject: [PATCH] Add AppControl.SetAutoRestart method (#4280) Signed-off-by: Hwankyu Jhun --- .../Interop/Interop.AppControl.cs | 3 ++ .../Tizen.Applications/AppControl.cs | 40 ++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/src/Tizen.Applications.Common/Interop/Interop.AppControl.cs b/src/Tizen.Applications.Common/Interop/Interop.AppControl.cs index 6360dd9..ee60e6e 100755 --- a/src/Tizen.Applications.Common/Interop/Interop.AppControl.cs +++ b/src/Tizen.Applications.Common/Interop/Interop.AppControl.cs @@ -151,5 +151,8 @@ internal static partial class Interop [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_component_id")] internal static extern ErrorCode GetComponentId(SafeAppControlHandle handle, out string componentId); + + [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_auto_restart")] + internal static extern ErrorCode SetAutoRestart(SafeAppControlHandle handle); } } diff --git a/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs b/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs index 6c951fa..20ead07 100755 --- a/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs +++ b/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs @@ -16,6 +16,7 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Runtime.InteropServices; using System.Threading.Tasks; @@ -769,6 +770,45 @@ namespace Tizen.Applications } /// + /// Sets the auto restart. + /// + /// + /// The functionality of this method only applies to the caller application. + /// The auto restart cannot be applied to other applications. The application ID set in the AppControl is ignored. + /// This method is only available for platform level signed applications. + /// + /// The AppControl. + /// Thrown when the argument is null. + /// Thrown when the argument is invalid. + /// Thrown when the permission is denied. + /// Thrown when the memory is insufficient. + /// Thrown when the memory is insufficient. + [EditorBrowsable(EditorBrowsableState.Never)] + public static void SetAutoRestart(AppControl appControl) + { + if (appControl == null) + { + throw new ArgumentNullException(nameof(appControl)); + } + + Interop.AppControl.ErrorCode err = Interop.AppControl.SetAutoRestart(appControl.SafeAppControlHandle); + if (err != Interop.AppControl.ErrorCode.None) + { + switch (err) + { + case Interop.AppControl.ErrorCode.InvalidParameter: + throw new ArgumentException("Invalid arguments"); + case Interop.AppControl.ErrorCode.PermissionDenied: + throw new Exceptions.PermissionDeniedException("Permission denied"); + case Interop.AppControl.ErrorCode.OutOfMemory: + throw new Exceptions.OutOfMemoryException("Out of memory"); + default: + throw new InvalidOperationException("err = " + err); + } + } + } + + /// /// Class for extra data. /// /// 3 -- 2.7.4