[SystemInfo] Remove build warnings
[platform/core/csapi/tizenfx.git] / src / Tizen.System.Information / RuntimeInfo / TvProductHelper.cs
1 /*
2 * Copyright (c) 2016 - 2017 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (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://www.apache.org/licenses/LICENSE-2.0
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 System;
18 using System.Collections.Generic;
19
20 namespace Tizen.System
21 {
22     internal static class TvProductHelper
23     {
24         private static int is_TV_product = -1;
25
26         private static readonly Dictionary<RuntimeInfoKey, int> s_keyTVkeyMapping = new Dictionary<RuntimeInfoKey, int>
27         {
28             [RuntimeInfoKey.Bluetooth] = 5,
29             [RuntimeInfoKey.WifiHotspot] = 6,
30             [RuntimeInfoKey.BluetoothTethering] = 7,
31             [RuntimeInfoKey.UsbTethering] = 8,
32             [RuntimeInfoKey.PacketData] = 13,
33             [RuntimeInfoKey.DataRoaming] = 14,
34             [RuntimeInfoKey.Vibration] = 16,
35             [RuntimeInfoKey.AudioJack] = 20,
36             [RuntimeInfoKey.BatteryIsCharging] = 22,
37             [RuntimeInfoKey.TvOut] = 18,
38             [RuntimeInfoKey.Charger] = 26,
39             [RuntimeInfoKey.AutoRotation] = 28,
40             [RuntimeInfoKey.Gps] = 21,
41             [RuntimeInfoKey.AudioJackConnector] = 20
42         };
43
44         /// This function is for a TV product. It will be removed.
45         internal static RuntimeInfoKey ConvertKeyIfTvProduct(RuntimeInfoKey key)
46         {
47             bool is_key_existed = false;
48             string profile;
49             int key_TV = -1;
50
51             if (is_TV_product == -1)
52             {
53 #pragma warning disable CS0618 // Type or member is obsolete
54                 is_key_existed = SystemInfo.TryGetValue<string>("http://com.samsung/build_config/product_type", out profile);
55 #pragma warning restore CS0618 // Type or member is obsolete
56                 if (is_key_existed && String.Compare(profile, "TV") == 0)
57                 {
58                     is_TV_product = 1;
59                 }
60                 else
61                 {
62                     is_TV_product = 0;
63                 }
64             }
65
66             if (is_TV_product == 0)
67             {
68                 return key;
69             }
70             else
71             {
72                 if (!s_keyTVkeyMapping.TryGetValue(key, out key_TV))
73                 {
74                     InformationErrorFactory.ThrowException(InformationError.InvalidParameter);
75                 }
76                 return (RuntimeInfoKey)key_TV;
77             }
78         }
79     }
80 }