From 145d2ee99a47dfcfc2b264c8f825829391ef2cba Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Wed, 9 Aug 2023 16:02:05 +0900 Subject: [PATCH] [System.Feedback] Add internal APIs to support multi-theme sound conf usage Allows selecting one of several theme files according to feedback type. Now, this supports only feedback type Sound. These are newly added to System.Feedback. - public uint GetCountOfThemeInternal(FeedbackType type) -> It returns count of theme which is defined conf file according to feedback type. This indicates how many conf files are available. - public uint GetThemeIndexInternal(FeedbackType type) -> It returns index of theme which is selected as default according to feedback type. - public void SetThemeIndexInternal(FeedbackType type, uint indexOfTheme) -> It sets indexOfTheme to default conf index according to feedback type. By calling this, feedback will use the conf file with "indexOfTheme" index. Signed-off-by: Yunhee Seo --- src/Tizen.System.Feedback/Feedback/Feedback.cs | 132 +++++++++++++++++++++ .../Interop/Interop.Feedback.cs | 9 ++ 2 files changed, 141 insertions(+) diff --git a/src/Tizen.System.Feedback/Feedback/Feedback.cs b/src/Tizen.System.Feedback/Feedback/Feedback.cs index 3e6a79b..73ee4a5 100755 --- a/src/Tizen.System.Feedback/Feedback/Feedback.cs +++ b/src/Tizen.System.Feedback/Feedback/Feedback.cs @@ -16,6 +16,7 @@ using System; using System.Collections.Generic; +using System.ComponentModel; namespace Tizen.System @@ -328,5 +329,136 @@ namespace Tizen.System } } } + + /// + /// Gets the count of theme can be used according to feedback type. + /// + /// + /// Now this internal API works for FeedbackType.Sound only, FeedbackType.Vibration is not supported. + /// + /// 10 + /// The feedback type. + /// The counf of theme can be used according to feedback type. + /// Thrown when failed because the feedback is not initialized. + /// 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 coundOfTheme = feedback.GetCountOfThemeInternal(FeedbackType.Sound); + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public uint GetCountOfThemeInternal(FeedbackType type) + { + uint countOfTheme = 0; + Interop.Feedback.FeedbackError res; + + res = (Interop.Feedback.FeedbackError)Interop.Feedback.GetCountOfThemeInternal((Interop.Feedback.FeedbackType)type, out countOfTheme); + + if (res != Interop.Feedback.FeedbackError.None) + { + Log.Warn(LogTag, string.Format("Failed to get count of theme internal. err = {0}", res)); + switch (res) + { + case Interop.Feedback.FeedbackError.NotInitialized: + throw new Exception("Not initialized"); + 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 count of theme internal"); + } + } + return countOfTheme; + } + + /// + /// Gets the index of theme selected. + /// + /// + /// Now this internal API works for FeedbackType.Sound only, FeedbackType.Vibration is not supported. + /// + /// 10 + /// The feedback type. + /// The index of theme selected as default theme 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 indexOfTheme = feedback. GetThemeIndexInternal(FeedbackType.Sound); + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public uint GetThemeIndexInternal(FeedbackType type) + { + uint countOfTheme = 0; + Interop.Feedback.FeedbackError res; + + res = (Interop.Feedback.FeedbackError)Interop.Feedback.GetThemeIndexInternal((Interop.Feedback.FeedbackType)type, out countOfTheme); + + if (res != Interop.Feedback.FeedbackError.None) + { + Log.Warn(LogTag, string.Format("Failed to get index 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 index of theme internal"); + } + } + return countOfTheme; + } + + /// + /// Sets the index of theme according to feedback type. + /// + /// + /// Now this internal API works for FeedbackType.Sound only, FeedbackType.Vibration is not supported. + /// + /// 10 + /// The feedback type. + /// The index of theme will be set. + /// 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 indexOfTheme = 0; + /// feedback.SetThemeIndexInternal(FeedbackType.Sound, indexOfTheme); + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetThemeIndexInternal(FeedbackType type, uint indexOfTheme) + { + Interop.Feedback.FeedbackError res; + + res = (Interop.Feedback.FeedbackError)Interop.Feedback.SetThemeIndexInternal((Interop.Feedback.FeedbackType)type, indexOfTheme); + + if (res != Interop.Feedback.FeedbackError.None) + { + Log.Warn(LogTag, string.Format("Failed to set index 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 set index of theme internal"); + } + } + } } } diff --git a/src/Tizen.System.Feedback/Interop/Interop.Feedback.cs b/src/Tizen.System.Feedback/Interop/Interop.Feedback.cs index 6b3e572..359f9b2 100644 --- a/src/Tizen.System.Feedback/Interop/Interop.Feedback.cs +++ b/src/Tizen.System.Feedback/Interop/Interop.Feedback.cs @@ -55,5 +55,14 @@ internal static partial class Interop [DllImport(Libraries.Feedback, EntryPoint = "feedback_is_supported_pattern")] internal static extern int IsSupportedPattern(FeedbackType type, int pattern, out bool supported); + + [DllImport(Libraries.Feedback, EntryPoint = "feedback_get_count_of_theme_internal")] + internal static extern int GetCountOfThemeInternal(FeedbackType type, out uint countOfTheme); + + [DllImport(Libraries.Feedback, EntryPoint = "feedback_get_theme_index_internal")] + internal static extern int GetThemeIndexInternal(FeedbackType type, out uint indexOfTheme); + + [DllImport(Libraries.Feedback, EntryPoint = "feedback_set_theme_index_internal")] + internal static extern int SetThemeIndexInternal(FeedbackType type, uint indexOfTheme); } } -- 2.7.4