Merge "[Multimedia] Modified to throw a exception with better error message when... preview1-00238
authorcoderhyme <jhyo.kim@samsung.com>
Fri, 22 Sep 2017 03:09:18 +0000 (03:09 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Fri, 22 Sep 2017 03:09:18 +0000 (03:09 +0000)
17 files changed:
pkg/PublicModuleList.txt
src/ElmSharp/ElmSharp/EvasImage.cs
src/ElmSharp/ElmSharp/Image.cs
src/ElmSharp/ElmSharp/Layout.cs
src/Tizen.Applications.Common/Tizen.Applications.Exceptions/AppNotFoundException.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications.Exceptions/LaunchFailedException.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications.Exceptions/LaunchRejectedException.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications.Exceptions/OutOfMemoryException.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications.Exceptions/PermissionDeniedException.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs
src/Tizen.Applications.Common/Tizen.Applications/ResourceManager.cs
src/Tizen.Applications.MessagePort/Tizen.Applications.Messages/RemotePort.cs
src/Tizen.Context/Tizen.Context.AppHistory/AppStatistics.cs
src/Tizen.Multimedia.Recorder/Recorder/VideoRecorder.Capabilities.cs
src/Tizen.Multimedia.Recorder/Recorder/VideoRecorder.cs
src/Tizen.Multimedia.Remoting/ScreenMirroring/ScreenMirroring.cs
src/Tizen.Multimedia.Util/ThumbnailExtractor/ThumbnailExtractor.cs

index a7ddc1b..0327770 100755 (executable)
@@ -75,6 +75,8 @@ Tizen.Tracer
 Tizen.Uix.InputMethod
 Tizen.Uix.InputMethodManager
 Tizen.Uix.Stt
+Tizen.Uix.SttEngine
 Tizen.Uix.Tts
+Tizen.Uix.TtsEngine
 Tizen.Uix.VoiceControl
 Tizen.WebView
index 6ef6537..2bf9407 100644 (file)
@@ -222,6 +222,7 @@ namespace ElmSharp
                     Interop.Evas.evas_object_image_memfile_set(RealHandle, data, dataArr.Length, IntPtr.Zero, IntPtr.Zero);
                 }
             }
+            memstream.Dispose();
         }
 
         /// <summary>
index 5420e44..4f40932 100644 (file)
@@ -594,6 +594,8 @@ namespace ElmSharp
                 }
             }
 
+            memstream.Dispose();
+
             return await tcs.Task;
         }
 
index 9a45bbe..4e7b294 100644 (file)
@@ -304,7 +304,7 @@ namespace ElmSharp
         {
             set
             {
-                if (value.IsDefault)
+                if (value.IsDefault && ClassName != null)
                 {
                     string part = ClassName.ToLower().Replace("elm_", "") + "/" + "bg";
                     EdjeObject.DeleteColorClass(part);
diff --git a/src/Tizen.Applications.Common/Tizen.Applications.Exceptions/AppNotFoundException.cs b/src/Tizen.Applications.Common/Tizen.Applications.Exceptions/AppNotFoundException.cs
new file mode 100755 (executable)
index 0000000..6c9454d
--- /dev/null
@@ -0,0 +1,18 @@
+using System;
+
+namespace Tizen.Applications.Exceptions
+{
+    /// <summary>
+    /// The class that represents the exception which will be thrown when the application to run is not found
+    /// </summary>
+    public class AppNotFoundException : InvalidOperationException
+    {
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        /// <param name="message">The localized error message string</param>
+        public AppNotFoundException(string message) : base(message)
+        {
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications.Exceptions/LaunchFailedException.cs b/src/Tizen.Applications.Common/Tizen.Applications.Exceptions/LaunchFailedException.cs
new file mode 100755 (executable)
index 0000000..99085f7
--- /dev/null
@@ -0,0 +1,18 @@
+using System;
+
+namespace Tizen.Applications.Exceptions
+{
+    /// <summary>
+    /// The class that represents the exception which will be thrown when the request failed to launch the application
+    /// </summary>
+    public class LaunchFailedException : InvalidOperationException
+    {
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        /// <param name="message">The localized error message string</param>
+        public LaunchFailedException(string message) : base(message)
+        {
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications.Exceptions/LaunchRejectedException.cs b/src/Tizen.Applications.Common/Tizen.Applications.Exceptions/LaunchRejectedException.cs
new file mode 100755 (executable)
index 0000000..e89de76
--- /dev/null
@@ -0,0 +1,18 @@
+using System;
+
+namespace Tizen.Applications.Exceptions
+{
+    /// <summary>
+    /// The class that represents the exception which will be thrown when the launch request is rejected
+    /// </summary>
+    public class LaunchRejectedException : InvalidOperationException
+    {
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        /// <param name="message">The localized error message string</param>
+        public LaunchRejectedException(string message) : base(message)
+        {
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications.Exceptions/OutOfMemoryException.cs b/src/Tizen.Applications.Common/Tizen.Applications.Exceptions/OutOfMemoryException.cs
new file mode 100755 (executable)
index 0000000..f6c5967
--- /dev/null
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Tizen.Applications.Exceptions
+{
+    /// <summary>
+    /// The class that represents the exception which will be thrown when the memory is insufficient
+    /// </summary>
+    public class OutOfMemoryException : InvalidOperationException
+    {
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        /// <param name="message">The localized error message string</param>
+        public OutOfMemoryException(string message) : base(message)
+        {
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications.Exceptions/PermissionDeniedException.cs b/src/Tizen.Applications.Common/Tizen.Applications.Exceptions/PermissionDeniedException.cs
new file mode 100755 (executable)
index 0000000..015ae13
--- /dev/null
@@ -0,0 +1,18 @@
+using System;
+
+namespace Tizen.Applications.Exceptions
+{
+    /// <summary>
+    /// The class that represents the exception which will be thrown when the permission is denied
+    /// </summary>
+    public class PermissionDeniedException : InvalidOperationException
+    {
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        /// <param name="message">The localized error message string</param>
+        public PermissionDeniedException(string message) : base(message)
+        {
+        }
+    }
+}
index fd4c79c..a0e1f88 100755 (executable)
@@ -501,7 +501,11 @@ namespace Tizen.Applications
         /// <param name="launchRequest">The AppControl.</param>
         /// <param name="replyAfterLaunching">The callback function to be called when the reply is delivered.</param>
         /// <exception cref="ArgumentException">Thrown when failed because of the argument is invalid.</exception>
-        /// <exception cref="InvalidOperationException">Thrown when failed because of an invalid operation.</exception>
+        /// <exception cref="Exceptions.AppNotFoundException">Thrown when the application to run is not found.</exception>
+        /// <exception cref="Exceptions.LaunchFailedException">Thrown when the request failed to launch the application.</exception>
+        /// <exception cref="Exceptions.LaunchRejectedException">Thrown when the launch request is rejected.</exception>
+        /// <exception cref="Exceptions.OutOfMemoryException">Thrown when the memory is insufficient.</exception>
+        /// <exception cref="Exceptions.PermissionDeniedException">Thrown when the permission is denied.</exception>
         /// <exception cref="TimeoutException">Thrown when failed because of timeout.</exception>
         /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
         /// <example>
@@ -559,8 +563,19 @@ namespace Tizen.Applications
                         throw new ArgumentException("Invalid Arguments");
                     case Interop.AppControl.ErrorCode.TimedOut:
                         throw new TimeoutException("Timed out");
+                    case Interop.AppControl.ErrorCode.OutOfMemory:
+                        throw new Exceptions.OutOfMemoryException("Out-of-memory");
+                    case Interop.AppControl.ErrorCode.AppNotFound:
+                        throw new Exceptions.AppNotFoundException("App not found");
+                    case Interop.AppControl.ErrorCode.LaunchRejected:
+                        throw new Exceptions.LaunchRejectedException("Launch rejected");
+                    case Interop.AppControl.ErrorCode.LaunchFailed:
+                        throw new Exceptions.LaunchFailedException("Launch failed");
+                    case Interop.AppControl.ErrorCode.PermissionDenied:
+                        throw new Exceptions.PermissionDeniedException("Permission denied");
+
                     default:
-                        throw new InvalidOperationException("Error = " + err);
+                        throw new Exceptions.LaunchRejectedException("Launch rejected");
                 }
             }
         }
index 3212fac..d300c57 100755 (executable)
@@ -15,6 +15,7 @@
  */
 
 using System;
+using System.IO;
 using Tizen.Internals.Errors;
 
 namespace Tizen.Applications
@@ -105,8 +106,22 @@ namespace Tizen.Applications
         public static string TryGetPath(Category category, string id)
         {
             string path;
-            ErrorCode err = AppResourceManagerGet(category, id, out path);
+            ErrorCode err;
+            string res;
+
+            if (Application.Current != null)
+            {
+                res = Application.Current.DirectoryInfo.Resource + "res.xml";
+            }
+            else
+            {
+                res = Interop.AppCommon.AppGetResourcePath() + "res.xml";
+            }
+
+            if (!File.Exists(res))
+                return null;
 
+            err = AppResourceManagerGet(category, id, out path);
             switch (err)
             {
                 case ErrorCode.InvalidParameter:
index 5e9f541..561948d 100755 (executable)
@@ -150,7 +150,12 @@ namespace Tizen.Applications.Messages
                 Interop.MessagePort.CheckTrustedRemotePort(_appId, _portName, out _isRunning) :
                 Interop.MessagePort.CheckRemotePort(_appId, _portName, out _isRunning);
 
-            if (ret != (int)MessagePortError.None)
+            if (ret == (int)MessagePortError.CertificateNotMatch)
+            {
+                /* Although Remote port is NotMatch, it is running */
+                _isRunning = true;
+            }
+            else if (ret != (int)MessagePortError.None)
             {
                 MessagePortErrorFactory.ThrowException(ret);
             }
@@ -167,7 +172,7 @@ namespace Tizen.Applications.Messages
         /// <code>
         /// Remote remotePort = new RemotePort("org.tizen.example", "SenderPort", true);
         /// remotePort.RemotePortStateChanged += RemotePortStateChangedCallback;
-        /// static void RemotePortStateChangedCallback(object sender, MessageReceivedEventArgs e)
+        /// static void RemotePortStateChangedCallback(object sender, RemotePortStateChangedEventArgs e)
         /// {
         ///     switch (e.Status)
         ///     {
index c25b493..3cca79d 100644 (file)
@@ -28,7 +28,7 @@ namespace Tizen.Context.AppHistory
         internal const string AppStatsEndTime = "EndTime";
         internal const string AppStatsResultSize = "ResultSize";
         internal const string AppStatsAppId = "AppId";
-        internal const int DefaultResultSize = 5;
+        internal const int DefaultResultSize = 10;
 
         internal string Uri;
 
index 7e50b68..9c3e223 100644 (file)
@@ -73,7 +73,7 @@ namespace Tizen.Multimedia
                 return _frontResolutions ?? (_frontResolutions = LoadVideoResolutions(CameraDevice.Front));
             }
 
-            if (device == CameraDevice.Front)
+            if (device == CameraDevice.Rear)
             {
                 return _rearResolutions ?? (_rearResolutions = LoadVideoResolutions(CameraDevice.Rear));
             }
index fa8821a..23b9a83 100755 (executable)
@@ -75,7 +75,9 @@ namespace Tizen.Multimedia
         /// <exception cref="ArgumentException">
         ///     <paramref name="videoCodec"/> is not valid.\n
         ///     -or-\n
-        ///     <paramref name="fileFormat"/> is not valid.
+        ///     <paramref name="fileFormat"/> is not valid.\n
+        ///     -or-\n
+        ///     <paramref name="camera"/> is being used by another object.
         /// </exception>
         /// <exception cref="ObjectDisposedException"><paramref name="camera"/> has been disposed of.</exception>
         /// <exception cref="ArgumentNullException"><paramref name="camera"/> is null.</exception>
index 2d02dc8..4e0bd7d 100644 (file)
@@ -29,6 +29,7 @@ namespace Tizen.Multimedia.Remoting
     /// </summary>
     public class ScreenMirroring : IDisposable, IDisplayable<ScreenMirroringErrorCode>
     {
+        private const string Feature = "http://tizen.org/feature/network.wifi.direct.display";
         private const int Port = 2022;
 
         private IntPtr _handle;
@@ -47,6 +48,11 @@ namespace Tizen.Multimedia.Remoting
             }
         }
 
+        private static bool IsSupported()
+        {
+            return System.Information.TryGetValue(Feature, out bool isSupported) ? isSupported : false;
+        }
+
         /// <summary>
         /// Initializes a new instance of the ScreenMirroring class.
         /// </summary>
@@ -54,6 +60,11 @@ namespace Tizen.Multimedia.Remoting
         /// <exception cref="NotSupportedException">The feature is not supported.</exception>
         public ScreenMirroring()
         {
+            if (IsSupported() == false)
+            {
+                throw new PlatformNotSupportedException($"The feature({Feature}) is not supported on the current device");
+            }
+
             Native.Create(out _handle).ThrowIfError("Failed to create ScreenMirroring.");
 
             _state = new AtomicState();
index c9ff018..4ec117b 100755 (executable)
@@ -199,11 +199,11 @@ namespace Tizen.Multimedia.Util
                         byte[] tmpBuf = new byte[dataSize];
                         Marshal.Copy(thumbData, tmpBuf, 0, dataSize);
 
-                        tcs.SetResult(new ThumbnailExtractionResult(tmpBuf, thumbWidth, thumbHeight));
+                        tcs.TrySetResult(new ThumbnailExtractionResult(tmpBuf, thumbWidth, thumbHeight));
                     }
                     catch (Exception e)
                     {
-                        tcs.SetException(new InvalidOperationException("[" + error + "] Failed to copy data.", e));
+                        tcs.TrySetException(new InvalidOperationException("[" + error + "] Failed to copy data.", e));
                     }
                     finally
                     {
@@ -212,7 +212,7 @@ namespace Tizen.Multimedia.Util
                 }
                 else
                 {
-                    tcs.SetException(error.ToException("Failed to extract."));
+                    tcs.TrySetException(error.ToException("Failed to extract."));
                 }
             };
         }