From 69f48e567f1a758dcf5f6cb979b7682de7e83d2a Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 8 Feb 2017 13:59:51 +0900 Subject: [PATCH] Add new property to get app state Change-Id: I379eadf81c9666726e7bb762b8b3d128d31aa873 Signed-off-by: Hwankyu Jhun --- .../Interop/Interop.ApplicationManager.cs | 4 ++ .../Tizen.Applications/ApplicationInfo.cs | 64 ++++++++++++++++++++++ 2 files changed, 68 insertions(+) mode change 100755 => 100644 src/Tizen.Applications.Common/Interop/Interop.ApplicationManager.cs mode change 100755 => 100644 src/Tizen.Applications.Common/Tizen.Applications/ApplicationInfo.cs diff --git a/src/Tizen.Applications.Common/Interop/Interop.ApplicationManager.cs b/src/Tizen.Applications.Common/Interop/Interop.ApplicationManager.cs old mode 100755 new mode 100644 index ec2d291..a2637fd --- a/src/Tizen.Applications.Common/Interop/Interop.ApplicationManager.cs +++ b/src/Tizen.Applications.Common/Interop/Interop.ApplicationManager.cs @@ -129,6 +129,10 @@ internal static partial class Interop internal static extern ErrorCode AppContextGetPid(IntPtr handle, out int processId); //int app_context_get_pid (app_context_h app_context, pid_t *pid) + [DllImport(Libraries.AppManager, EntryPoint = "app_context_get_app_state")] + internal static extern ErrorCode AppContextGetAppState(IntPtr handle, out int state); + //int app_context_get_app_state (app_context_h app_context, app_state_e *state) + [DllImport(Libraries.AppManager, EntryPoint = "app_context_is_terminated")] internal static extern ErrorCode AppContextIsTerminated(IntPtr handle, out bool terminated); //int app_context_is_terminated (app_context_h app_context, bool *terminated); diff --git a/src/Tizen.Applications.Common/Tizen.Applications/ApplicationInfo.cs b/src/Tizen.Applications.Common/Tizen.Applications/ApplicationInfo.cs old mode 100755 new mode 100644 index 31e9774..1c4858c --- a/src/Tizen.Applications.Common/Tizen.Applications/ApplicationInfo.cs +++ b/src/Tizen.Applications.Common/Tizen.Applications/ApplicationInfo.cs @@ -53,6 +53,37 @@ namespace Tizen.Applications } /// + /// Enumeration for the Application State. + /// + public enum AppState + { + /// + /// The undefined state + /// + Undefined = 0, + + /// + /// The UI application is running in the foreground. + /// + Foreground, + + /// + /// The UI application is running in the background. + /// + Background, + + /// + /// The Service application is running. + /// + Service, + + /// + /// The application is terminated. + /// + Terminated, + } + + /// /// Gets the application id. /// public string ApplicationId @@ -409,6 +440,39 @@ namespace Tizen.Applications return label; } + /// + /// Gets the state of the application. + /// + public AppState State + { + get + { + int value = 0; + IntPtr contextHandle = IntPtr.Zero; + try + { + err = Interop.ApplicationManager.AppManagerGetAppContext(ApplicationId, out contextHandle); + if (err != Interop.ApplicationManager.ErrorCode.None) + { + Log.Warn(LogTag, "Failed to get the context handle. err = " + err); + } + err = Interop.ApplicationManager.AppContextGetAppState(contextHandle, out value); + if (err != Interop.ApplicationManager.ErrorCode.None) + { + Log.Warn(LogTag, "Failed to get the app state. err = " + err); + } + } + finally + { + if (contextHandle != IntPtr.Zero) + { + Interop.ApplicationManager.AppContextDestroy(contextHandle); + } + } + return (AppState)value; + } + } + private IntPtr GetInfoHandle() { if (_infoHandle == IntPtr.Zero) -- 2.7.4