[Applications.Common] Add a new internal API (#4625)
authorhjhun <36876573+hjhun@users.noreply.github.com>
Wed, 5 Oct 2022 23:17:56 +0000 (08:17 +0900)
committerGitHub <noreply@github.com>
Wed, 5 Oct 2022 23:17:56 +0000 (08:17 +0900)
To send the termination request without restarting, the method is added.

Adds:
 - ApplicationRunningContext.TerminateWithoutRestarting()

Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/Tizen.Applications.Common/Interop/Interop.ApplicationManager.cs
src/Tizen.Applications.Common/Tizen.Applications/ApplicationRunningContext.cs

index 6758ac1..e5af6ba 100755 (executable)
@@ -187,6 +187,10 @@ internal static partial class Interop
         internal static extern ErrorCode AppManagerTerminateApp(IntPtr handle);
         //int app_manager_terminate_app (app_context_h app_context);
 
+        [DllImport(Libraries.AppManager, EntryPoint = "app_manager_terminate_app_without_restarting")]
+        internal static extern ErrorCode AppManagerTerminateAppWithoutRestarting(IntPtr handle);
+        //int app_manager_terminate_app_without_restarting (app_context_h app_context);
+
         [DllImport(Libraries.AppManager, EntryPoint = "app_manager_get_app_context_by_instance_id")]
         internal static extern ErrorCode AppManagerGetAppContextByInstanceId(string applicationId, string instanceId, out IntPtr handle);
         //int app_manager_get_app_context_by_instance_id (const char *app_id, const char *instance_id, app_context_h *app_context);
index c7196e7..9c791e9 100755 (executable)
@@ -287,6 +287,32 @@ namespace Tizen.Applications
         }
 
         /// <summary>
+        /// Terminates the application without restarting.
+        /// </summary>
+        /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when failed because of permission denied.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when failed because of system error.</exception>
+        /// <privilege>http://tizen.org/privilege/appmanager.kill</privilege>
+        /// <since_tizen> 10 </since_tizen>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void TerminateWithoutRestarting()
+        {
+            err = Interop.ApplicationManager.AppManagerTerminateAppWithoutRestarting(_contextHandle);
+            if (err != Interop.ApplicationManager.ErrorCode.None)
+            {
+                switch (err)
+                {
+                    case Interop.ApplicationManager.ErrorCode.InvalidParameter:
+                        throw new ArgumentException("Invalid argument.");
+                    case Interop.ApplicationManager.ErrorCode.PermissionDenied:
+                        throw new UnauthorizedAccessException("Permission denied.");
+                    default:
+                        throw new InvalidOperationException("Invalid Operation.");
+                }
+            }
+        }
+
+        /// <summary>
         /// Resumes the running application.
         /// </summary>
         /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>