[System.Feedback] Change feedback theme api name index to id
[platform/core/csapi/tizenfx.git] / src / Tizen.System.Feedback / Feedback / Feedback.cs
1 /*
2 * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 using System;
18 using System.Collections.Generic;
19 using System.ComponentModel;
20
21
22 namespace Tizen.System
23 {
24     /// <summary>
25     /// The Feedback API provides functions to control haptic and sound.
26     /// The Feedback API provides the way to play and stop feedback, and get the information whether a specific pattern is supported.
27     /// Below is the supported pattern string:
28     /// Tap
29     /// SoftInputPanel
30     /// Key0
31     /// Key1
32     /// Key2
33     /// Key3
34     /// Key4
35     /// Key5
36     /// Key6
37     /// Key7
38     /// Key8
39     /// Key9
40     /// KeyStar
41     /// KeySharp
42     /// KeyBack
43     /// Hold
44     /// HardwareKeyPressed
45     /// HardwareKeyHold
46     /// Message
47     /// Email
48     /// WakeUp
49     /// Schedule
50     /// Timer
51     /// General
52     /// PowerOn
53     /// PowerOff
54     /// ChargerConnected
55     /// ChargingError
56     /// FullyCharged
57     /// LowBattery
58     /// Lock
59     /// UnLock
60     /// VibrationModeAbled
61     /// SilentModeDisabled
62     /// BluetoothDeviceConnected
63     /// BluetoothDeviceDisconnected
64     /// ListReorder
65     /// ListSlider
66     /// VolumeKeyPressed
67     /// </summary>
68     /// <privilege>
69     /// For controlling the haptic device:
70     /// http://tizen.org/privilege/haptic
71     /// For controlling the sound, privilege is not needed.
72     /// </privilege>
73     /// <example>
74     /// <code>
75     /// Feedback feedback = new Feedback();
76     /// bool res = feedback.IsSupportedPattern(FeedbackType.Vibration, "Tap");
77     /// </code>
78     /// </example>
79     /// <since_tizen> 3 </since_tizen>
80     public class Feedback
81     {
82         private const string LogTag = "Tizen.System.Feedback";
83
84         private readonly Dictionary<string, int> Pattern = new Dictionary<string, int>
85         {
86             {"Tap", 0},
87             {"SoftInputPanel", 1},
88             {"SipBackspace", 2},
89             {"SipFunction", 3},
90             {"SipFjkey", 4},
91             {"MaxCharacter", 5},
92             {"Key0", 6},
93             {"Key1", 7},
94             {"Key2", 8},
95             {"Key3", 9},
96             {"Key4", 10},
97             {"Key5", 11},
98             {"Key6", 12},
99             {"Key7", 13},
100             {"Key8", 14},
101             {"Key9", 15},
102             {"KeyStar", 16},
103             {"KeySharp", 17},
104             {"KeyBack", 18},
105             {"Hold", 19},
106             {"MultiTap", 20},
107             {"HardwareKeyPressed", 21},
108             {"HardwareKeyHold", 22},
109             {"Message", 23},
110             {"MessageOnCall", 24},
111             {"Email", 25},
112             {"EmailOnCall", 26},
113             {"WakeUp", 27},
114             {"WakeUpOnCall", 28},
115             {"Schedule", 29},
116             {"ScheduleOnCall", 30},
117             {"Timer", 31},
118             {"TimerOnCall", 32},
119             {"General", 33},
120             {"GeneralOnCall", 34},
121             {"SmartAlert", 35},
122             {"PowerOn", 36},
123             {"PowerOff", 37},
124             {"ChargerConnected", 38},
125             {"ChargerconnOnCall", 39},
126             {"ChargingError", 40},
127             {"ChargingErrorOnCall", 41},
128             {"FullyCharged", 42},
129             {"FullchargedOnCall", 43},
130             {"LowBattery", 44},
131             {"LowBattOnCall", 45},
132             {"Lock", 46},
133             {"UnLock", 47},
134             {"GeometricLock", 50},
135             {"Callconnect", 51},
136             {"Discallconnect", 52},
137             {"OutgoingCall", 53},
138             {"Minuteminder", 54},
139             {"VibrationModeAbled", 55},
140             {"SilentModeDisabled", 56},
141             {"BluetoothDeviceConnected", 57},
142             {"BluetoothDeviceDisconnected", 58},
143             {"BtPairing", 59},
144             {"BtWaiting", 60},
145             {"ScreenCapture", 61},
146             {"ListReorder", 62},
147             {"ListSlider", 63},
148             {"VolumeKeyPressed", 64},
149             {"UvProcessing", 95},
150             {"ShealthStart", 96},
151             {"ShealthPause", 97},
152             {"ShealthStop", 98},
153             {"3rdApplication", 99},
154             {"Tick", 100},
155             {"TransitionCircular", 101},
156             {"TransitionPop", 102},
157             {"Process", 103},
158             {"MoveList", 104},
159             {"Dismiss", 105},
160             {"ClockSecondHand", 106},
161             {"SystemShort", 107},
162             {"SystemError", 108},
163             {"SpiralDown", 109},
164             {"MoveList2", 110},
165             {"SpiralUp", 111},
166             {"SystemLong", 112},
167             {"SystemMid", 113},
168             {"Silence", 114},
169             {"InactiveTension", 115},
170             {"InactiveFine", 116},
171             {"EndEffect", 117},
172             {"ShealthNotice", 118},
173             {"ShealthGentleAlert", 119},
174             {"EndEffectFine", 120},
175             {"ClickValue", 121},
176             {"ClickFineTrain1", 122},
177             {"ClickFine", 123},
178             {"ClickSlider", 124},
179             {"ClickMedium", 125},
180             {"ClickStrong", 126},
181             {"TurnRight", 127},
182             {"TurnLeft", 128},
183             {"Function", 129},
184             {"VoiceStart", 130},
185             {"VoiceStop", 131},
186             {"Communication", 132},
187             {"MessageStrongBuzz", 133},
188             {"EmailStrongBuzz", 134},
189             {"GeneralStrongBuzz", 135},
190             {"CommunicationStrongBuzz", 136},
191             {"ScheduleStrongBuzz", 137},
192             {"WakeupStrongBuzz", 138},
193             {"TimerStrongBuzz", 139},
194             {"RingerStrongBuzz", 140},
195             {"Heartbeat", 141},
196             {"HeartbeatFast", 142},
197             {"SettingOn", 143},
198             {"SettingOff", 144},
199             {"Connect", 145},
200             {"Disconnect", 146},
201             {"FindMyGear", 147},
202             {"Notification1", 148},
203             {"Notification1StrongBuzz", 149},
204             {"Notification2", 150},
205             {"Notification2StrongBuzz", 151},
206             {"Notification3", 152},
207             {"Notification3StrongBuzz", 153},
208             {"Notification4", 154},
209             {"Notification4StrongBuzz", 155},
210             {"Notification5", 156},
211             {"Notification5StrongBuzz", 157},
212             {"Notification6", 158},
213             {"Notification6StrongBuzz", 159},
214             {"Notification7", 160},
215             {"Notification7StrongBuzz", 161},
216             {"Notification8", 162},
217             {"Notification8StrongBuzz", 163},
218             {"Notification9", 164},
219             {"Notification9StrongBuzz", 165},
220             {"Notification10", 166},
221             {"Notification10StrongBuzz", 167},
222             {"Ring1", 168},
223             {"Ring1StrongBuzz", 169},
224             {"Ring2", 170},
225             {"Ring2StrongBuzz", 171},
226             {"Ring3", 172},
227             {"Ring3StrongBuzz", 173},
228             {"Ring4", 174},
229             {"Ring4StrongBuzz", 175},
230             {"Ring5", 176},
231             {"Ring5StrongBuzz", 177},
232             {"Ring6", 178},
233             {"Ring6StrongBuzz", 179},
234             {"Ring7", 180},
235             {"Ring7StrongBuzz", 181},
236             {"Ring8", 182},
237             {"Ring8StrongBuzz", 183},
238             {"Ring9", 184},
239             {"Ring9StrongBuzz", 185},
240             {"Ring10", 186},
241             {"Ring10StrongBuzz", 187},
242             {"Alarm1", 188},
243             {"Alarm1StrongBuzz", 189},
244             {"Alarm2", 190},
245             {"Alarm2StrongBuzz", 191},
246             {"Alarm3", 192},
247             {"Alarm3StrongBuzz", 193},
248             {"Alarm4", 194},
249             {"Alarm4StrongBuzz", 195},
250             {"Alarm5", 196},
251             {"Alarm5StrongBuzz", 197},
252             {"Alarm6", 198},
253             {"Alarm6StrongBuzz", 199},
254             {"Alarm7", 200},
255             {"Alarm7StrongBuzz", 201},
256             {"Alarm8", 202},
257             {"Alarm8StrongBuzz", 203},
258             {"Alarm9", 204},
259             {"Alarm9StrongBuzz", 205},
260             {"Alarm10", 206},
261             {"Alarm10StrongBuzz", 207},
262             {"Picker", 208},
263             {"PickerFinish", 209},
264             {"OnOffSwitch", 210},
265             {"Reorder", 211},
266             {"CursorMove", 212},
267             {"Mms", 10000},
268             {"HourlyAlert", 10001},
269             {"SafetyAlert", 10002},
270             {"AccidentDetect", 10003},
271             {"SendSosMessage", 10004},
272             {"EndSosMessage", 10005},
273             {"EmergencyBuzzer", 10006},
274             {"SafetyLowPower", 10007},
275             {"Cmas", 10008},
276             {"Ringer", 10009},
277             {"Notification", 10010},
278             {"Info", 10011},
279             {"Warning", 10012},
280             {"Error", 10013},
281             {"Emergency", 10014},
282             {"InternalWakeup", 10015},
283             {"InternalTimer", 10016},
284             {"TemperatureWarning", 10017},
285             {"CooldownWarning1", 10018},
286             {"CooldownWarning2", 10019},
287             {"SpeedUp", 10020},
288             {"SlowDown", 10021},
289             {"KeepThisPace", 10022},
290             {"GoalAchieved", 10023},
291             {"ExerciseCount", 10024},
292             {"StartCue", 10025},
293             {"HealthPace", 10026},
294             {"InactiveTime", 10027},
295             {"CmasCa", 10028},
296             {"NfcSuccess", 10029},
297             {"MeasuringSuccess", 10030},
298             {"MeasuringFailure", 10031},
299             {"Meditation", 10032},
300             {"MeditationInternal", 10033},
301             {"FallDetection1", 10034},
302             {"FallDetection2", 10035},
303             {"SmartGesture", 10036},
304             {"BreathingExhale", 12000},
305             {"Bos", 12001},
306             {"Eos", 12002},
307             {"Uds", 12003},
308             {"Basic", 40001},
309             {"ToggleOn", 40002},
310             {"ToggleOff", 40003},
311             {"LongPressOn", 40004},
312             {"LongPressOff", 40005},
313             {"Invalid", 40006},
314             {"Confirm", 40007},
315             {"PopUp", 40008},
316             {"PreheatEnding", 40009},
317             {"TaskEnding", 40010},
318             {"Scroll", 40011},
319             {"PageTurn", 40012},
320             {"OpStart", 40013},
321             {"OpPause", 40014},
322             {"OpStop", 40015},
323             {"Default", 40016},
324             {"DefaultLevel1", 40017},
325             {"Level1", 40018},
326             {"Level2", 40019},
327             {"Level3", 40020},
328             {"Level4", 40021},
329             {"Level5", 40022},
330             {"Level6", 40023},
331             {"Level7", 40024},
332             {"Level8", 40025},
333             {"Level9", 40026},
334             {"Level10", 40027},
335             {"TimerEnding", 40028},
336             {"BurnerDetected", 40029},
337             {"BurnerMoved", 40030},
338             {"Connected", 40031},
339             {"Disconnected", 40032},
340             {"Welcome", 40033},
341             {"AutoDoorOpen", 40034},
342         };
343
344         /// <summary>
345         /// Constructor of Feedback class
346         /// </summary>
347         /// <since_tizen> 3 </since_tizen>
348         /// <feature>
349         /// http://tizen.org/feature/feedback.vibration for FeedbackType.Vibration
350         /// </feature>
351         /// <exception cref="NotSupportedException">Thrown when failed because the devices (vibration and sound) are not supported.</exception>
352         /// <exception cref="InvalidOperationException">Thrown when failed because of a system error.</exception>
353         /// <privilege>http://tizen.org/privilege/haptic</privilege>
354         /// <example>
355         /// <code>
356         /// Feedback feedback = new Feedback();
357         /// </code>
358         /// </example>
359         public Feedback()
360         {
361             Interop.Feedback.FeedbackError res = (Interop.Feedback.FeedbackError)Interop.Feedback.Initialize();
362             if (res != Interop.Feedback.FeedbackError.None)
363             {
364                 Log.Warn(LogTag, string.Format("Failed to initialize feedback. err = {0}", res));
365                 switch (res)
366                 {
367                     case Interop.Feedback.FeedbackError.NotSupported:
368                         throw new NotSupportedException("Device is not supported");
369                     default:
370                         throw new InvalidOperationException("Failed to initialize");
371                 }
372             }
373         }
374
375         /// <summary>
376         /// Finalizes an instance of the Feedback class.
377         /// </summary>
378         ~Feedback()
379         {
380             Interop.Feedback.FeedbackError res = (Interop.Feedback.FeedbackError)Interop.Feedback.Deinitialize();
381             if (res != Interop.Feedback.FeedbackError.None)
382             {
383                 Log.Warn(LogTag, string.Format("Failed to deinitialize feedback. err = {0}", res));
384             }
385         }
386
387         /// <summary>
388         /// Gets the supported information about a specific type and pattern.
389         /// </summary>
390         /// <remarks>
391         /// Now, IsSupportedPattern is not working for FeedbackType.All.
392         /// This API is working for FeedbackType.Sound and FeedbackType.Vibration only.
393         /// If you use FeedbackType.All for type parameter, this API will throw ArgumentException.
394         /// To get the supported information for Vibration type, the application should have http://tizen.org/privilege/haptic privilege.
395         /// </remarks>
396         /// <since_tizen> 3 </since_tizen>
397         /// <param name="type">The feedback type.</param>
398         /// <param name="pattern">The feedback pattern string.</param>
399         /// <feature>
400         /// http://tizen.org/feature/feedback.vibration for FeedbackType.Vibration
401         /// </feature>
402         /// <returns>Information whether a pattern is supported.</returns>
403         /// <exception cref="Exception">Thrown when failed because the feedback is not initialized.</exception>
404         /// <exception cref="ArgumentException">Thrown when failed because of an invalid arguament.</exception>
405         /// <exception cref="NotSupportedException">Thrown when failed becuase the device (haptic, sound) is not supported.</exception>
406         /// <exception cref="UnauthorizedAccessException">Thrown when failed because the access is not granted (No privilege).</exception>
407         /// <exception cref="InvalidOperationException">Thrown when failed because of a system error.</exception>
408         /// <privilege>http://tizen.org/privilege/haptic</privilege>
409         /// <example>
410         /// <code>
411             /// Feedback feedback = new Feedback();
412         /// bool res = feedback.IsSupportedPattern(FeedbackType.Vibration, "Tap");
413         /// </code>
414         /// </example>
415         public bool IsSupportedPattern(FeedbackType type, String pattern)
416         {
417             bool supported = false;
418             int number;
419             Interop.Feedback.FeedbackError res;
420
421             if (!Pattern.TryGetValue(pattern, out number))
422                 throw new ArgumentException($"Not supported pattern string : {pattern}", nameof(pattern));
423
424             res = (Interop.Feedback.FeedbackError)Interop.Feedback.IsSupportedPattern((Interop.Feedback.FeedbackType)type, number, out supported);
425
426             if (res != Interop.Feedback.FeedbackError.None)
427             {
428                 Log.Warn(LogTag, string.Format("Failed to get supported information. err = {0}", res));
429                 switch (res)
430                 {
431                     case Interop.Feedback.FeedbackError.NotInitialized:
432                         throw new Exception("Not initialized");
433                     case Interop.Feedback.FeedbackError.InvalidParameter:
434                         throw new ArgumentException("Invalid Arguments");
435                     case Interop.Feedback.FeedbackError.NotSupported:
436                         throw new NotSupportedException("Device is not supported");
437                     case Interop.Feedback.FeedbackError.PermissionDenied:
438                         throw new UnauthorizedAccessException("Access is not granted");
439                     case Interop.Feedback.FeedbackError.OperationFailed:
440                     default:
441                         throw new InvalidOperationException("Failed to get supported information");
442                 }
443             }
444             return supported;
445         }
446
447         /// <summary>
448         /// Plays a specific feedback pattern.
449         /// </summary>
450         /// <remarks>
451         /// To play Vibration type, app should have http://tizen.org/privilege/haptic privilege.
452         /// </remarks>
453         /// <since_tizen> 3 </since_tizen>
454         /// <param name="type">The feedback type.</param>
455         /// <param name="pattern">The feedback pattern string.</param>
456         /// <feature>
457         /// http://tizen.org/feature/feedback.vibration for FeedbackType.Vibration
458         /// </feature>
459         /// <exception cref="Exception">Thrown when failed because feedback is not initialized.</exception>
460         /// <exception cref="ArgumentException">Thrown when failed because of an invalid arguament.</exception>
461         /// <exception cref="NotSupportedException">Thrown when failed because the device (haptic, sound) or a specific pattern is not supported.</exception>
462         /// <exception cref="UnauthorizedAccessException">Thrown when failed because the access is not granted(No privilege)</exception>
463         /// <exception cref="InvalidOperationException">Thrown when failed because of a system error.</exception>
464         /// <privilege>http://tizen.org/privilege/haptic</privilege>
465         /// <example>
466         /// <code>
467         /// Feedback feedback = new Feedback();
468         /// feedback.Play(FeedbackType.All, "Tap");
469         /// </code>
470         /// </example>
471         public void Play(FeedbackType type, String pattern)
472         {
473             int number;
474             Interop.Feedback.FeedbackError res;
475
476             if (!Pattern.TryGetValue(pattern, out number))
477                 throw new ArgumentException($"Not supported pattern string : {pattern}", nameof(pattern));
478
479             if (type == FeedbackType.All)
480                 res = (Interop.Feedback.FeedbackError)Interop.Feedback.Play(number);
481             else
482                 res = (Interop.Feedback.FeedbackError)Interop.Feedback.PlayType((Interop.Feedback.FeedbackType)type, number);
483
484             if (res != Interop.Feedback.FeedbackError.None)
485             {
486                 Log.Warn(LogTag, string.Format("Failed to play feedback. err = {0}", res));
487                 switch (res)
488                 {
489                     case Interop.Feedback.FeedbackError.NotInitialized:
490                         throw new Exception("Not initialized");
491                     case Interop.Feedback.FeedbackError.InvalidParameter:
492                         throw new ArgumentException("Invalid Arguments");
493                     case Interop.Feedback.FeedbackError.NotSupported:
494                         throw new NotSupportedException("Not supported");
495                     case Interop.Feedback.FeedbackError.PermissionDenied:
496                         throw new UnauthorizedAccessException("Access is not granted");
497                     case Interop.Feedback.FeedbackError.OperationFailed:
498                     default:
499                         throw new InvalidOperationException("Failed to play pattern");
500                 }
501             }
502         }
503
504         /// <summary>
505         /// Stops to play the feedback.
506         /// </summary>
507         /// <remarks>
508         /// To stop vibration, the application should have http://tizen.org/privilege/haptic privilege.
509         /// </remarks>
510         /// <since_tizen> 3 </since_tizen>
511         /// <feature>
512         /// http://tizen.org/feature/feedback.vibration
513         /// </feature>
514         /// <exception cref="Exception">Thrown when failed because the feedback is not initialized.</exception>
515         /// <exception cref="ArgumentException">Thrown when failed because of an invalid arguament</exception>
516         /// <exception cref="NotSupportedException">Thrown when failed because the device (haptic, sound) or a specific pattern is not supported.</exception>
517         /// <exception cref="UnauthorizedAccessException">Thrown when failed because the access is not granted (No privilege).</exception>
518         /// <exception cref="InvalidOperationException">Thrown when failed because of a system error.</exception>
519         /// <privilege>http://tizen.org/privilege/haptic</privilege>
520         /// <example>
521         /// <code>
522         /// Feedback Feedback1 = new Feedback();
523         /// Feedback1.Stop();
524         /// </code>
525         /// </example>
526         public void Stop()
527         {
528             Interop.Feedback.FeedbackError res = (Interop.Feedback.FeedbackError)Interop.Feedback.Stop();
529
530             if (res != Interop.Feedback.FeedbackError.None)
531             {
532                 Log.Warn(LogTag, string.Format("Failed to stop feedback. err = {0}", res));
533                 switch (res)
534                 {
535                     case Interop.Feedback.FeedbackError.NotInitialized:
536                         throw new Exception("Not initialized");
537                     case Interop.Feedback.FeedbackError.InvalidParameter:
538                         throw new ArgumentException("Invalid Arguments");
539                     case Interop.Feedback.FeedbackError.NotSupported:
540                         throw new NotSupportedException("Not supported");
541                     case Interop.Feedback.FeedbackError.PermissionDenied:
542                         throw new UnauthorizedAccessException("Access is not granted");
543                     case Interop.Feedback.FeedbackError.OperationFailed:
544                     default:
545                         throw new InvalidOperationException("Failed to stop pattern");
546                 }
547             }
548         }
549
550         /// <summary>
551         /// Gets the count of theme can be used according to feedback type.
552         /// </summary>
553         /// <remarks>
554         /// Now this internal API works for FeedbackType.Sound only, FeedbackType.Vibration is not supported.
555         /// Counts of theme range will be 1 ~ N according to conf file.
556         /// </remarks>
557         /// <since_tizen> 10 </since_tizen>
558         /// <param name="type">The feedback type.</param>
559         /// <returns>The counf of theme can be used according to feedback type.</returns>
560         /// <exception cref="Exception">Thrown when failed because the feedback is not initialized.</exception>
561         /// <exception cref="ArgumentException">Thrown when failed because of an invalid arguament.</exception>
562         /// <exception cref="NotSupportedException">Thrown when failed becuase the device (haptic, sound) is not supported.</exception>
563         /// <exception cref="InvalidOperationException">Thrown when failed because of a system error.</exception>
564         /// <example>
565         /// <code>
566         /// Feedback feedback = new Feedback();
567         /// uint coundOfTheme = feedback.GetCountOfThemeInternal(FeedbackType.Sound);
568         /// </code>
569         /// </example>
570         [EditorBrowsable(EditorBrowsableState.Never)]
571         public uint GetCountOfThemeInternal(FeedbackType type)
572         {
573             uint countOfTheme = 0;
574             Interop.Feedback.FeedbackError res;
575
576             res = (Interop.Feedback.FeedbackError)Interop.Feedback.GetCountOfThemeInternal((Interop.Feedback.FeedbackType)type, out countOfTheme);
577
578             if (res != Interop.Feedback.FeedbackError.None)
579             {
580                 Log.Warn(LogTag, string.Format("Failed to get count of theme internal. err = {0}", res));
581                 switch (res)
582                 {
583                     case Interop.Feedback.FeedbackError.NotInitialized:
584                         throw new Exception("Not initialized");
585                     case Interop.Feedback.FeedbackError.InvalidParameter:
586                         throw new ArgumentException("Invalid Arguments");
587                     case Interop.Feedback.FeedbackError.NotSupported:
588                         throw new NotSupportedException("Device is not supported");
589                     case Interop.Feedback.FeedbackError.OperationFailed:
590                     default:
591                         throw new InvalidOperationException("Failed to get count of theme internal");
592                 }
593             }
594             return countOfTheme;
595         }
596
597         /// <summary>
598         /// Gets the id of theme selected.
599         /// </summary>
600         /// <remarks>
601         /// Now this internal API works for FeedbackType.Sound only, FeedbackType.Vibration is not supported.
602         /// The theme id is positive value as defined in the conf file.
603         /// </remarks>
604         /// <since_tizen> 10 </since_tizen>
605         /// <param name="type">The feedback type.</param>
606         /// <returns>The id of theme selected as default theme according to feedback type.</returns>
607         /// <exception cref="ArgumentException">Thrown when failed because of an invalid arguament.</exception>
608         /// <exception cref="NotSupportedException">Thrown when failed becuase the device (haptic, sound) is not supported.</exception>
609         /// <exception cref="InvalidOperationException">Thrown when failed because of a system error.</exception>
610         /// <example>
611         /// <code>
612         /// Feedback feedback = new Feedback();
613         /// uint idOfTheme = feedback.GetThemeIdInternal(FeedbackType.Sound);
614         /// </code>
615         /// </example>
616         [EditorBrowsable(EditorBrowsableState.Never)]
617         public uint GetThemeIdInternal(FeedbackType type)
618         {
619             uint countOfTheme = 0;
620             Interop.Feedback.FeedbackError res;
621
622             res = (Interop.Feedback.FeedbackError)Interop.Feedback.GetThemeIdInternal((Interop.Feedback.FeedbackType)type, out countOfTheme);
623
624             if (res != Interop.Feedback.FeedbackError.None)
625             {
626                 Log.Warn(LogTag, string.Format("Failed to get id of theme internal. err = {0}", res));
627                 switch (res)
628                 {
629                     case Interop.Feedback.FeedbackError.InvalidParameter:
630                         throw new ArgumentException("Invalid Arguments");
631                     case Interop.Feedback.FeedbackError.NotSupported:
632                         throw new NotSupportedException("Device is not supported");
633                     case Interop.Feedback.FeedbackError.OperationFailed:
634                     default:
635                         throw new InvalidOperationException("Failed to get id of theme internal");
636                 }
637             }
638             return countOfTheme;
639         }
640
641         /// <summary>
642         /// Sets the id of theme according to feedback type.
643         /// </summary>
644         /// <remarks>
645         /// Now this internal API works for FeedbackType.Sound only, FeedbackType.Vibration is not supported.
646         /// To set the id of theme for Sound type, the application should have http://tizen.org/privilege/systemsettings.admin privilege.
647         /// The theme id is positive value as defined in the conf file.
648         /// </remarks>
649         /// <since_tizen> 10 </since_tizen>
650         /// <param name="type">The feedback type.</param>
651         /// <param name="idOfTheme">The id of theme will be set.</param>
652         /// <exception cref="ArgumentException">Thrown when failed because of an invalid arguament.</exception>
653         /// <exception cref="NotSupportedException">Thrown when failed becuase the device (haptic, sound) is not supported.</exception>
654         /// <exception cref="UnauthorizedAccessException">Thrown when failed because the access is not granted(No privilege)</exception>
655         /// <exception cref="InvalidOperationException">Thrown when failed because of a system error.</exception>
656         /// <example>
657         /// <code>
658         /// Feedback feedback = new Feedback();
659         /// uint idOfTheme = 1;
660         /// feedback.SetThemeIdInternal(FeedbackType.Sound, idOfTheme);
661         /// </code>
662         /// </example>
663         [EditorBrowsable(EditorBrowsableState.Never)]
664         public void SetThemeIdInternal(FeedbackType type, uint idOfTheme)
665         {
666             Interop.Feedback.FeedbackError res;
667
668             res = (Interop.Feedback.FeedbackError)Interop.Feedback.SetThemeIdInternal((Interop.Feedback.FeedbackType)type, idOfTheme);
669
670             if (res != Interop.Feedback.FeedbackError.None)
671             {
672                 Log.Warn(LogTag, string.Format("Failed to set id of theme internal. err = {0}", res));
673                 switch (res)
674                 {
675                     case Interop.Feedback.FeedbackError.InvalidParameter:
676                         throw new ArgumentException("Invalid Arguments");
677                     case Interop.Feedback.FeedbackError.NotSupported:
678                         throw new NotSupportedException("Device is not supported");
679                     case Interop.Feedback.FeedbackError.PermissionDenied:
680                         throw new UnauthorizedAccessException("Access is not granted");
681                     case Interop.Feedback.FeedbackError.OperationFailed:
682                     default:
683                         throw new InvalidOperationException("Failed to set id of theme internal");
684                 }
685             }
686         }
687
688         /// <summary>
689         /// Stops the current feedback playing by feedback type
690         /// </summary>
691         /// <remarks>
692         /// To stop vibration, the application should have http://tizen.org/privilege/haptic privilege.
693         /// </remarks>
694         /// <since_tizen> 10 </since_tizen>
695         /// <param name="type">The feedback type.</param>
696         /// <exception cref="Exception">Thrown when failed because the feedback is not initialized.</exception>
697         /// <exception cref="ArgumentException">Thrown when failed because of an invalid argument</exception>
698         /// <exception cref="NotSupportedException">Thrown when failed because the device (haptic, sound) or a specific pattern is not supported.</exception>
699         /// <exception cref="UnauthorizedAccessException">Thrown when failed because the access is not granted (No privilege).</exception>
700         /// <exception cref="InvalidOperationException">Thrown when failed because of a system error.</exception>
701         /// <example>
702         /// <code>
703         /// Feedback Feedback = new Feedback();
704         /// feedback.StopTypeInternal(FeedbackType.Sound);
705         /// feedback.StopTypeInternal(FeedbackType.Vibration);
706         /// </code>
707         /// </example>
708         [EditorBrowsable(EditorBrowsableState.Never)]
709         public void StopTypeInternal(FeedbackType type)
710         {
711             Interop.Feedback.FeedbackError res;
712
713             res = (Interop.Feedback.FeedbackError)Interop.Feedback.StopTypeInternal((Interop.Feedback.FeedbackType)type);
714
715             if (res != Interop.Feedback.FeedbackError.None)
716             {
717                 Log.Warn(LogTag, string.Format("Failed to Stop feedback by feedback type internal. err = {0}", res));
718                 switch (res)
719                 {
720                     case Interop.Feedback.FeedbackError.NotInitialized:
721                         throw new Exception("Not initialized");
722                     case Interop.Feedback.FeedbackError.InvalidParameter:
723                         throw new ArgumentException("Invalid Arguments");
724                     case Interop.Feedback.FeedbackError.NotSupported:
725                         throw new NotSupportedException("Not supported");
726                     case Interop.Feedback.FeedbackError.PermissionDenied:
727                         throw new UnauthorizedAccessException("Access is not granted");
728                     case Interop.Feedback.FeedbackError.OperationFailed:
729                     default:
730                         throw new InvalidOperationException("Failed to stop pattern by feedback type");
731                 }
732             }
733         }
734     }
735 }