From: Yunhee Seo Date: Wed, 8 Nov 2023 07:07:00 +0000 (+0900) Subject: [System.Feedback] Add internal API to support get ids X-Git-Tag: submit/tizen_8.0/20231115.091119~1^2~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0e9428bc1467072bb514453681d75a6485addfa6;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [System.Feedback] Add internal API to support get ids Allows getting feedback theme id array supported. This is newly added to System.Feedback. - public uint[] GetThemeIdsInternal(FeedbackType type) -> It returns the available id array defined in the conf file according to feedback type. Signed-off-by: Yunhee Seo --- diff --git a/src/Tizen.System.Feedback/Feedback/Feedback.cs b/src/Tizen.System.Feedback/Feedback/Feedback.cs index fc5a8aec2..6365ea0c8 100755 --- a/src/Tizen.System.Feedback/Feedback/Feedback.cs +++ b/src/Tizen.System.Feedback/Feedback/Feedback.cs @@ -17,6 +17,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using System.Runtime.InteropServices; namespace Tizen.System @@ -731,5 +732,61 @@ namespace Tizen.System } } } + + /// + /// Gets the id array of theme supported. + /// + /// + /// Now this internal API works for FeedbackType.Sound only, FeedbackType.Vibration is not supported. + /// The theme id is positive value as defined in the conf file. + /// + /// 10 + /// The feedback type. + /// The array of theme id supported according to feedback type. + /// Thrown when failed because of an invalid arguament. + /// Thrown when failed becuase the device (haptic, sound) is not supported. + /// Thrown when failed because of a system error. + /// + /// + /// Feedback feedback = new Feedback(); + /// uint[] getThemeIds = feedback.GetThemeIdsInternal(FeedbackType.Sound); + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public uint[] GetThemeIdsInternal(FeedbackType type) + { + uint countOfTheme = 0; + IntPtr getThemeIds; + Interop.Feedback.FeedbackError res; + + res = (Interop.Feedback.FeedbackError)Interop.Feedback.GetThemeIdsInternal((Interop.Feedback.FeedbackType)type, out countOfTheme, out getThemeIds); + if (res != Interop.Feedback.FeedbackError.None) + { + Log.Warn(LogTag, string.Format("Failed to get ids of theme internal. err = {0}", res)); + switch (res) + { + case Interop.Feedback.FeedbackError.InvalidParameter: + throw new ArgumentException("Invalid Arguments"); + case Interop.Feedback.FeedbackError.NotSupported: + throw new NotSupportedException("Device is not supported"); + case Interop.Feedback.FeedbackError.OperationFailed: + default: + throw new InvalidOperationException("Failed to get ids of theme internal"); + } + } + + uint[] themeIds = new uint[countOfTheme]; + unsafe { + uint index = 0; + uint* themeIdsPointer = (uint*)getThemeIds; + + for (index = 0; index < countOfTheme; index++) { + themeIds[index] = themeIdsPointer[index]; + } + } + Marshal.FreeHGlobal(getThemeIds); + + return themeIds; + } } } diff --git a/src/Tizen.System.Feedback/Interop/Interop.Feedback.cs b/src/Tizen.System.Feedback/Interop/Interop.Feedback.cs index 0a4b4e8c2..81fbedaeb 100644 --- a/src/Tizen.System.Feedback/Interop/Interop.Feedback.cs +++ b/src/Tizen.System.Feedback/Interop/Interop.Feedback.cs @@ -67,5 +67,8 @@ internal static partial class Interop [DllImport(Libraries.Feedback, EntryPoint = "feedback_stop_type_internal")] internal static extern int StopTypeInternal(FeedbackType type); + + [DllImport(Libraries.Feedback, EntryPoint = "feedback_get_theme_ids_internal", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetThemeIdsInternal(FeedbackType type, out uint coundOfTheme, out IntPtr themeIds); } }