From 2a35598a15ec42a48febbf3626d07045db5923d1 Mon Sep 17 00:00:00 2001 From: "sung-su.kim" Date: Thu, 21 Apr 2016 15:31:52 +0900 Subject: [PATCH] Add shared directory info and public constructor - Add properties about shared directories - Add a public constructor that takes the application id Change-Id: I240218b7b2fff4f1d677f236ec75ba5d25a0fb01 --- .../Tizen.Applications/ApplicationInfo.cs | 145 +++++++++++++++++++-- 1 file changed, 132 insertions(+), 13 deletions(-) diff --git a/Tizen.Applications/Tizen.Applications/ApplicationInfo.cs b/Tizen.Applications/Tizen.Applications/ApplicationInfo.cs index 41c6dd5..bf1831f 100755 --- a/Tizen.Applications/Tizen.Applications/ApplicationInfo.cs +++ b/Tizen.Applications/Tizen.Applications/ApplicationInfo.cs @@ -19,7 +19,8 @@ namespace Tizen.Applications { private const string LogTag = "Tizen.Applications"; private bool _disposed = false; - private IntPtr _infoHandle; + private IntPtr _infoHandle = IntPtr.Zero; + private string _applicationId = string.Empty; internal ApplicationInfo(IntPtr infoHandle) { @@ -27,6 +28,15 @@ namespace Tizen.Applications } /// + /// A constructor of ApplicationInfo that takes the application id. + /// + /// application id. + public ApplicationInfo(string applicationId) + { + _applicationId = applicationId; + } + + /// /// Destructor of the class /// ~ApplicationInfo() @@ -41,8 +51,14 @@ namespace Tizen.Applications { get { + if (_applicationId != string.Empty) + return _applicationId; + IntPtr infoHandle = GetInfoHandle(); string appid = string.Empty; - Interop.ApplicationManager.AppInfoGetAppId(_infoHandle, out appid); + if (infoHandle != IntPtr.Zero) + { + Interop.ApplicationManager.AppInfoGetAppId(infoHandle, out appid); + } return appid; } } @@ -54,8 +70,12 @@ namespace Tizen.Applications { get { + IntPtr infoHandle = GetInfoHandle(); string packageid = string.Empty; - Interop.ApplicationManager.AppInfoGetPackage(_infoHandle, out packageid); + if (infoHandle != IntPtr.Zero) + { + Interop.ApplicationManager.AppInfoGetPackage(infoHandle, out packageid); + } return packageid; } } @@ -67,8 +87,12 @@ namespace Tizen.Applications { get { + IntPtr infoHandle = GetInfoHandle(); string label = string.Empty; - Interop.ApplicationManager.AppInfoGetLabel(_infoHandle, out label); + if (infoHandle != IntPtr.Zero) + { + Interop.ApplicationManager.AppInfoGetLabel(infoHandle, out label); + } return label; } } @@ -80,8 +104,12 @@ namespace Tizen.Applications { get { + IntPtr infoHandle = GetInfoHandle(); string exec = string.Empty; - Interop.ApplicationManager.AppInfoGetExec(_infoHandle, out exec); + if (infoHandle != IntPtr.Zero) + { + Interop.ApplicationManager.AppInfoGetExec(infoHandle, out exec); + } return exec; } } @@ -93,8 +121,12 @@ namespace Tizen.Applications { get { + IntPtr infoHandle = GetInfoHandle(); string path = string.Empty; - Interop.ApplicationManager.AppInfoGetIcon(_infoHandle, out path); + if (infoHandle != IntPtr.Zero) + { + Interop.ApplicationManager.AppInfoGetIcon(infoHandle, out path); + } return path; } } @@ -106,8 +138,12 @@ namespace Tizen.Applications { get { + IntPtr infoHandle = GetInfoHandle(); string type = string.Empty; - Interop.ApplicationManager.AppInfoGetType(_infoHandle, out type); + if (infoHandle != IntPtr.Zero) + { + Interop.ApplicationManager.AppInfoGetType(infoHandle, out type); + } return type; } } @@ -130,10 +166,14 @@ namespace Tizen.Applications return true; }; - Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.AppInfoForeachMetadata(_infoHandle, cb, IntPtr.Zero); - if (err != Interop.ApplicationManager.ErrorCode.None) + IntPtr infoHandle = GetInfoHandle(); + if (infoHandle != IntPtr.Zero) { - Log.Warn(LogTag, "Failed to get metadata of the application. err = " + err); + Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.AppInfoForeachMetadata(infoHandle, cb, IntPtr.Zero); + if (err != Interop.ApplicationManager.ErrorCode.None) + { + Log.Warn(LogTag, "Failed to get metadata of the application. err = " + err); + } } return metadata; } @@ -146,8 +186,12 @@ namespace Tizen.Applications { get { + IntPtr infoHandle = GetInfoHandle(); bool nodisplay = false; - Interop.ApplicationManager.AppInfoIsNodisplay(_infoHandle, out nodisplay); + if (infoHandle != IntPtr.Zero) + { + Interop.ApplicationManager.AppInfoIsNodisplay(infoHandle, out nodisplay); + } return nodisplay; } } @@ -159,8 +203,12 @@ namespace Tizen.Applications { get { + IntPtr infoHandle = GetInfoHandle(); bool onboot = false; - Interop.ApplicationManager.AppInfoIsOnBoot(_infoHandle, out onboot); + if (infoHandle != IntPtr.Zero) + { + Interop.ApplicationManager.AppInfoIsOnBoot(infoHandle, out onboot); + } return onboot; } } @@ -172,8 +220,12 @@ namespace Tizen.Applications { get { + IntPtr infoHandle = GetInfoHandle(); bool preloaded = false; - Interop.ApplicationManager.AppInfoIsPreLoad(_infoHandle, out preloaded); + if (infoHandle != IntPtr.Zero) + { + Interop.ApplicationManager.AppInfoIsPreLoad(infoHandle, out preloaded); + } return preloaded; } } @@ -217,6 +269,58 @@ namespace Tizen.Applications } /// + /// Gets the shared data path. + /// + public string SharedDataPath + { + get + { + string path = string.Empty; + Interop.ApplicationManager.AppManagerGetSharedDataPath(ApplicationId, out path); + return path; + } + } + + /// + /// Gets the shared resource path. + /// + public string SharedResourcePath + { + get + { + string path = string.Empty; + Interop.ApplicationManager.AppManagerGetSharedResourcePath(ApplicationId, out path); + return path; + } + } + + /// + /// Gets the shared trust path. + /// + public string SharedTrustedPath + { + get + { + string path = string.Empty; + Interop.ApplicationManager.AppManagerGetSharedTrustedPath(ApplicationId, out path); + return path; + } + } + + /// + /// Gets the external shared data path. + /// + public string ExternalSharedDataPath + { + get + { + string path = string.Empty; + Interop.ApplicationManager.AppManagerGetExternalSharedDataPath(ApplicationId, out path); + return path; + } + } + + /// /// Gets the localized label of application for the given locale. /// /// locale. @@ -227,6 +331,21 @@ namespace Tizen.Applications return label; } + private IntPtr GetInfoHandle() + { + if (_infoHandle == IntPtr.Zero) + { + IntPtr infoHandle = IntPtr.Zero; + Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.AppManagerGetAppInfo(_applicationId, out infoHandle); + if (err != Interop.ApplicationManager.ErrorCode.None) + { + Log.Warn(LogTag, "Failed to get ApplicationInfo handle."); + } + _infoHandle = infoHandle; + } + return _infoHandle; + } + /// /// Releases all resources used by the ApplicationInfo class. /// -- 2.7.4