5ebb287382f747ee95c10dd87bc46bde6aaa0ea1
[profile/tv/apps/dotnet/home.git] / LibTVRefCommonPortable / Utils / AppControlUtils.cs
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd
3  *
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
7  *
8  *     http://floralicense.org/license/
9  *
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.
15  */
16
17 using Xamarin.Forms;
18
19 namespace LibTVRefCommonPortable.Utils
20 {
21     /// <summary>
22     /// A class provides App Control utility APIs.
23     /// </summary>
24     public sealed class AppControlUtils
25     {
26         /// <summary>
27         /// A method makes the package ID's app to be launched.
28         /// </summary>
29         /// <param name="pkgID">A package ID of the targeted application.</param>
30         public static void SendLaunchRequest(string pkgID)
31         {
32             if (DependencyService.Get<IAppControl>() == null)
33             {
34                 return;
35             }
36
37             DependencyService.Get<IAppControl>().SendLaunchRequest(pkgID);
38         }
39
40         /// <summary>
41         /// A method sends a add pin request App Control to TVApps app.
42         /// </summary>
43         public static void SendAddAppRequestToApps()
44         {
45             if (DependencyService.Get<IAppControl>() == null)
46             {
47                 return;
48             }
49
50             DependencyService.Get<IAppControl>().SendAddAppRequestToApps();
51         }
52
53         /// <summary>
54         /// A method sends a pin added notification App control to TVHome app.
55         /// </summary>
56         /// <param name="addedAddID">A app ID of newly added.</param>
57         public static void SendAppAddedNotificationToHome(string addedAddID)
58         {
59             if (DependencyService.Get<IAppControl>() == null)
60             {
61                 return;
62             }
63
64             DependencyService.Get<IAppControl>().SendAppAddedNotificationToHome(addedAddID);
65         }
66
67         /// <summary>
68         /// A method terminates caller application.
69         /// </summary>
70         public static void SelfTerminate()
71         {
72             if (DependencyService.Get<IAppLifeControl>() == null)
73             {
74                 return;
75             }
76
77             DependencyService.Get<IAppLifeControl>().SelfTerminate();
78         }
79     }
80 }