diff options
author | Hwankyu Jhun <h.jhun@samsung.com> | 2017-08-02 10:04:24 +0900 |
---|---|---|
committer | HwanKyu Jhun <h.jhun@samsung.com> | 2017-08-02 05:39:33 +0000 |
commit | 4279fe970528374a4e3db7e1fd876b1498ac8d75 (patch) | |
tree | bcd2004dccc78674ffa8241d503bbf8f57476664 | |
parent | 6b651e625318a84946c3c1d0d3317226b8980c9a (diff) | |
download | application-4279fe970528374a4e3db7e1fd876b1498ac8d75.tar.gz application-4279fe970528374a4e3db7e1fd876b1498ac8d75.tar.bz2 application-4279fe970528374a4e3db7e1fd876b1498ac8d75.zip |
Support extension API
- Add internal constructor of the ApplicationRunninngContext
- Add internal API to terminate the running application
Change-Id: If3bb93a9ec37ea380067bc8176cca463e731b2da
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r--[-rwxr-xr-x] | Tizen.Applications.Common/Interop/Interop.ApplicationManager.cs | 8 | ||||
-rw-r--r-- | Tizen.Applications.Common/Tizen.Applications/ApplicationRunningContext.cs | 56 |
2 files changed, 64 insertions, 0 deletions
diff --git a/Tizen.Applications.Common/Interop/Interop.ApplicationManager.cs b/Tizen.Applications.Common/Interop/Interop.ApplicationManager.cs index 7326b7f..0879a32 100755..100644 --- a/Tizen.Applications.Common/Interop/Interop.ApplicationManager.cs +++ b/Tizen.Applications.Common/Interop/Interop.ApplicationManager.cs @@ -166,6 +166,14 @@ internal static partial class Interop internal static extern ErrorCode AppManagerEventDestroy(IntPtr handle); //int app_manager_event_destroy (app_manager_event_h handle); + [DllImport(Libraries.AppManager, EntryPoint = "app_manager_terminate_app")] + internal static extern ErrorCode AppManagerTerminateApp(IntPtr handle); + //int app_manager_terminate_app (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); + [DllImport(Libraries.AppManager, EntryPoint = "app_context_destroy")] internal static extern ErrorCode AppContextDestroy(IntPtr handle); //int app_context_destroy(app_context_h app_context) diff --git a/Tizen.Applications.Common/Tizen.Applications/ApplicationRunningContext.cs b/Tizen.Applications.Common/Tizen.Applications/ApplicationRunningContext.cs index 35d9223..0220424 100644 --- a/Tizen.Applications.Common/Tizen.Applications/ApplicationRunningContext.cs +++ b/Tizen.Applications.Common/Tizen.Applications/ApplicationRunningContext.cs @@ -16,6 +16,7 @@ using System; using System.Collections.Generic; +using System.ComponentModel; namespace Tizen.Applications { @@ -64,6 +65,37 @@ namespace Tizen.Applications } /// <summary> + /// A constructor of ApplicationRunningContext that takes the application id. + /// </summary> + /// <param name="applicationId">application id.</param> + /// <param name="instanceId">instance id.</param> + /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception> + /// <exception cref="InvalidOperationException">Thrown when failed because of application not exist error or system error.</exception> + /// <exception cref="OutOfMemoryException">Thrown when failed because of out of memory.</exception> + [EditorBrowsable(EditorBrowsableState.Never)] + public ApplicationRunningContext(string applicationId, string instanceId) + { + IntPtr contextHandle = IntPtr.Zero; + err = Interop.ApplicationManager.AppManagerGetAppContextByInstanceId(applicationId, instanceId, out contextHandle); + if (err != Interop.ApplicationManager.ErrorCode.None) + { + Log.Warn(LogTag, "Failed to get the handle of the ApplicationRunningContext. err = " + err); + switch (err) + { + case Interop.ApplicationManager.ErrorCode.InvalidParameter: + throw new ArgumentException("Invalid Parameter."); + case Interop.ApplicationManager.ErrorCode.NoSuchApp: + throw new InvalidOperationException("No such application."); + case Interop.ApplicationManager.ErrorCode.OutOfMemory: + throw new OutOfMemoryException("Out of memory"); + default: + throw new InvalidOperationException("Invalid Operation."); + } + } + _contextHandle = contextHandle; + } + + /// <summary> /// Destructor of the class /// </summary> ~ApplicationRunningContext() @@ -189,6 +221,30 @@ namespace Tizen.Applications } /// <summary> + /// Terminates the application. + /// </summary> + /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception> + /// <exception cref="InvalidOperationException">Thrown when failed because of permission denied or system error.</exception> + /// <privilege>http://tizen.org/privilege/appmanager.kill</privilege> + [EditorBrowsable(EditorBrowsableState.Never)] + public void Terminate() + { + err = Interop.ApplicationManager.AppManagerTerminateApp(_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 InvalidOperationException("Permission denied."); + default: + throw new InvalidOperationException("Invalid Operation."); + } + } + } + + /// <summary> /// Releases all resources used by the ApplicationRunningContext class. /// </summary> public void Dispose() |