From fd2e1e7f9859b9136fff14b85ec0a997248370bd Mon Sep 17 00:00:00 2001 From: Gilbok Lee Date: Thu, 1 Jun 2017 16:22:40 +0900 Subject: [PATCH] [Radio] If fmradio feature is false, radio return NotSupportedException Change-Id: Ib046ad83fda9dd0d1bbf1889b6b93dcd6c742d70 --- src/Tizen.Multimedia.Radio/Radio/Radio.cs | 17 +++++++++++++++++ .../Tizen.Multimedia.Radio.csproj | 1 + src/Tizen.Multimedia/Common.Internal/Features.cs | 4 ++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Tizen.Multimedia.Radio/Radio/Radio.cs b/src/Tizen.Multimedia.Radio/Radio/Radio.cs index f2e1ed0..f634861 100644 --- a/src/Tizen.Multimedia.Radio/Radio/Radio.cs +++ b/src/Tizen.Multimedia.Radio/Radio/Radio.cs @@ -17,6 +17,7 @@ using System; using System.Runtime.CompilerServices; using System.Threading.Tasks; +using Tizen.System; namespace Tizen.Multimedia { @@ -27,14 +28,18 @@ namespace Tizen.Multimedia { internal Interop.RadioHandle _handle; + private const string FeatureFmRadio = "http://tizen.org/feature/fmradio"; + /// /// Radio constructor /// + /// http://tizen.org/feature/fmradio /// /// This is thrown if Radio feature is not supported /// public Radio() { + ValidateFeatureSupported(FeatureFmRadio); _handle = new Interop.RadioHandle(); _handle.ScanCompleteCb = ScanCompleteCallback; _handle.InteruptedCb = PlaybackIntruptedCallback; @@ -266,6 +271,18 @@ namespace Tizen.Multimedia return Interop.PinnedTask(tcs); } + private void ValidateFeatureSupported(string featurePath) + { + bool supported = false; + SystemInfo.TryGetValue(featurePath, out supported); + + if (supported == false) + { + throw new NotSupportedException($"The feature({featurePath}) is not supported."); + } + + } + private void ScanUpdateCallback(int frequency, IntPtr data) { ScanInformationUpdated?.Invoke(this, new ScanUpdatedEventArgs(frequency)); diff --git a/src/Tizen.Multimedia.Radio/Tizen.Multimedia.Radio.csproj b/src/Tizen.Multimedia.Radio/Tizen.Multimedia.Radio.csproj index 61fb22d..ecf05ef 100644 --- a/src/Tizen.Multimedia.Radio/Tizen.Multimedia.Radio.csproj +++ b/src/Tizen.Multimedia.Radio/Tizen.Multimedia.Radio.csproj @@ -11,6 +11,7 @@ + diff --git a/src/Tizen.Multimedia/Common.Internal/Features.cs b/src/Tizen.Multimedia/Common.Internal/Features.cs index ebb0c82..50c8508 100644 --- a/src/Tizen.Multimedia/Common.Internal/Features.cs +++ b/src/Tizen.Multimedia/Common.Internal/Features.cs @@ -20,8 +20,8 @@ namespace Tizen.Multimedia { internal static class Features { - internal static string AudioEffect = "http://tizen.org/feature/multimedia.custom_audio_effect"; - internal static string RawVideo = "http://tizen.org/feature/multimedia.raw_video"; + internal const string AudioEffect = "http://tizen.org/feature/multimedia.custom_audio_effect"; + internal const string RawVideo = "http://tizen.org/feature/multimedia.raw_video"; internal static bool IsSupported(string featureKey) { -- 2.7.4