Add comments for AppControlPort.cs & ApplicationManagerPort.cs
authorGeunsun, Lee <gs86.lee@samsung.com>
Tue, 28 Mar 2017 10:39:20 +0000 (19:39 +0900)
committerChulSeung Kim <charles0.kim@samsung.com>
Thu, 8 Jun 2017 09:34:51 +0000 (18:34 +0900)
Change-Id: I93f5b331c8dc469a642533df94d06da277651b07

LibTVRefCommonTizen/Ports/AppControlPort.cs
LibTVRefCommonTizen/Ports/ApplicationManagerPort.cs

index b946580..d3762ae 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/*
  * Copyright (c) 2017 Samsung Electronics Co., Ltd
  *
  * Licensed under the Flora License, Version 1.1 (the "License");
@@ -22,7 +22,7 @@ using Tizen.Applications;
 namespace LibTVRefCommonTizen.Ports
 {
     /// <summary>
-    /// This class is for AppControl API
+    /// Handles the Appcontrol APIs
     /// </summary>
     public class AppControlPort : IAppControl
     {
@@ -38,11 +38,13 @@ namespace LibTVRefCommonTizen.Ports
         public static string TVAppsAppID = "org.tizen.example.TVApps.TizenTV";
 
         /// <summary>
+        /// Represents the operation to be performed between TVHome and TVApps
         /// This operation is sended from TVHomes to TVApps
         /// </summary>
         public static string AddAppOperation = "http://xahome.tizen.org/appcontrol/operation/add_app";
 
         /// <summary>
+        /// Represents the operation to be performed between TVHome and TVApps
         /// This operation is sended from TVApps to TVHome
         /// </summary>
         public static string AppAddedNotifyOperation = "http://xahome.tizen.org/appcontrol/operation/app_added";
index 2995618..6610a01 100644 (file)
 using System;
 using System.Collections.Generic;
 using System.Threading.Tasks;
-using Xamarin.Forms.Platform.Tizen.Native;
-using Tizen;
 using Tizen.Applications;
 using LibTVRefCommonPortable.Utils;
 
 namespace LibTVRefCommonTizen.Ports
 {
+    /// <summary>
+    /// Handles the ApplicationsManager APIs
+    /// </summary>
     public class ApplicationManagerPort : IApplicationManagerAPIs
     {
+        /// <summary>
+        /// Defines the default app icon
+        /// If the app icon is not exist, shows the default app icon
+        /// </summary>
         private static String DefaultAppIcon = "AppIcon.png";
 
+        /// <summary>
+        /// The constructor of this class
+        /// Adds the EventHandler for ApplicationLaunched
+        /// </summary>
         public ApplicationManagerPort()
         {
             ApplicationManager.ApplicationLaunched += new EventHandler<ApplicationLaunchedEventArgs>(OnApplicationLaunched);
         }
 
+        /// <summary>
+        /// Arguments for the event that is raised when the application is launched
+        /// </summary>
+        /// <param name="sender">The source of the event</param>
+        /// <param name="args">An object that contains no event data</param>
+        /// <remarks>
+        /// https://msdn.microsoft.com/en-us/library/system.eventhandler(v=vs.110).aspx
+        /// </remarks>
         void OnApplicationLaunched(object sender, EventArgs args)
         {
             ApplicationLaunchedEventArgs launchedEventArgs = args as ApplicationLaunchedEventArgs;
             DebuggingUtils.Dbg(launchedEventArgs.ApplicationRunningContext.ApplicationId + " launched");
         }
 
+        /// <summary>
+        /// Gets the information of the recent applications
+        /// </summary>
+        /// <returns>The list of the recent applications</returns>
         public IEnumerable<RecentApp> GetRecentApplications()
         {
             List<RecentApp> resultList = new List<RecentApp>();
-            IEnumerable<RecentApplicationInfo> recentApps = ApplicationManager.GetRecentApplications();
-
-            foreach (var app in recentApps)
+            try
             {
-                if (app.IsNoDisplay ||
-                    app.ApplicationId == null ||
-                    app.ApplicationId.Length < 1)
-                {
-                    continue;
-                }
+                IEnumerable<RecentApplicationInfo> recentApps = ApplicationManager.GetRecentApplications();
 
-                resultList.Add(new RecentApp()
+                foreach (var app in recentApps)
                 {
-                    instanceID = app.InstanceId,
-                    instanceLabel = app.InstanceName,
-                    appID = app.ApplicationId,
-                    applabel = (app.Label == null || app.Label.Length < 1) ? "No Name" : app.Label,
-                    iconPath = app.IconPath,
-                    launchedTime = app.LaunchTime,
-                    uri = app.Uri,
-                });
+                    if (app.IsNoDisplay ||
+                        app.ApplicationId == null ||
+                        app.ApplicationId.Length < 1)
+                    {
+                        continue;
+                    }
+
+                    resultList.Add(new RecentApp()
+                    {
+                        instanceID = app.InstanceId,
+                        instanceLabel = app.InstanceName,
+                        appID = app.ApplicationId,
+                        applabel = (app.Label == null || app.Label.Length < 1) ? "No Name" : app.Label,
+                        iconPath = app.IconPath,
+                        launchedTime = app.LaunchTime,
+                        uri = app.Uri,
+                    });
+                }
+            }
+            catch (InvalidOperationException)
+            {
+                DebuggingUtils.Err("Failed to get the information of the recent applications");
+                return null;
             }
 
             return resultList;
         }
 
-        public Dictionary<string, string> GetInstalledApplication(string applicationId)
+        /// <summary>
+        /// Gets the information of the specified application with the app ID
+        /// </summary>
+        /// <param name="appID">The app Id you want to get</param>
+        /// <returns>The information of the installed applications</returns>
+        public Dictionary<string, string> GetInstalledApplication(string appID)
         {
             Dictionary<string, string> result = null;
             ApplicationInfo appInfo = null;
 
             try
             {
-                appInfo = ApplicationManager.GetInstalledApplication(applicationId);
+                appInfo = ApplicationManager.GetInstalledApplication(appID);
                 if (appInfo == null)
                 {
                     DbgPort.D("GetInstalledApplication failed");
@@ -89,13 +123,17 @@ namespace LibTVRefCommonTizen.Ports
             }
             catch (Exception exception)
             {
-                DbgPort.E("Exception " + applicationId + " :" + exception.Message);
+                DbgPort.E("Exception " + appID + " :" + exception.Message);
                 return null;
             }
 
             return result;
         }
 
+        /// <summary>
+        /// Gets the information of the installed applications asynchronously
+        /// </summary>
+        /// <returns>The list of the installed applications</returns>
         public async Task<Dictionary<string, string[]>> GetAllInstalledApplication()
         {
             try