-/// Copyright 2016 by Samsung Electronics, Inc.,
-///
-/// This software is the confidential and proprietary information
-/// of Samsung Electronics, Inc. ("Confidential Information"). You
-/// shall not disclose such Confidential Information and shall use
-/// it only in accordance with the terms of the license agreement
-/// you entered into with Samsung.
-
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+// Copyright 2016 by Samsung Electronics, Inc.,
+//
+// This software is the confidential and proprietary information
+// of Samsung Electronics, Inc. ("Confidential Information"). You
+// shall not disclose such Confidential Information and shall use
+// it only in accordance with the terms of the license agreement
+// you entered into with Samsung.
internal static partial class Interop
{
internal static partial class Libraries
{
- public const string RuntimeInfo = "libcapi-system-runtime-info.so.0";
+ internal const string RuntimeInfo = "libcapi-system-runtime-info.so.0";
+ internal const string SystemInfo = "libcapi-system-info.so.0";
}
}
--- /dev/null
+// Copyright 2016 by Samsung Electronics, Inc.,
+//
+// This software is the confidential and proprietary information
+// of Samsung Electronics, Inc. ("Confidential Information"). You
+// shall not disclose such Confidential Information and shall use
+// it only in accordance with the terms of the license agreement
+// you entered into with Samsung.
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+ internal static partial class SystemInfo
+ {
+ 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,
+ PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
+ NotSupported = Tizen.Internals.Errors.ErrorCode.NoSuchDevice,
+ }
+
+ internal enum SystemInfoValueType
+ {
+ Bool = 0,
+ Int = 1,
+ Double = 2,
+ String = 3,
+ }
+
+ internal enum SystemInfoType
+ {
+ platform,
+ Custom,
+ None,
+ }
+
+ [DllImport(Libraries.SystemInfo, EntryPoint = "system_info_get_platform_type")]
+ internal static extern ErrorCode SystemInfoGetPlatformType(string key, out SystemInfoValueType type);
+
+ [DllImport(Libraries.SystemInfo, EntryPoint = "system_info_get_custom_type")]
+ internal static extern ErrorCode SystemInfoGetCustomType(string key, out SystemInfoValueType type);
+
+ [DllImport(Libraries.SystemInfo, EntryPoint = "system_info_get_platform_bool")]
+ internal static extern ErrorCode SystemInfoGetPlatformBool(string key, out bool value);
+
+ [DllImport(Libraries.SystemInfo, EntryPoint = "system_info_get_platform_int")]
+ internal static extern ErrorCode SystemInfoGetPlatformInt(string key, out int value);
+
+ [DllImport(Libraries.SystemInfo, EntryPoint = "system_info_get_platform_double")]
+ internal static extern ErrorCode SystemInfoGetPlatformDouble(string key, out double value);
+
+ [DllImport(Libraries.SystemInfo, EntryPoint = "system_info_get_platform_string")]
+ internal static extern ErrorCode SystemInfoGetPlatformString(string key, out string value);
+
+ [DllImport(Libraries.SystemInfo, EntryPoint = "system_info_get_custom_bool")]
+ internal static extern ErrorCode SystemInfoGetCustomBool(string key, out bool value);
+
+ [DllImport(Libraries.SystemInfo, EntryPoint = "system_info_get_custom_int")]
+ internal static extern ErrorCode SystemInfoGetCustomInt(string key, out int value);
+
+ [DllImport(Libraries.SystemInfo, EntryPoint = "system_info_get_custom_double")]
+ internal static extern ErrorCode SystemInfoGetCustomDouble(string key, out double value);
+
+ [DllImport(Libraries.SystemInfo, EntryPoint = "system_info_get_custom_string")]
+ internal static extern ErrorCode SystemInfoGetCustomString(string key, out string value);
+ }
+}
--- /dev/null
+// Copyright 2016 by Samsung Electronics, Inc.,
+//
+// This software is the confidential and proprietary information
+// of Samsung Electronics, Inc. ("Confidential Information"). You
+// shall not disclose such Confidential Information and shall use
+// it only in accordance with the terms of the license agreement
+// you entered into with Samsung.
+
+using System;
+
+namespace Tizen.System.SystemInfo
+{
+ /// <summary>
+ /// System Information class. This class has methods which can be used to obtain device information
+ /// </summary>
+ public static class SystemInfo
+ {
+ private const string LogTag = "Tizen.System";
+
+ private static Interop.SystemInfo.SystemInfoType GetValueType(string key, out Interop.SystemInfo.SystemInfoValueType valueType)
+ {
+ Interop.SystemInfo.ErrorCode err = Interop.SystemInfo.SystemInfoGetPlatformType(key, out valueType);
+ if (err == Interop.SystemInfo.ErrorCode.None)
+ {
+ return Interop.SystemInfo.SystemInfoType.platform;
+ }
+
+ Log.Debug(LogTag, string.Format("Key {0} not in platform system info", key));
+ err = Interop.SystemInfo.SystemInfoGetCustomType(key, out valueType);
+ if (err == Interop.SystemInfo.ErrorCode.None)
+ {
+ return Interop.SystemInfo.SystemInfoType.Custom;
+ }
+
+ Log.Debug(LogTag, string.Format("Key {0} not in custom system info", key));
+ return Interop.SystemInfo.SystemInfoType.None;
+ }
+
+ /// <summary>
+ /// Checks if type of value for given feature is T
+ /// </summary>
+ /// <typeparam name="T">Type of value for feature key</typeparam>
+ /// <param name="key">The name of the feature</param>
+ /// <returns>true if type of value for given feature is T, false otherwise</returns>
+ public static bool Is<T>(string key)
+ {
+ Interop.SystemInfo.SystemInfoValueType valueType;
+ Interop.SystemInfo.SystemInfoType keyType = GetValueType(key, out valueType);
+ if (keyType == Interop.SystemInfo.SystemInfoType.None)
+ {
+ return false;
+ }
+
+ switch (valueType)
+ {
+ case Interop.SystemInfo.SystemInfoValueType.Bool:
+ return typeof(T) == typeof(bool);
+ case Interop.SystemInfo.SystemInfoValueType.Double:
+ return typeof(T) == typeof(double);
+ case Interop.SystemInfo.SystemInfoValueType.Int:
+ return typeof(T) == typeof(int);
+ case Interop.SystemInfo.SystemInfoValueType.String:
+ return typeof(T) == typeof(string);
+ }
+ return false;
+ }
+
+ /// <summary>
+ /// Checks if given key is valid feature
+ /// </summary>
+ /// <param name="key">The name of the feature</param>
+ /// <returns>true of key is valid, false otherwise</returns>
+ public static bool IsValidKey(string key)
+ {
+ Interop.SystemInfo.SystemInfoValueType valueType;
+ return GetValueType(key, out valueType) != Interop.SystemInfo.SystemInfoType.None;
+ }
+
+ /// <summary>
+ /// Gets the value of the feature.
+ /// </summary>
+ /// <typeparam name="T">Type of key value</typeparam>
+ /// <param name="key">The name of the feature</param>
+ /// <param name="value">The value of the given feature</param>
+ /// <returns>return true on success otherwise false</returns>
+ public static bool TryGetValue<T>(string key, out T value)
+ {
+ bool res = false;
+ if (typeof(T) == typeof(bool))
+ {
+ bool val;
+ res = TryGetValue(key, out val);
+ value = (T)(object)val;
+ }
+ else if (typeof(T) == typeof(int))
+ {
+ int val;
+ res = TryGetValue(key, out val);
+ value = (T)(object)val;
+ }
+ else if (typeof(T) == typeof(double))
+ {
+ double val;
+ res = TryGetValue(key, out val);
+ value = (T)(object)val;
+ }
+ else if (typeof(T) == typeof(string))
+ {
+ string val;
+ res = TryGetValue(key, out val);
+ value = (T)(object)val;
+ }
+ else
+ {
+ value = default(T);
+ }
+ return res;
+ }
+
+ /// <summary>
+ /// Gets the bool value of the feature.
+ /// </summary>
+ /// <param name="key">The name of the feature</param>
+ /// <param name="value">The value of the given feature</param>
+ /// <returns>return true on success otherwise false</returns>
+ public static bool TryGetValue(string key, out bool value)
+ {
+ Interop.SystemInfo.SystemInfoValueType valueType;
+ Interop.SystemInfo.SystemInfoType keyType = GetValueType(key, out valueType);
+
+ Interop.SystemInfo.ErrorCode err = Interop.SystemInfo.ErrorCode.InvalidParameter;
+ if (keyType == Interop.SystemInfo.SystemInfoType.platform)
+ {
+ err = Interop.SystemInfo.SystemInfoGetPlatformBool(key, out value);
+ }
+ else if (keyType == Interop.SystemInfo.SystemInfoType.Custom)
+ {
+ err = Interop.SystemInfo.SystemInfoGetCustomBool(key, out value);
+ } else
+ {
+ value = false;
+ }
+
+ if (err != Interop.SystemInfo.ErrorCode.None)
+ {
+ Log.Warn(LogTag, string.Format("Failed to get value for key: {0}. err = {1}", key, err));
+ return false;
+ }
+
+ return true;
+ }
+
+ /// <summary>
+ /// Gets the int value of the feature.
+ /// </summary>
+ /// <param name="key">The name of the feature</param>
+ /// <param name="value">The value of the given feature</param>
+ /// <returns>return true on success otherwise false</returns>
+ public static bool TryGetValue(string key, out int value)
+ {
+ Interop.SystemInfo.SystemInfoValueType valueType;
+ Interop.SystemInfo.SystemInfoType keyType = GetValueType(key, out valueType);
+
+ Interop.SystemInfo.ErrorCode err = Interop.SystemInfo.ErrorCode.InvalidParameter;
+ if (keyType == Interop.SystemInfo.SystemInfoType.platform)
+ {
+ err = Interop.SystemInfo.SystemInfoGetPlatformInt(key, out value);
+ }
+ else if (keyType == Interop.SystemInfo.SystemInfoType.Custom)
+ {
+ err = Interop.SystemInfo.SystemInfoGetCustomInt(key, out value);
+ }
+ else
+ {
+ value = 0;
+ }
+
+ if (err != Interop.SystemInfo.ErrorCode.None)
+ {
+ Log.Warn(LogTag, string.Format("Failed to get value for key: {0}. err = {1}", key, err));
+ return false;
+ }
+
+ return true;
+ }
+
+ /// <summary>
+ /// Gets the double value of the feature.
+ /// </summary>
+ /// <param name="key">The name of the feature</param>
+ /// <param name="value">The value of the given feature</param>
+ /// <returns>return true on success otherwise false</returns>
+ public static bool TryGetValue(string key, out double value)
+ {
+ Interop.SystemInfo.SystemInfoValueType valueType;
+ Interop.SystemInfo.SystemInfoType keyType = GetValueType(key, out valueType);
+
+ Interop.SystemInfo.ErrorCode err = Interop.SystemInfo.ErrorCode.InvalidParameter;
+ if (keyType == Interop.SystemInfo.SystemInfoType.platform)
+ {
+ err = Interop.SystemInfo.SystemInfoGetPlatformDouble(key, out value);
+ }
+ else if (keyType == Interop.SystemInfo.SystemInfoType.Custom)
+ {
+ err = Interop.SystemInfo.SystemInfoGetCustomDouble(key, out value);
+ }
+ else
+ {
+ value = 0;
+ }
+
+ if (err != Interop.SystemInfo.ErrorCode.None)
+ {
+ Log.Warn(LogTag, string.Format("Failed to get value for key: {0}. err = {1}", key, err));
+ return false;
+ }
+
+ return true;
+ }
+
+ /// <summary>
+ /// Gets the string value of the feature.
+ /// </summary>
+ /// <param name="key">The name of the feature</param>
+ /// <param name="value">The value of the given feature</param>
+ /// <returns>return true on success otherwise false</returns>
+ public static bool TryGetValue(string key, out string value)
+ {
+ Interop.SystemInfo.SystemInfoValueType valueType;
+ Interop.SystemInfo.SystemInfoType keyType = GetValueType(key, out valueType);
+
+ Interop.SystemInfo.ErrorCode err = Interop.SystemInfo.ErrorCode.InvalidParameter;
+ if (keyType == Interop.SystemInfo.SystemInfoType.platform)
+ {
+ err = Interop.SystemInfo.SystemInfoGetPlatformString(key, out value);
+ }
+ else if (keyType == Interop.SystemInfo.SystemInfoType.Custom)
+ {
+ err = Interop.SystemInfo.SystemInfoGetCustomString(key, out value);
+ }
+ else
+ {
+ value = string.Empty;
+ }
+
+ if (err != Interop.SystemInfo.ErrorCode.None)
+ {
+ Log.Warn(LogTag, string.Format("Failed to get value for key: {0}. err = {1}", key, err));
+ return false;
+ }
+
+ return true;
+ }
+ }
+}
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Tizen.System</RootNamespace>
<AssemblyName>Tizen.System</AssemblyName>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<ProductVersion>8.0.30703</ProductVersion>
<Compile Include="Interop\Interop.Device.cs" />
<Compile Include="Interop\Interop.RuntimeInfo.cs" />
<Compile Include="Interop\Interop.Libraries.cs" />
+ <Compile Include="Interop\Interop.SystemInfo.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RuntimeInfo\CpuUsage.cs" />
<Compile Include="RuntimeInfo\Enumerations.cs" />
<Compile Include="RuntimeInfo\RuntimeInformation.cs" />
<Compile Include="RuntimeInfo\RuntimeKeyStatusChangedEventArgs.cs" />
<Compile Include="RuntimeInfo\MemoryInformation.cs" />
+ <Compile Include="SystemInfo\SystemInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packaging\csapi-tizen.system.manifest" />
-%define dllpath %{_libdir}/mono/tizen
-%define dllname Tizen.System.dll
+%define BUILDCONF Debug
Name: csapi-tizen.system
Summary: Tizen System API for C#
# TODO: replace mono-compiler, mono-devel to mcs, mono-shlib-cop
BuildRequires: mono-compiler
BuildRequires: mono-devel
-# TODO: replace mono-core to gacutil.
-# mono-core should provide the symbol 'gacutil'
-Requires(post): mono-core
-Requires(postun): mono-core
# P/Invoke Dependencies
+BuildRequires: pkgconfig(csapi-tizen)
BuildRequires: pkgconfig(capi-system-device)
BuildRequires: pkgconfig(capi-system-runtime-info)
+BuildRequires: pkgconfig(capi-system-info)
# P/Invoke Runtime Dependencies
# TODO: It should be removed after fix tizen-rpm-config
+# DLL Dependencies
Requires: capi-system-device
Requires: capi-system-runtime-info
-# DLL Dependencies
+Requires: capi-system-info
#BuildRequires: ...
%description
cp %{SOURCE1} .
%build
-# build dll
-mcs -target:library -out:%{dllname} -keyfile:Tizen.System/Tizen.System.snk \
- Tizen.System/Properties/AssemblyInfo.cs \
- Tizen.System/System.cs \
- Tizen.System/Device/EventArgs.cs \
- Tizen.System/Device/Battery.cs \
- Tizen.System/Device/Display.cs \
- Tizen.System/Device/Haptic.cs \
- Tizen.System/Device/Led.cs \
- Tizen.System/Device/Power.cs \
- Tizen.System/Interop/Interop.Device.cs \
- Tizen.System/Interop/Interop.Libraries.cs \
- Tizen.System/Interop/Interop.RuntimeInfo.cs \
- Tizen.System/RuntimeInfo/CpuUsage.cs \
- Tizen.System/RuntimeInfo/Enumerations.cs \
- Tizen.System/RuntimeInfo/MemoryInformation.cs \
- Tizen.System/RuntimeInfo/RuntimeInfoErrorFactory.cs \
- Tizen.System/RuntimeInfo/RuntimeInformation.cs \
- Tizen.System/RuntimeInfo/RuntimeKeyStatusChangedEventArgs.cs
-
-# check p/invoke
-if [ -x %{dllname} ]; then
- RET=`mono-shlib-cop %{dllname}`; \
- CNT=`echo $RET | grep -E "^error:" | wc -l`; \
- if [ $CNT -gt 0 ]; then exit 1; fi
-fi
+xbuild Tizen.System/Tizen.System.csproj /p:Configuration=%{BUILDCONF}
%install
-# copy dll
-mkdir -p %{buildroot}%{dllpath}
-install -p -m 644 %{dllname} %{buildroot}%{dllpath}
+gacutil -i Tizen.System/bin/%{BUILDCONF}/*.dll -root "%{buildroot}%{_libdir}" -package tizen
# generate pkgconfig
mkdir -p %{buildroot}%{_libdir}/pkgconfig
-sed -e "s#@version@#%{version}#g" \
- -e "s#@dllpath@#%{dllpath}#g" \
- -e "s#@dllname@#%{dllname}#g" \
+sed -e "s#@name@#%{name}#g" \
+ -e "s#@version@#%{version}#g" \
+ -e "s#@libs@#%{pc_libs}#g" \
%{SOURCE2} > %{buildroot}%{_libdir}/pkgconfig/%{name}.pc
-%post
-gacutil -i %{dllpath}/%{dllname}
%files
-%{dllpath}/%{dllname}
+%{_libdir}/mono
%files devel
%{_libdir}/pkgconfig/%{name}.pc