Release 4.0.0-preview1-00201
[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 using System.ComponentModel;
20
21 namespace Tizen.System
22 {
23     [EditorBrowsable(EditorBrowsableState.Never)]
24     internal static class TvProductHelper
25     {
26         private static int is_TV_product = -1;
27
28         private static readonly Dictionary<RuntimeInfoKey, int> s_keyTVkeyMapping = new Dictionary<RuntimeInfoKey, int>
29         {
30             [RuntimeInfoKey.Bluetooth] = 5,
31             [RuntimeInfoKey.WifiHotspot] = 6,
32             [RuntimeInfoKey.BluetoothTethering] = 7,
33             [RuntimeInfoKey.UsbTethering] = 8,
34             [RuntimeInfoKey.PacketData] = 13,
35             [RuntimeInfoKey.DataRoaming] = 14,
36             [RuntimeInfoKey.Vibration] = 16,
37             [RuntimeInfoKey.AudioJack] = 20,
38             [RuntimeInfoKey.BatteryIsCharging] = 22,
39             [RuntimeInfoKey.TvOut] = 18,
40             [RuntimeInfoKey.Charger] = 26,
41             [RuntimeInfoKey.AutoRotation] = 28,
42             [RuntimeInfoKey.Gps] = 21,
43             [RuntimeInfoKey.AudioJackConnector] = 20
44         };
45
46         /// This function is for a TV product. It will be removed.
47         internal static RuntimeInfoKey ConvertKeyIfTvProduct(RuntimeInfoKey key)
48         {
49             bool is_key_existed = false;
50             string profile;
51             int key_TV = -1;
52
53             if (is_TV_product == -1)
54             {
55                 is_key_existed = SystemInfo.TryGetValue<string>("http://com.samsung/build_config/product_type", out profile);
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 }