[Radio] If fmradio feature is false, radio return NotSupportedException
authorGilbok Lee <gilbok.lee@samsung.com>
Thu, 1 Jun 2017 07:22:40 +0000 (16:22 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Thu, 1 Jun 2017 08:17:48 +0000 (17:17 +0900)
Change-Id: Ib046ad83fda9dd0d1bbf1889b6b93dcd6c742d70

src/Tizen.Multimedia.Radio/Radio/Radio.cs
src/Tizen.Multimedia.Radio/Tizen.Multimedia.Radio.csproj
src/Tizen.Multimedia/Common.Internal/Features.cs

index f2e1ed0..f634861 100644 (file)
@@ -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";
+
         /// <summary>
         /// Radio constructor
         /// </summary>
+        /// <Feature> http://tizen.org/feature/fmradio </Feature>
         /// <exception cref="OutOfMemoryException"></exception>
         /// <exception cref="NotSupportedException">This is thrown if Radio feature is not supported</exception>
         /// <exception cref="InvalidOperationException"></exception>
         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));
index 61fb22d..ecf05ef 100644 (file)
@@ -11,6 +11,7 @@
 
   <ItemGroup>
     <PackageReference Include="Tizen" Version="1.0.3" />
+    <PackageReference Include="Tizen.System.Information" Version="1.0.2" />
   </ItemGroup>
 
 </Project>
index ebb0c82..50c8508 100644 (file)
@@ -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)
         {