2 * Copyright (c) 2017 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (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
8 * http://floralicense.org/license/
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.
17 using LibTVRefCommonPortable.Stubs;
19 using System.Collections.Generic;
20 using System.Threading.Tasks;
23 namespace LibTVRefCommonPortable.Utils
26 /// A class provides application controlling functions
28 public sealed class ApplicationManagerUtils
31 /// A instance of platform specific application manager port.
33 private static IApplicationManagerAPIs applicationManagerAPIs;
36 /// A instance of ApplicationManagerUtils
38 private static readonly ApplicationManagerUtils instance = new ApplicationManagerUtils();
41 /// A getter of ApplicationManagerUtils instance
43 public static ApplicationManagerUtils Instance
54 private ApplicationManagerUtils()
56 applicationManagerAPIs = new ApplicationManagerAPITestStub();
60 if (DependencyService.Get<IApplicationManagerAPIs>() != null)
62 applicationManagerAPIs = DependencyService.Get<IApplicationManagerAPIs>();
65 catch (InvalidOperationException e)
67 DebuggingUtils.Err(e.Message);
72 /// A method for removing all recent applications
74 public void DeleteAllRecentApplication()
76 applicationManagerAPIs.DeleteAllRecentApplication();
80 /// A method for removing the specified recent application
82 /// <param name="appId">An application ID</param>
83 public void DeleteRecentApplication(string appId)
85 applicationManagerAPIs.DeleteRecentApplication(appId);
90 /// Gets the information of the recent applications
92 /// <returns>The list of the recent applications</returns>
93 public IEnumerable<RecentApp> GetRecentApplications()
95 return applicationManagerAPIs.GetRecentApplications();
99 /// Gets the information of the specified application with the app ID
101 /// <param name="appID">The app Id to get</param>
102 /// <returns>The information of the installed application</returns>
103 public InstalledApp GetInstalledApplication(string appID)
105 return applicationManagerAPIs.GetInstalledApplication(appID);
109 /// Gets the information of the installed applications asynchronously
111 /// <returns>The list of the installed applications</returns>
112 public Task<IEnumerable<InstalledApp>> GetAllInstalledApplication()
114 return applicationManagerAPIs.GetAllInstalledApplication();
118 /// Checks whether application is removable
120 /// <param name="appID">The app ID to get</param>
121 /// <returns>If the application is removable, true; otherwise, false</returns>
122 public bool GetAppInfoRemovable(string appID)
124 return applicationManagerAPIs.GetAppInfoRemovable(appID);
128 /// Gets the app ID by the app label
130 /// <param name="appLabel">the app label to get</param>
131 /// <returns>the app ID of the app label</returns>
132 public Task<string> GetAppIDbyAppLabel(string appLabel)
134 return applicationManagerAPIs.GetAppIDbyAppLabel(appLabel);