From: hjhun <36876573+hjhun@users.noreply.github.com>
Date: Fri, 30 Aug 2019 06:34:30 +0000 (+0900)
Subject: [ComponentManager] Change namespace (#989)
X-Git-Tag: submit/tizen/20190831.005203~1^2
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0b6fcb1c983e8bfd9aa8b8d83432646951c687ce;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git
[ComponentManager] Change namespace (#989)
Namespace is changed to 'Tizen.Applications.ComponentBased'.
---
diff --git a/src/Tizen.Applications.ComponentBased.ComponentManager/Interop/Interop.ComponentManager.cs b/src/Tizen.Applications.ComponentBased.ComponentManager/Interop/Interop.ComponentManager.cs
new file mode 100755
index 000000000..0ca3c224c
--- /dev/null
+++ b/src/Tizen.Applications.ComponentBased.ComponentManager/Interop/Interop.ComponentManager.cs
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+ internal static partial class ComponentManager
+ {
+ internal enum ErrorCode
+ {
+ None = Tizen.Internals.Errors.ErrorCode.None,
+ InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
+ OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
+ IoError = Tizen.Internals.Errors.ErrorCode.IoError,
+ NoSuchComponent = -0x03040000 | 0x01,
+ DbFailed = -0x03040000 | 0x03,
+ InvalidApplication = -0x03040000 | 0x04,
+ NotRunning = -0x03040000 | 0x05,
+ LabelNotFound = -0x03040000 | 0x06,
+ PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied
+ }
+
+ internal enum ComponentInfoComponentType
+ {
+ Frame = 0,
+ Service = 1
+ }
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate bool ComponentManagerComponentContextCallback(IntPtr handle, IntPtr userData);
+ // bool (*component_manager_component_context_cb)(component_context_h handle, void *user_data);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate bool ComponentManagerComponentInfoCallback(IntPtr handle, IntPtr userData);
+ // bool (*component_manager_component_info_cb)(component_info_h handle, void *user_data);
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_foreach_component_context")]
+ internal static extern ErrorCode ComponentManagerForeachComponentContext(ComponentManagerComponentContextCallback callback, IntPtr userData);
+ // int component_manager_foreach_component_context(component_manager_component_context_cb callback, void *user_data)
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_foreach_component_info")]
+ internal static extern ErrorCode ComponentManagerForeachComponentInfo(ComponentManagerComponentInfoCallback callback, IntPtr userData);
+ // int component_manager_foreach_component_info(component_manager_component_info_cb callback, void *user_data)
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_get_component_context")]
+ internal static extern ErrorCode ComponentManagerGetComponentContext(string componentId, out IntPtr handle);
+ // int component_manager_get_component_context(const char *comp_id, component_context_h *handle);
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_get_component_info")]
+ internal static extern ErrorCode ComponentManagerGetComponentInfo(string componentId, out IntPtr handle);
+ // int component_manager_get_component_info(const char *comp_id, component_info_h *handle);
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_is_running")]
+ internal static extern ErrorCode ComponentManagerIsRunning(string componentId, out bool running);
+ // int component_manager_is_running(const char *appid, bool *running);
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_resume_component")]
+ internal static extern ErrorCode ComponentManagerResumeComponent(IntPtr handle);
+ // int component_manager_resume_component(component_context_h handle);
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_terminate_bg_component")]
+ internal static extern ErrorCode ComponentManagerTerminateBgComponent(IntPtr handle);
+ // int component_manager_terminate_bg_component (component_context_h handle);
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_pause_component")]
+ internal static extern ErrorCode ComponentManagerPauseComponent(IntPtr handle);
+ // int component_manager_pause_component(component_context_h handle);
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_terminate_component")]
+ internal static extern ErrorCode ComponentManagerTerminateComponent(IntPtr handle);
+ // int component_manager_terminate_component(component_context_h handle);
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_context_destroy")]
+ internal static extern ErrorCode ComponentContextDestroy(IntPtr handle);
+ // int component_context_destroy(component_context_h handle)
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_context_get_app_id")]
+ internal static extern ErrorCode ComponentContextGetAppId(IntPtr handle, out string applicationId);
+ // int component_context_get_app_id(component_context_h handle, char **app_id)
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_context_get_component_id")]
+ internal static extern ErrorCode ComponentContextGetComponentId(IntPtr handle, out string componentId);
+ // int component_context_get_component_id(component_context_h handle, char **component_id)
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_context_get_instance_id")]
+ internal static extern ErrorCode ComponentContextGetInstanceId(IntPtr handle, out string instanceId);
+ // int component_context_get_instance_id(component_context_h handle, char **instance_id)
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_context_get_component_state")]
+ internal static extern ErrorCode ComponentContextGetComponentState(IntPtr handle, out int state);
+ // int component_context_get_component_state(component_context_h handle, component_state_e *state)
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_context_is_terminated")]
+ internal static extern ErrorCode ComponentContextIsTerminated(IntPtr handle, out bool terminated);
+ // int component_context_is_terminated(component_context_h handle, bool *terminated);
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_context_is_subcomponent")]
+ internal static extern ErrorCode ComponentContextIsSubComponent(IntPtr handle, out bool is_subcomponent);
+ // int component_context_is_subcomponent(component_context_h handle, bool *is_subcomponent);
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_context_clone")]
+ internal static extern ErrorCode ComponentContextClone(out IntPtr destination, IntPtr source);
+ // int component_context_clone(component_context_h *clone, component_context_h handle);
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_create")]
+ internal static extern ErrorCode ComponentInfoCreate(string componentId, out IntPtr handle);
+ // int component_info_create(const char *component_id, component_info_h *handle);
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_destroy")]
+ internal static extern ErrorCode ComponentInfoDestroy(IntPtr handle);
+ // int component_info_destroy(component_info_h handle);
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_get_app_id")]
+ internal static extern ErrorCode ComponentInfoGetAppId(IntPtr handle, out string applicationId);
+ // int component_info_get_app_id(component_info_h handle, char **app_id);
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_get_component_id")]
+ internal static extern ErrorCode ComponentInfoGetComponentId(IntPtr handle, out string componentId);
+ // int component_info_get_component_id(component_info_h handle, char **component_id);
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_get_component_type")]
+ internal static extern ErrorCode ComponentInfoGetComponentType(IntPtr handle, out ComponentInfoComponentType type);
+ // int component_info_get_component_type(component_info_h handle, component_info_component_type_e *type);
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_is_icon_display")]
+ internal static extern ErrorCode ComponentInfoIsIconDisplay(IntPtr handle, out bool iconDisplay);
+ // int component_info_is_icon_display(component_info_h handle, bool *icon_display);
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_is_managed_by_task_manager")]
+ internal static extern ErrorCode ComponentInfoIsManagedByTaskManager(IntPtr handle, out bool managed);
+ // int component_info_is_managed_by_task_manager(component_info_h handle, bool *managed);
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_get_icon")]
+ internal static extern ErrorCode ComponentInfoGetIcon(IntPtr handle, out string icon);
+ // int component_info_get_icon(component_info_h handle, char **icon);
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_get_label")]
+ internal static extern ErrorCode ComponentInfoGetLabel(IntPtr handle, out string label);
+ // int component_info_get_label(component_info_h handle, char **label);
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_get_localized_label")]
+ internal static extern ErrorCode ComponentInfoGetLocalizedLabel(IntPtr handle, string locale, out string label);
+ // int component_info_get_localized_label(component_info_h handle, const char *locale, char **label);
+
+ [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_clone")]
+ internal static extern ErrorCode ComponentInfoClone(out IntPtr destination, IntPtr source);
+ // int component_info_clone(component_info_h *clone, component_info_h handle);
+ }
+}
diff --git a/src/Tizen.Applications.ComponentBased.ComponentManager/Interop/Interop.Libraries.cs b/src/Tizen.Applications.ComponentBased.ComponentManager/Interop/Interop.Libraries.cs
new file mode 100755
index 000000000..a793dd37b
--- /dev/null
+++ b/src/Tizen.Applications.ComponentBased.ComponentManager/Interop/Interop.Libraries.cs
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+internal static partial class Interop
+{
+ internal static partial class Libraries
+ {
+ public const string ComponentManager = "libcapi-appfw-component-manager.so.1";
+ }
+}
\ No newline at end of file
diff --git a/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications.ComponentBased.ComponentManager.csproj b/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications.ComponentBased.ComponentManager.csproj
new file mode 100755
index 000000000..4c51c4197
--- /dev/null
+++ b/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications.ComponentBased.ComponentManager.csproj
@@ -0,0 +1,12 @@
+
+
+
+ netstandard2.0
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications.ComponentBased.ComponentManager.sln b/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications.ComponentBased.ComponentManager.sln
new file mode 100755
index 000000000..aa76b61b6
--- /dev/null
+++ b/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications.ComponentBased.ComponentManager.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.28307.271
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Applications.ComponentBased.ComponentManager", "Tizen.Applications.ComponentBased.ComponentManager.csproj", "{0C733CDC-EE90-42CE-9083-87FC55EF91DA}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {0C733CDC-EE90-42CE-9083-87FC55EF91DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0C733CDC-EE90-42CE-9083-87FC55EF91DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0C733CDC-EE90-42CE-9083-87FC55EF91DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0C733CDC-EE90-42CE-9083-87FC55EF91DA}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {7166CBA3-05BB-413B-9DA4-5F0A408AFA36}
+ EndGlobalSection
+EndGlobal
diff --git a/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications/ComponentInfo.cs b/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications/ComponentInfo.cs
new file mode 100755
index 000000000..16805c4b0
--- /dev/null
+++ b/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications/ComponentInfo.cs
@@ -0,0 +1,260 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace Tizen.Applications.ComponentBased
+{
+ ///
+ /// This class provides methods and properties to get information of the component.
+ ///
+ /// 6
+ public class ComponentInfo : IDisposable
+ {
+ private const string LogTag = "Tizen.Applications";
+ private bool _disposed = false;
+ private IntPtr _infoHandle = IntPtr.Zero;
+ private string _componentId = string.Empty;
+
+ internal ComponentInfo(IntPtr infoHandle)
+ {
+ Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentInfoGetComponentId(infoHandle, out _componentId);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ throw ComponentManager.ComponentManagerErrorFactory.GetException(err, "Invalid native handle.");
+ }
+ _infoHandle = infoHandle;
+ }
+
+ ///
+ /// A constructor of ComponentInfo that takes the component ID.
+ ///
+ /// Component ID.
+ /// Thrown when failed because of an invalid argument.
+ /// Thrown when failed because of the system error.
+ /// Thrown when failed because of out of memory.
+ /// Thrown when failed because of permission denied.>
+ /// http://tizen.org/privilege/packagemanager.info
+ /// 6
+ public ComponentInfo(string componentId)
+ {
+ _componentId = componentId;
+ IntPtr infoHandle = IntPtr.Zero;
+ Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentInfoCreate(_componentId, out infoHandle);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ throw ComponentManager.ComponentManagerErrorFactory.GetException(err, "Failed to create the ComponentInfo.");
+ }
+ _infoHandle = infoHandle;
+ }
+
+ ///
+ /// Destructor of the class.
+ ///
+ ~ComponentInfo()
+ {
+ Dispose(false);
+ }
+
+ ///
+ /// Gets the component ID.
+ ///
+ /// 6
+ public string ComponentId
+ {
+ get
+ {
+ if (!string.IsNullOrEmpty(_componentId))
+ return _componentId;
+
+ string compId = string.Empty;
+ Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentInfoGetComponentId(_infoHandle, out compId);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ Log.Warn(LogTag, "Failed to get the ComponentId. err = " + err);
+ }
+ _componentId = compId;
+
+ return _componentId;
+ }
+ }
+
+ ///
+ /// Gets the application ID of the component.
+ ///
+ /// 6
+ public string ApplicationId
+ {
+ get
+ {
+ string appId = string.Empty;
+ Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentInfoGetAppId(_infoHandle, out appId);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ Log.Warn(LogTag, "Failed to get the ApplicationId of " + _componentId + ". err = " + err);
+ }
+
+ return appId;
+ }
+ }
+
+ ///
+ /// Gets the type of the component.
+ ///
+ /// 6
+ public ComponentType ComponentType
+ {
+ get
+ {
+ Interop.ComponentManager.ComponentInfoComponentType type = 0;
+ Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentInfoGetComponentType(_infoHandle, out type);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ Log.Warn(LogTag, "Failed to get the Type of " + _componentId + ". err = " + err);
+ }
+
+ return (ComponentType)type;
+ }
+ }
+
+ ///
+ /// Checks whether the icon of the component should be displayed or not.
+ ///
+ /// 6
+ public bool IsIconDisplayed
+ {
+ get
+ {
+ bool iconDisplay = false;
+ Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentInfoIsIconDisplay(_infoHandle, out iconDisplay);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ Log.Warn(LogTag, "Failed to get the IsIconDisplay of " + _componentId + ". err = " + err);
+ }
+
+ return iconDisplay;
+ }
+ }
+
+ ///
+ /// Checks whether the component should be managed by task-manager or not.
+ ///
+ /// 6
+ public bool IsManagedByTaskManager
+ {
+ get
+ {
+ bool managed = false;
+ Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentInfoIsManagedByTaskManager(_infoHandle, out managed);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ Log.Warn(LogTag, "Failed to get the IsManagedByTaskManager of " + _componentId + ". err = " + err);
+ }
+
+ return managed;
+ }
+ }
+
+ ///
+ /// Gets the absolute path of the icon image.
+ ///
+ /// 6
+ public string IconPath
+ {
+ get
+ {
+ string path = string.Empty;
+ Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentInfoGetIcon(_infoHandle, out path);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ Log.Warn(LogTag, "Failed to get the IconPath of " + _componentId + ". err = " + err);
+ }
+
+ return path;
+ }
+ }
+
+ ///
+ /// Gets the label of the component.
+ ///
+ public string Label
+ {
+ get
+ {
+ string label = string.Empty;
+ Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentInfoGetLabel(_infoHandle, out label);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ Log.Warn(LogTag, "Failed to get the Label of " + _componentId + ". err = " + err);
+ }
+
+ return label;
+ }
+ }
+
+ ///
+ /// Gets the localized label of the component for the given locale.
+ ///
+ /// Locale.
+ /// The format of locale is language and country code. (available value: "[2-letter lowercase language code (ISO 639-1)]-[2-letter lowercase country code (ISO 3166-alpha-2)]")
+ /// The localized label.
+ /// 6
+ public string GetLocalizedLabel(string locale)
+ {
+ string label = string.Empty;
+ Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentInfoGetLocalizedLabel(_infoHandle, locale, out label);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ Log.Warn(LogTag, "Failed to get the GetLocalizedLabel of " + _componentId + ". err = " + err);
+ label = Label;
+ }
+ return label;
+ }
+
+ ///
+ /// Releases all resources used by the ComponentInfo class.
+ ///
+ /// 6
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ ///
+ /// Releases all resources used by the ComponentInfo class.
+ ///
+ /// Disposing
+ /// 6
+ private void Dispose(bool disposing)
+ {
+ if (_disposed)
+ return;
+
+ if (disposing)
+ {
+ }
+
+ if (_infoHandle != IntPtr.Zero)
+ {
+ Interop.ComponentManager.ComponentInfoDestroy(_infoHandle);
+ _infoHandle = IntPtr.Zero;
+ }
+ _disposed = true;
+ }
+ }
+}
diff --git a/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications/ComponentManager.cs b/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications/ComponentManager.cs
new file mode 100755
index 000000000..1654e7230
--- /dev/null
+++ b/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications/ComponentManager.cs
@@ -0,0 +1,186 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+using System.Threading.Tasks;
+
+namespace Tizen.Applications.ComponentBased
+{
+ ///
+ /// This class has the methods and events of the ComponentManager.
+ ///
+ /// 6
+ public static class ComponentManager
+ {
+ private const string LogTag = "Tizen.Applications";
+
+ ///
+ /// Gets the information of the installed components asynchronously.
+ ///
+ /// The installed component info list.
+ /// Thrown when failed because of an invalid argument.
+ /// Thrown when failed because of the "component not exist" error or the system error.
+ /// Thrown when failed because of out of memory.
+ /// Thrown when failed because of permission denied.
+ /// http://tizen.org/privilege/packagemanager.info
+ /// 6
+ public static async Task> GetInstalledComponentsAsync()
+ {
+ return await Task.Run(() =>
+ {
+ Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ErrorCode.None;
+ List result = new List();
+
+ Interop.ComponentManager.ComponentManagerComponentInfoCallback cb = (IntPtr infoHandle, IntPtr userData) =>
+ {
+ if (infoHandle != IntPtr.Zero)
+ {
+ IntPtr clonedHandle = IntPtr.Zero;
+ err = Interop.ComponentManager.ComponentInfoClone(out clonedHandle, infoHandle);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ Log.Warn(LogTag, "Failed to clone the ComponentInfo. err = " + err);
+ return false;
+ }
+ ComponentInfo info = new ComponentInfo(clonedHandle);
+ result.Add(info);
+ return true;
+ }
+ return false;
+ };
+ err = Interop.ComponentManager.ComponentManagerForeachComponentInfo(cb, IntPtr.Zero);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ throw ComponentManagerErrorFactory.GetException(err, "Failed to retrieve the component info.");
+ }
+ return result;
+ }).ConfigureAwait(false);
+ }
+
+ ///
+ /// Gets the information of the running components asynchronously.
+ ///
+ /// The component running context list.
+ /// Thrown when failed because of an invalid argument.
+ /// Thrown when failed because of the "component not exist" error or the system error.
+ /// Thrown when failed because of out of memory.
+ /// Thrown when failed because of permission denied.
+ /// http://tizen.org/privilege/packagemanager.info
+ /// 6
+ public static async Task> GetRunningComponentsAsync()
+ {
+ return await Task.Run(() =>
+ {
+ Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ErrorCode.None;
+ List result = new List();
+
+ Interop.ComponentManager.ComponentManagerComponentContextCallback cb = (IntPtr contextHandle, IntPtr userData) =>
+ {
+ if (contextHandle != IntPtr.Zero)
+ {
+ IntPtr clonedHandle = IntPtr.Zero;
+ err = Interop.ComponentManager.ComponentContextClone(out clonedHandle, contextHandle);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ Log.Warn(LogTag, "Failed to clone the ComponentInfo. err = " + err);
+ return false;
+ }
+ ComponentRunningContext context = new ComponentRunningContext(clonedHandle);
+ result.Add(context);
+ return true;
+ }
+ return false;
+ };
+ err = Interop.ComponentManager.ComponentManagerForeachComponentContext(cb, IntPtr.Zero);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ throw ComponentManagerErrorFactory.GetException(err, "Failed to retrieve the running component context.");
+ }
+ return result;
+ }).ConfigureAwait(false);
+ }
+
+ ///
+ /// Checks whether the component is running or not.
+ ///
+ /// Component ID.
+ /// Returns true if the component is running, otherwise false.
+ /// Thrown when failed because of an invalid argument.
+ /// Thrown when failed because of the "component not exist" error or the system error.
+ /// Thrown when failed because of out of memory.
+ /// Thrown when failed because of permission denied.
+ /// http://tizen.org/privilege/packagemanager.info
+ /// 6
+ public static bool IsRunning(string componentId)
+ {
+ bool isRunning = false;
+ Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentManagerIsRunning(componentId, out isRunning);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ throw ComponentManagerErrorFactory.GetException(err, "Failed to check the IsRunning of " + componentId + ".");
+ }
+ return isRunning;
+ }
+
+ ///
+ /// Terminates the component if it is running in the background.
+ ///
+ /// Component ID
+ /// Thrown when failed because of an invalid argument.
+ /// Thrown when failed because of the "component not exist" error or the system error.
+ /// Thrown when failed because of out of memory.
+ /// Thrown when failed because of permission denied.
+ /// http://tizen.org/privilege/appmanager.kill.bgapp
+ ///
+ /// This function returns after it just sends a request for terminating a background component.
+ /// Platform will decide if the target component could be terminated or not according to the state of the target component.
+ ///
+ /// 6
+ public static void TerminateBackgroundComponent(ComponentRunningContext context)
+ {
+ Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentManagerTerminateBgComponent(context._contextHandle);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ throw ComponentManagerErrorFactory.GetException(err, "Failed to send the terminate request.");
+ }
+ }
+
+ internal static class ComponentManagerErrorFactory
+ {
+ internal static Exception GetException(Interop.ComponentManager.ErrorCode err, string message)
+ {
+ string errMessage = string.Format("{0} err = {1}", message, err);
+ switch (err)
+ {
+ case Interop.ComponentManager.ErrorCode.InvalidParameter:
+ case Interop.ComponentManager.ErrorCode.NoSuchComponent:
+ return new ArgumentException(errMessage);
+ case Interop.ComponentManager.ErrorCode.PermissionDenied:
+ return new UnauthorizedAccessException(errMessage);
+ case Interop.ComponentManager.ErrorCode.IoError:
+ return new global::System.IO.IOException(errMessage);
+ case Interop.ComponentManager.ErrorCode.OutOfMemory:
+ return new OutOfMemoryException(errMessage);
+ default:
+ return new InvalidOperationException(errMessage);
+ }
+ }
+ }
+ }
+}
diff --git a/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications/ComponentRunningContext.cs b/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications/ComponentRunningContext.cs
new file mode 100755
index 000000000..493292208
--- /dev/null
+++ b/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications/ComponentRunningContext.cs
@@ -0,0 +1,314 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+using System.Threading.Tasks;
+
+namespace Tizen.Applications.ComponentBased
+{
+ ///
+ /// This class provides methods and properties to get information of the running component.
+ ///
+ /// 6
+ public class ComponentRunningContext : IDisposable
+ {
+ private const string LogTag = "Tizen.Applications";
+ private bool _disposed = false;
+ internal IntPtr _contextHandle = IntPtr.Zero;
+ private string _componentId = string.Empty;
+
+ internal ComponentRunningContext(IntPtr contextHandle)
+ {
+ _contextHandle = contextHandle;
+ }
+
+ ///
+ /// A constructor of ComponentRunningContext that takes the component ID.
+ ///
+ /// Component ID.
+ /// Thrown when failed because of an invalid argument.
+ /// Thrown when failed because of the "component not exist" error or the system error.
+ /// Thrown when failed because of out of memory.
+ /// Thrown when failed because of permission denied.
+ /// http://tizen.org/privilege/packagemanager.info
+ /// 6
+ public ComponentRunningContext(string componentId)
+ {
+ _componentId = componentId;
+ IntPtr contextHandle = IntPtr.Zero;
+ Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentManagerGetComponentContext(_componentId, out contextHandle);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ throw ComponentManager.ComponentManagerErrorFactory.GetException(err, "Failed to create the ComponentRunningContext of " + _componentId + ".");
+ }
+ _contextHandle = contextHandle;
+ }
+
+ ///
+ /// Destructor of the class.
+ ///
+ ~ComponentRunningContext()
+ {
+ Dispose(false);
+ }
+
+ ///
+ /// Enumeration for the component state.
+ ///
+ /// 6
+ public enum ComponentState
+ {
+ ///
+ /// The Initialized state. This is the state when the component is constructed but OnCreate() is not called yet.
+ ///
+ Initialized = 0,
+
+ ///
+ /// The created state. This state is reached after OnCreate() is called.
+ ///
+ Created,
+
+ ///
+ /// The started state. This state is reached after OnStart() or OnStartCommand() is called.
+ ///
+ Started,
+
+ ///
+ /// The resumed state. This state is reached after OnResume() is called.
+ ///
+ Resumed,
+
+ ///
+ /// The paused state. This state is reached after OnPause() is called.
+ ///
+ Paused,
+
+ ///
+ /// The destroyed state. This state is reached right before OnDestroy() call.
+ ///
+ Destroyed
+ }
+
+ ///
+ /// Gets the ID of the component.
+ ///
+ /// 6
+ public string ComponentId
+ {
+ get
+ {
+ if (!string.IsNullOrEmpty(_componentId))
+ return _componentId;
+
+ string componentId = string.Empty;
+ Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentContextGetComponentId(_contextHandle, out componentId);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ Log.Warn(LogTag, "Failed to get the ComponentId. err = " + err);
+ }
+ _componentId = componentId;
+
+ return _componentId;
+ }
+ }
+
+ ///
+ /// Gets the application ID of the component.
+ ///
+ /// 6
+ public string ApplicationId
+ {
+ get
+ {
+ string appId = string.Empty;
+ Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentContextGetAppId(_contextHandle, out appId);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ Log.Warn(LogTag, "Failed to get the ApplicationId of " + _componentId + ". err = " + err);
+ }
+
+ return appId;
+ }
+ }
+
+ ///
+ /// Gets the instance ID of the component.
+ ///
+ /// 6
+ public string InstanceId
+ {
+ get
+ {
+ string instanceId = string.Empty;
+ Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentContextGetInstanceId(_contextHandle, out instanceId);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ Log.Warn(LogTag, "Failed to get the InstanceId of " + _componentId + ". err = " + err);
+ }
+
+ return instanceId;
+ }
+ }
+
+ ///
+ /// Gets the state of the component.
+ ///
+ /// 6
+ public ComponentState State
+ {
+ get
+ {
+ int state = 0;
+ Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentContextGetComponentState(_contextHandle, out state);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ Log.Warn(LogTag, "Failed to get the State of " + _componentId + ". err = " + err);
+ }
+
+ return (ComponentState)state;
+ }
+ }
+
+ ///
+ /// Checks whether the component is terminated or not.
+ ///
+ /// 6
+ public bool IsTerminated
+ {
+ get
+ {
+ bool isTerminated = false;
+ Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentContextIsTerminated(_contextHandle, out isTerminated);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ Log.Warn(LogTag, "Failed to get the IsTerminated of " + _componentId + ". err = " + err);
+ }
+
+ return isTerminated;
+ }
+ }
+
+ ///
+ /// Checks whether the component is running as sub component of the group.
+ ///
+ /// 6
+ public bool IsSubComponent
+ {
+ get
+ {
+ bool isSubComponent = false;
+ Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentContextIsSubComponent(_contextHandle, out isSubComponent);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ Log.Warn(LogTag, "Failed to get the IsSubComponent of " + _componentId + ". err = " + err);
+ }
+
+ return isSubComponent;
+ }
+ }
+
+ ///
+ /// Resumes the running component.
+ ///
+ /// Thrown when failed because of an invalid argument.
+ /// Thrown when failed because of the system error.
+ /// Thrown when failed because of out of memory.
+ /// Thrown when failed because of permission denied.
+ /// http://tizen.org/privilege/appmanager.launch
+ /// 6
+ public void Resume()
+ {
+ Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentManagerResumeComponent(_contextHandle);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ throw ComponentManager.ComponentManagerErrorFactory.GetException(err, "Failed to Send the resume request.");
+ }
+ }
+
+ ///
+ /// Pauses the running component.
+ ///
+ /// Thrown when failed because of an invalid argument.
+ /// Thrown when failed because of the system error.
+ /// Thrown when failed because of out of memory.
+ /// Thrown when failed because of permission denied.
+ /// http://tizen.org/privilege/appmanager.launch
+ /// 6
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Pause()
+ {
+ Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentManagerPauseComponent(_contextHandle);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ throw ComponentManager.ComponentManagerErrorFactory.GetException(err, "Failed to Send the pause request.");
+ }
+ }
+
+ ///
+ /// Terminates the running component.
+ ///
+ /// Thrown when failed because of an invalid argument.
+ /// Thrown when failed because of the system error.
+ /// Thrown when failed because of out of memory.
+ /// Thrown when failed because of permission denied.
+ /// http://tizen.org/privilege/appmanager.launch
+ /// 6
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Terminate()
+ {
+ Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentManagerTerminateComponent(_contextHandle);
+ if (err != Interop.ComponentManager.ErrorCode.None)
+ {
+ throw ComponentManager.ComponentManagerErrorFactory.GetException(err, "Failed to Send the terminate request.");
+ }
+ }
+
+ ///
+ /// Releases all resources used by the ComponentInfo class.
+ ///
+ /// 6
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ ///
+ /// Releases all resources used by the ComponentInfo class.
+ ///
+ /// Disposing
+ /// 6
+ private void Dispose(bool disposing)
+ {
+ if (_disposed)
+ return;
+
+ if (disposing)
+ {
+ }
+
+ if (_contextHandle != IntPtr.Zero)
+ {
+ Interop.ComponentManager.ComponentContextDestroy(_contextHandle);
+ _contextHandle = IntPtr.Zero;
+ }
+ _disposed = true;
+ }
+ }
+}
diff --git a/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications/ComponentType.cs b/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications/ComponentType.cs
new file mode 100755
index 000000000..38a13f8a0
--- /dev/null
+++ b/src/Tizen.Applications.ComponentBased.ComponentManager/Tizen.Applications/ComponentType.cs
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications.ComponentBased
+{
+ ///
+ /// Enumeration for component type.
+ ///
+ /// 6
+ public enum ComponentType
+ {
+ ///
+ /// Frame component
+ ///
+ Frame = 0,
+
+ ///
+ /// Service component
+ ///
+ Service = 1
+ }
+}
diff --git a/src/Tizen.Applications.ComponentManager/Interop/Interop.ComponentManager.cs b/src/Tizen.Applications.ComponentManager/Interop/Interop.ComponentManager.cs
deleted file mode 100755
index 0ca3c224c..000000000
--- a/src/Tizen.Applications.ComponentManager/Interop/Interop.ComponentManager.cs
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Runtime.InteropServices;
-
-internal static partial class Interop
-{
- internal static partial class ComponentManager
- {
- internal enum ErrorCode
- {
- None = Tizen.Internals.Errors.ErrorCode.None,
- InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
- OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
- IoError = Tizen.Internals.Errors.ErrorCode.IoError,
- NoSuchComponent = -0x03040000 | 0x01,
- DbFailed = -0x03040000 | 0x03,
- InvalidApplication = -0x03040000 | 0x04,
- NotRunning = -0x03040000 | 0x05,
- LabelNotFound = -0x03040000 | 0x06,
- PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied
- }
-
- internal enum ComponentInfoComponentType
- {
- Frame = 0,
- Service = 1
- }
-
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate bool ComponentManagerComponentContextCallback(IntPtr handle, IntPtr userData);
- // bool (*component_manager_component_context_cb)(component_context_h handle, void *user_data);
-
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate bool ComponentManagerComponentInfoCallback(IntPtr handle, IntPtr userData);
- // bool (*component_manager_component_info_cb)(component_info_h handle, void *user_data);
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_foreach_component_context")]
- internal static extern ErrorCode ComponentManagerForeachComponentContext(ComponentManagerComponentContextCallback callback, IntPtr userData);
- // int component_manager_foreach_component_context(component_manager_component_context_cb callback, void *user_data)
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_foreach_component_info")]
- internal static extern ErrorCode ComponentManagerForeachComponentInfo(ComponentManagerComponentInfoCallback callback, IntPtr userData);
- // int component_manager_foreach_component_info(component_manager_component_info_cb callback, void *user_data)
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_get_component_context")]
- internal static extern ErrorCode ComponentManagerGetComponentContext(string componentId, out IntPtr handle);
- // int component_manager_get_component_context(const char *comp_id, component_context_h *handle);
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_get_component_info")]
- internal static extern ErrorCode ComponentManagerGetComponentInfo(string componentId, out IntPtr handle);
- // int component_manager_get_component_info(const char *comp_id, component_info_h *handle);
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_is_running")]
- internal static extern ErrorCode ComponentManagerIsRunning(string componentId, out bool running);
- // int component_manager_is_running(const char *appid, bool *running);
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_resume_component")]
- internal static extern ErrorCode ComponentManagerResumeComponent(IntPtr handle);
- // int component_manager_resume_component(component_context_h handle);
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_terminate_bg_component")]
- internal static extern ErrorCode ComponentManagerTerminateBgComponent(IntPtr handle);
- // int component_manager_terminate_bg_component (component_context_h handle);
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_pause_component")]
- internal static extern ErrorCode ComponentManagerPauseComponent(IntPtr handle);
- // int component_manager_pause_component(component_context_h handle);
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_terminate_component")]
- internal static extern ErrorCode ComponentManagerTerminateComponent(IntPtr handle);
- // int component_manager_terminate_component(component_context_h handle);
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_context_destroy")]
- internal static extern ErrorCode ComponentContextDestroy(IntPtr handle);
- // int component_context_destroy(component_context_h handle)
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_context_get_app_id")]
- internal static extern ErrorCode ComponentContextGetAppId(IntPtr handle, out string applicationId);
- // int component_context_get_app_id(component_context_h handle, char **app_id)
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_context_get_component_id")]
- internal static extern ErrorCode ComponentContextGetComponentId(IntPtr handle, out string componentId);
- // int component_context_get_component_id(component_context_h handle, char **component_id)
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_context_get_instance_id")]
- internal static extern ErrorCode ComponentContextGetInstanceId(IntPtr handle, out string instanceId);
- // int component_context_get_instance_id(component_context_h handle, char **instance_id)
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_context_get_component_state")]
- internal static extern ErrorCode ComponentContextGetComponentState(IntPtr handle, out int state);
- // int component_context_get_component_state(component_context_h handle, component_state_e *state)
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_context_is_terminated")]
- internal static extern ErrorCode ComponentContextIsTerminated(IntPtr handle, out bool terminated);
- // int component_context_is_terminated(component_context_h handle, bool *terminated);
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_context_is_subcomponent")]
- internal static extern ErrorCode ComponentContextIsSubComponent(IntPtr handle, out bool is_subcomponent);
- // int component_context_is_subcomponent(component_context_h handle, bool *is_subcomponent);
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_context_clone")]
- internal static extern ErrorCode ComponentContextClone(out IntPtr destination, IntPtr source);
- // int component_context_clone(component_context_h *clone, component_context_h handle);
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_create")]
- internal static extern ErrorCode ComponentInfoCreate(string componentId, out IntPtr handle);
- // int component_info_create(const char *component_id, component_info_h *handle);
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_destroy")]
- internal static extern ErrorCode ComponentInfoDestroy(IntPtr handle);
- // int component_info_destroy(component_info_h handle);
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_get_app_id")]
- internal static extern ErrorCode ComponentInfoGetAppId(IntPtr handle, out string applicationId);
- // int component_info_get_app_id(component_info_h handle, char **app_id);
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_get_component_id")]
- internal static extern ErrorCode ComponentInfoGetComponentId(IntPtr handle, out string componentId);
- // int component_info_get_component_id(component_info_h handle, char **component_id);
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_get_component_type")]
- internal static extern ErrorCode ComponentInfoGetComponentType(IntPtr handle, out ComponentInfoComponentType type);
- // int component_info_get_component_type(component_info_h handle, component_info_component_type_e *type);
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_is_icon_display")]
- internal static extern ErrorCode ComponentInfoIsIconDisplay(IntPtr handle, out bool iconDisplay);
- // int component_info_is_icon_display(component_info_h handle, bool *icon_display);
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_is_managed_by_task_manager")]
- internal static extern ErrorCode ComponentInfoIsManagedByTaskManager(IntPtr handle, out bool managed);
- // int component_info_is_managed_by_task_manager(component_info_h handle, bool *managed);
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_get_icon")]
- internal static extern ErrorCode ComponentInfoGetIcon(IntPtr handle, out string icon);
- // int component_info_get_icon(component_info_h handle, char **icon);
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_get_label")]
- internal static extern ErrorCode ComponentInfoGetLabel(IntPtr handle, out string label);
- // int component_info_get_label(component_info_h handle, char **label);
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_get_localized_label")]
- internal static extern ErrorCode ComponentInfoGetLocalizedLabel(IntPtr handle, string locale, out string label);
- // int component_info_get_localized_label(component_info_h handle, const char *locale, char **label);
-
- [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_clone")]
- internal static extern ErrorCode ComponentInfoClone(out IntPtr destination, IntPtr source);
- // int component_info_clone(component_info_h *clone, component_info_h handle);
- }
-}
diff --git a/src/Tizen.Applications.ComponentManager/Interop/Interop.Libraries.cs b/src/Tizen.Applications.ComponentManager/Interop/Interop.Libraries.cs
deleted file mode 100755
index a793dd37b..000000000
--- a/src/Tizen.Applications.ComponentManager/Interop/Interop.Libraries.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-internal static partial class Interop
-{
- internal static partial class Libraries
- {
- public const string ComponentManager = "libcapi-appfw-component-manager.so.1";
- }
-}
\ No newline at end of file
diff --git a/src/Tizen.Applications.ComponentManager/Tizen.Applications.ComponentManager.csproj b/src/Tizen.Applications.ComponentManager/Tizen.Applications.ComponentManager.csproj
deleted file mode 100755
index 4c51c4197..000000000
--- a/src/Tizen.Applications.ComponentManager/Tizen.Applications.ComponentManager.csproj
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
- netstandard2.0
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Tizen.Applications.ComponentManager/Tizen.Applications.ComponentManager.sln b/src/Tizen.Applications.ComponentManager/Tizen.Applications.ComponentManager.sln
deleted file mode 100755
index ca87df51d..000000000
--- a/src/Tizen.Applications.ComponentManager/Tizen.Applications.ComponentManager.sln
+++ /dev/null
@@ -1,25 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.28307.271
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Applications.ComponentManager", "Tizen.Applications.ComponentManager.csproj", "{0C733CDC-EE90-42CE-9083-87FC55EF91DA}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {0C733CDC-EE90-42CE-9083-87FC55EF91DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {0C733CDC-EE90-42CE-9083-87FC55EF91DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {0C733CDC-EE90-42CE-9083-87FC55EF91DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {0C733CDC-EE90-42CE-9083-87FC55EF91DA}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {7166CBA3-05BB-413B-9DA4-5F0A408AFA36}
- EndGlobalSection
-EndGlobal
diff --git a/src/Tizen.Applications.ComponentManager/Tizen.Applications/ComponentInfo.cs b/src/Tizen.Applications.ComponentManager/Tizen.Applications/ComponentInfo.cs
deleted file mode 100755
index 31add2761..000000000
--- a/src/Tizen.Applications.ComponentManager/Tizen.Applications/ComponentInfo.cs
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-
-namespace Tizen.Applications
-{
- ///
- /// This class provides methods and properties to get information of the component.
- ///
- /// 6
- public class ComponentInfo : IDisposable
- {
- private const string LogTag = "Tizen.Applications";
- private bool _disposed = false;
- private IntPtr _infoHandle = IntPtr.Zero;
- private string _componentId = string.Empty;
-
- internal ComponentInfo(IntPtr infoHandle)
- {
- Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentInfoGetComponentId(infoHandle, out _componentId);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- throw ComponentManager.ComponentManagerErrorFactory.GetException(err, "Invalid native handle.");
- }
- _infoHandle = infoHandle;
- }
-
- ///
- /// A constructor of ComponentInfo that takes the component ID.
- ///
- /// Component ID.
- /// Thrown when failed because of an invalid argument.
- /// Thrown when failed because of the system error.
- /// Thrown when failed because of out of memory.
- /// Thrown when failed because of permission denied.>
- /// http://tizen.org/privilege/packagemanager.info
- /// 6
- public ComponentInfo(string componentId)
- {
- _componentId = componentId;
- IntPtr infoHandle = IntPtr.Zero;
- Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentInfoCreate(_componentId, out infoHandle);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- throw ComponentManager.ComponentManagerErrorFactory.GetException(err, "Failed to create the ComponentInfo.");
- }
- _infoHandle = infoHandle;
- }
-
- ///
- /// Destructor of the class.
- ///
- ~ComponentInfo()
- {
- Dispose(false);
- }
-
- ///
- /// Gets the component ID.
- ///
- /// 6
- public string ComponentId
- {
- get
- {
- if (!string.IsNullOrEmpty(_componentId))
- return _componentId;
-
- string compId = string.Empty;
- Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentInfoGetComponentId(_infoHandle, out compId);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- Log.Warn(LogTag, "Failed to get the ComponentId. err = " + err);
- }
- _componentId = compId;
-
- return _componentId;
- }
- }
-
- ///
- /// Gets the application ID of the component.
- ///
- /// 6
- public string ApplicationId
- {
- get
- {
- string appId = string.Empty;
- Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentInfoGetAppId(_infoHandle, out appId);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- Log.Warn(LogTag, "Failed to get the ApplicationId of " + _componentId + ". err = " + err);
- }
-
- return appId;
- }
- }
-
- ///
- /// Gets the type of the component.
- ///
- /// 6
- public ComponentType ComponentType
- {
- get
- {
- Interop.ComponentManager.ComponentInfoComponentType type = 0;
- Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentInfoGetComponentType(_infoHandle, out type);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- Log.Warn(LogTag, "Failed to get the Type of " + _componentId + ". err = " + err);
- }
-
- return (ComponentType)type;
- }
- }
-
- ///
- /// Checks whether the icon of the component should be displayed or not.
- ///
- /// 6
- public bool IsIconDisplayed
- {
- get
- {
- bool iconDisplay = false;
- Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentInfoIsIconDisplay(_infoHandle, out iconDisplay);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- Log.Warn(LogTag, "Failed to get the IsIconDisplay of " + _componentId + ". err = " + err);
- }
-
- return iconDisplay;
- }
- }
-
- ///
- /// Checks whether the component should be managed by task-manager or not.
- ///
- /// 6
- public bool IsManagedByTaskManager
- {
- get
- {
- bool managed = false;
- Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentInfoIsManagedByTaskManager(_infoHandle, out managed);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- Log.Warn(LogTag, "Failed to get the IsManagedByTaskManager of " + _componentId + ". err = " + err);
- }
-
- return managed;
- }
- }
-
- ///
- /// Gets the absolute path of the icon image.
- ///
- /// 6
- public string IconPath
- {
- get
- {
- string path = string.Empty;
- Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentInfoGetIcon(_infoHandle, out path);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- Log.Warn(LogTag, "Failed to get the IconPath of " + _componentId + ". err = " + err);
- }
-
- return path;
- }
- }
-
- ///
- /// Gets the label of the component.
- ///
- public string Label
- {
- get
- {
- string label = string.Empty;
- Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentInfoGetLabel(_infoHandle, out label);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- Log.Warn(LogTag, "Failed to get the Label of " + _componentId + ". err = " + err);
- }
-
- return label;
- }
- }
-
- ///
- /// Gets the localized label of the component for the given locale.
- ///
- /// Locale.
- /// The format of locale is language and country code. (available value: "[2-letter lowercase language code (ISO 639-1)]-[2-letter lowercase country code (ISO 3166-alpha-2)]")
- /// The localized label.
- /// 6
- public string GetLocalizedLabel(string locale)
- {
- string label = string.Empty;
- Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentInfoGetLocalizedLabel(_infoHandle, locale, out label);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- Log.Warn(LogTag, "Failed to get the GetLocalizedLabel of " + _componentId + ". err = " + err);
- label = Label;
- }
- return label;
- }
-
- ///
- /// Releases all resources used by the ComponentInfo class.
- ///
- /// 6
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- ///
- /// Releases all resources used by the ComponentInfo class.
- ///
- /// Disposing
- /// 6
- private void Dispose(bool disposing)
- {
- if (_disposed)
- return;
-
- if (disposing)
- {
- }
-
- if (_infoHandle != IntPtr.Zero)
- {
- Interop.ComponentManager.ComponentInfoDestroy(_infoHandle);
- _infoHandle = IntPtr.Zero;
- }
- _disposed = true;
- }
- }
-}
diff --git a/src/Tizen.Applications.ComponentManager/Tizen.Applications/ComponentManager.cs b/src/Tizen.Applications.ComponentManager/Tizen.Applications/ComponentManager.cs
deleted file mode 100755
index f37a90d05..000000000
--- a/src/Tizen.Applications.ComponentManager/Tizen.Applications/ComponentManager.cs
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Runtime.InteropServices;
-using System.Threading.Tasks;
-
-namespace Tizen.Applications
-{
- ///
- /// This class has the methods and events of the ComponentManager.
- ///
- /// 6
- public static class ComponentManager
- {
- private const string LogTag = "Tizen.Applications";
-
- ///
- /// Gets the information of the installed components asynchronously.
- ///
- /// The installed component info list.
- /// Thrown when failed because of an invalid argument.
- /// Thrown when failed because of the "component not exist" error or the system error.
- /// Thrown when failed because of out of memory.
- /// Thrown when failed because of permission denied.
- /// http://tizen.org/privilege/packagemanager.info
- /// 6
- public static async Task> GetInstalledComponentsAsync()
- {
- return await Task.Run(() =>
- {
- Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ErrorCode.None;
- List result = new List();
-
- Interop.ComponentManager.ComponentManagerComponentInfoCallback cb = (IntPtr infoHandle, IntPtr userData) =>
- {
- if (infoHandle != IntPtr.Zero)
- {
- IntPtr clonedHandle = IntPtr.Zero;
- err = Interop.ComponentManager.ComponentInfoClone(out clonedHandle, infoHandle);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- Log.Warn(LogTag, "Failed to clone the ComponentInfo. err = " + err);
- return false;
- }
- ComponentInfo info = new ComponentInfo(clonedHandle);
- result.Add(info);
- return true;
- }
- return false;
- };
- err = Interop.ComponentManager.ComponentManagerForeachComponentInfo(cb, IntPtr.Zero);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- throw ComponentManagerErrorFactory.GetException(err, "Failed to retrieve the component info.");
- }
- return result;
- }).ConfigureAwait(false);
- }
-
- ///
- /// Gets the information of the running components asynchronously.
- ///
- /// The component running context list.
- /// Thrown when failed because of an invalid argument.
- /// Thrown when failed because of the "component not exist" error or the system error.
- /// Thrown when failed because of out of memory.
- /// Thrown when failed because of permission denied.
- /// http://tizen.org/privilege/packagemanager.info
- /// 6
- public static async Task> GetRunningComponentsAsync()
- {
- return await Task.Run(() =>
- {
- Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ErrorCode.None;
- List result = new List();
-
- Interop.ComponentManager.ComponentManagerComponentContextCallback cb = (IntPtr contextHandle, IntPtr userData) =>
- {
- if (contextHandle != IntPtr.Zero)
- {
- IntPtr clonedHandle = IntPtr.Zero;
- err = Interop.ComponentManager.ComponentContextClone(out clonedHandle, contextHandle);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- Log.Warn(LogTag, "Failed to clone the ComponentInfo. err = " + err);
- return false;
- }
- ComponentRunningContext context = new ComponentRunningContext(clonedHandle);
- result.Add(context);
- return true;
- }
- return false;
- };
- err = Interop.ComponentManager.ComponentManagerForeachComponentContext(cb, IntPtr.Zero);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- throw ComponentManagerErrorFactory.GetException(err, "Failed to retrieve the running component context.");
- }
- return result;
- }).ConfigureAwait(false);
- }
-
- ///
- /// Checks whether the component is running or not.
- ///
- /// Component ID.
- /// Returns true if the component is running, otherwise false.
- /// Thrown when failed because of an invalid argument.
- /// Thrown when failed because of the "component not exist" error or the system error.
- /// Thrown when failed because of out of memory.
- /// Thrown when failed because of permission denied.
- /// http://tizen.org/privilege/packagemanager.info
- /// 6
- public static bool IsRunning(string componentId)
- {
- bool isRunning = false;
- Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentManagerIsRunning(componentId, out isRunning);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- throw ComponentManagerErrorFactory.GetException(err, "Failed to check the IsRunning of " + componentId + ".");
- }
- return isRunning;
- }
-
- ///
- /// Terminates the component if it is running in the background.
- ///
- /// Component ID
- /// Thrown when failed because of an invalid argument.
- /// Thrown when failed because of the "component not exist" error or the system error.
- /// Thrown when failed because of out of memory.
- /// Thrown when failed because of permission denied.
- /// http://tizen.org/privilege/appmanager.kill.bgapp
- ///
- /// This function returns after it just sends a request for terminating a background component.
- /// Platform will decide if the target component could be terminated or not according to the state of the target component.
- ///
- /// 6
- public static void TerminateBackgroundComponent(ComponentRunningContext context)
- {
- Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentManagerTerminateBgComponent(context._contextHandle);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- throw ComponentManagerErrorFactory.GetException(err, "Failed to send the terminate request.");
- }
- }
-
- internal static class ComponentManagerErrorFactory
- {
- internal static Exception GetException(Interop.ComponentManager.ErrorCode err, string message)
- {
- string errMessage = string.Format("{0} err = {1}", message, err);
- switch (err)
- {
- case Interop.ComponentManager.ErrorCode.InvalidParameter:
- case Interop.ComponentManager.ErrorCode.NoSuchComponent:
- return new ArgumentException(errMessage);
- case Interop.ComponentManager.ErrorCode.PermissionDenied:
- return new UnauthorizedAccessException(errMessage);
- case Interop.ComponentManager.ErrorCode.IoError:
- return new global::System.IO.IOException(errMessage);
- case Interop.ComponentManager.ErrorCode.OutOfMemory:
- return new OutOfMemoryException(errMessage);
- default:
- return new InvalidOperationException(errMessage);
- }
- }
- }
- }
-}
diff --git a/src/Tizen.Applications.ComponentManager/Tizen.Applications/ComponentRunningContext.cs b/src/Tizen.Applications.ComponentManager/Tizen.Applications/ComponentRunningContext.cs
deleted file mode 100755
index 57359483e..000000000
--- a/src/Tizen.Applications.ComponentManager/Tizen.Applications/ComponentRunningContext.cs
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Runtime.InteropServices;
-using System.Threading.Tasks;
-
-namespace Tizen.Applications
-{
- ///
- /// This class provides methods and properties to get information of the running component.
- ///
- /// 6
- public class ComponentRunningContext : IDisposable
- {
- private const string LogTag = "Tizen.Applications";
- private bool _disposed = false;
- internal IntPtr _contextHandle = IntPtr.Zero;
- private string _componentId = string.Empty;
-
- internal ComponentRunningContext(IntPtr contextHandle)
- {
- _contextHandle = contextHandle;
- }
-
- ///
- /// A constructor of ComponentRunningContext that takes the component ID.
- ///
- /// Component ID.
- /// Thrown when failed because of an invalid argument.
- /// Thrown when failed because of the "component not exist" error or the system error.
- /// Thrown when failed because of out of memory.
- /// Thrown when failed because of permission denied.
- /// http://tizen.org/privilege/packagemanager.info
- /// 6
- public ComponentRunningContext(string componentId)
- {
- _componentId = componentId;
- IntPtr contextHandle = IntPtr.Zero;
- Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentManagerGetComponentContext(_componentId, out contextHandle);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- throw ComponentManager.ComponentManagerErrorFactory.GetException(err, "Failed to create the ComponentRunningContext of " + _componentId + ".");
- }
- _contextHandle = contextHandle;
- }
-
- ///
- /// Destructor of the class.
- ///
- ~ComponentRunningContext()
- {
- Dispose(false);
- }
-
- ///
- /// Enumeration for the component state.
- ///
- /// 6
- public enum ComponentState
- {
- ///
- /// The Initialized state. This is the state when the component is constructed but OnCreate() is not called yet.
- ///
- Initialized = 0,
-
- ///
- /// The created state. This state is reached after OnCreate() is called.
- ///
- Created,
-
- ///
- /// The started state. This state is reached after OnStart() or OnStartCommand() is called.
- ///
- Started,
-
- ///
- /// The resumed state. This state is reached after OnResume() is called.
- ///
- Resumed,
-
- ///
- /// The paused state. This state is reached after OnPause() is called.
- ///
- Paused,
-
- ///
- /// The destroyed state. This state is reached right before OnDestroy() call.
- ///
- Destroyed
- }
-
- ///
- /// Gets the ID of the component.
- ///
- /// 6
- public string ComponentId
- {
- get
- {
- if (!string.IsNullOrEmpty(_componentId))
- return _componentId;
-
- string componentId = string.Empty;
- Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentContextGetComponentId(_contextHandle, out componentId);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- Log.Warn(LogTag, "Failed to get the ComponentId. err = " + err);
- }
- _componentId = componentId;
-
- return _componentId;
- }
- }
-
- ///
- /// Gets the application ID of the component.
- ///
- /// 6
- public string ApplicationId
- {
- get
- {
- string appId = string.Empty;
- Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentContextGetAppId(_contextHandle, out appId);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- Log.Warn(LogTag, "Failed to get the ApplicationId of " + _componentId + ". err = " + err);
- }
-
- return appId;
- }
- }
-
- ///
- /// Gets the instance ID of the component.
- ///
- /// 6
- public string InstanceId
- {
- get
- {
- string instanceId = string.Empty;
- Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentContextGetInstanceId(_contextHandle, out instanceId);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- Log.Warn(LogTag, "Failed to get the InstanceId of " + _componentId + ". err = " + err);
- }
-
- return instanceId;
- }
- }
-
- ///
- /// Gets the state of the component.
- ///
- /// 6
- public ComponentState State
- {
- get
- {
- int state = 0;
- Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentContextGetComponentState(_contextHandle, out state);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- Log.Warn(LogTag, "Failed to get the State of " + _componentId + ". err = " + err);
- }
-
- return (ComponentState)state;
- }
- }
-
- ///
- /// Checks whether the component is terminated or not.
- ///
- /// 6
- public bool IsTerminated
- {
- get
- {
- bool isTerminated = false;
- Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentContextIsTerminated(_contextHandle, out isTerminated);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- Log.Warn(LogTag, "Failed to get the IsTerminated of " + _componentId + ". err = " + err);
- }
-
- return isTerminated;
- }
- }
-
- ///
- /// Checks whether the component is running as sub component of the group.
- ///
- /// 6
- public bool IsSubComponent
- {
- get
- {
- bool isSubComponent = false;
- Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentContextIsSubComponent(_contextHandle, out isSubComponent);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- Log.Warn(LogTag, "Failed to get the IsSubComponent of " + _componentId + ". err = " + err);
- }
-
- return isSubComponent;
- }
- }
-
- ///
- /// Resumes the running component.
- ///
- /// Thrown when failed because of an invalid argument.
- /// Thrown when failed because of the system error.
- /// Thrown when failed because of out of memory.
- /// Thrown when failed because of permission denied.
- /// http://tizen.org/privilege/appmanager.launch
- /// 6
- public void Resume()
- {
- Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentManagerResumeComponent(_contextHandle);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- throw ComponentManager.ComponentManagerErrorFactory.GetException(err, "Failed to Send the resume request.");
- }
- }
-
- ///
- /// Pauses the running component.
- ///
- /// Thrown when failed because of an invalid argument.
- /// Thrown when failed because of the system error.
- /// Thrown when failed because of out of memory.
- /// Thrown when failed because of permission denied.
- /// http://tizen.org/privilege/appmanager.launch
- /// 6
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void Pause()
- {
- Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentManagerPauseComponent(_contextHandle);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- throw ComponentManager.ComponentManagerErrorFactory.GetException(err, "Failed to Send the pause request.");
- }
- }
-
- ///
- /// Terminates the running component.
- ///
- /// Thrown when failed because of an invalid argument.
- /// Thrown when failed because of the system error.
- /// Thrown when failed because of out of memory.
- /// Thrown when failed because of permission denied.
- /// http://tizen.org/privilege/appmanager.launch
- /// 6
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void Terminate()
- {
- Interop.ComponentManager.ErrorCode err = Interop.ComponentManager.ComponentManagerTerminateComponent(_contextHandle);
- if (err != Interop.ComponentManager.ErrorCode.None)
- {
- throw ComponentManager.ComponentManagerErrorFactory.GetException(err, "Failed to Send the terminate request.");
- }
- }
-
- ///
- /// Releases all resources used by the ComponentInfo class.
- ///
- /// 6
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- ///
- /// Releases all resources used by the ComponentInfo class.
- ///
- /// Disposing
- /// 6
- private void Dispose(bool disposing)
- {
- if (_disposed)
- return;
-
- if (disposing)
- {
- }
-
- if (_contextHandle != IntPtr.Zero)
- {
- Interop.ComponentManager.ComponentContextDestroy(_contextHandle);
- _contextHandle = IntPtr.Zero;
- }
- _disposed = true;
- }
- }
-}
diff --git a/src/Tizen.Applications.ComponentManager/Tizen.Applications/ComponentType.cs b/src/Tizen.Applications.ComponentManager/Tizen.Applications/ComponentType.cs
deleted file mode 100755
index 7306f095d..000000000
--- a/src/Tizen.Applications.ComponentManager/Tizen.Applications/ComponentType.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Tizen.Applications
-{
- ///
- /// Enumeration for component type.
- ///
- /// 6
- public enum ComponentType
- {
- ///
- /// Frame component
- ///
- Frame = 0,
-
- ///
- /// Service component
- ///
- Service = 1
- }
-}