Skip to content

Commit

Permalink
[System.Feedback] Add internal API to support get ids
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Yunhee Seo authored and chanwoochoi committed Nov 14, 2023
1 parent 18fd8db commit 232c512
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
57 changes: 57 additions & 0 deletions src/Tizen.System.Feedback/Feedback/Feedback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.InteropServices;


namespace Tizen.System
Expand Down Expand Up @@ -731,5 +732,61 @@ public void StopTypeInternal(FeedbackType type)
}
}
}

/// <summary>
/// Gets the id array of theme supported.
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
/// <since_tizen> 10 </since_tizen>
/// <param name="type">The feedback type.</param>
/// <returns>The array of theme id supported according to feedback type.</returns>
/// <exception cref="ArgumentException">Thrown when failed because of an invalid arguament.</exception>
/// <exception cref="NotSupportedException">Thrown when failed becuase the device (haptic, sound) is not supported.</exception>
/// <exception cref="InvalidOperationException">Thrown when failed because of a system error.</exception>
/// <example>
/// <code>
/// Feedback feedback = new Feedback();
/// uint[] getThemeIds = feedback.GetThemeIdsInternal(FeedbackType.Sound);
/// </code>
/// </example>
[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;
}
}
}
3 changes: 3 additions & 0 deletions src/Tizen.System.Feedback/Interop/Interop.Feedback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,8 @@ internal enum FeedbackType

[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);
}
}

0 comments on commit 232c512

Please sign in to comment.