From deaaacef3fcc1332f07fcf2eaa6d602a3e131c70 Mon Sep 17 00:00:00 2001 From: kichankwon <35328573+kichankwon@users.noreply.github.com> Date: Wed, 27 Mar 2019 14:08:36 +0900 Subject: [PATCH] [Information] No more convert for TV product (#766) - TV product is going to use enum values same with Public --- .../RuntimeInfo/RuntimeInfo.cs | 4 +- .../RuntimeInfo/RuntimeInfoEventHandler.cs | 9 +- .../RuntimeInfo/TvProductHelper.cs | 108 --------------------- 3 files changed, 6 insertions(+), 115 deletions(-) mode change 100644 => 100755 src/Tizen.System.Information/RuntimeInfo/RuntimeInfo.cs delete mode 100755 src/Tizen.System.Information/RuntimeInfo/TvProductHelper.cs diff --git a/src/Tizen.System.Information/RuntimeInfo/RuntimeInfo.cs b/src/Tizen.System.Information/RuntimeInfo/RuntimeInfo.cs old mode 100644 new mode 100755 index ba4a70a..f92ee56 --- a/src/Tizen.System.Information/RuntimeInfo/RuntimeInfo.cs +++ b/src/Tizen.System.Information/RuntimeInfo/RuntimeInfo.cs @@ -94,7 +94,7 @@ namespace Tizen.System if (type == typeof(bool)) { - InformationError ret = Interop.RuntimeInfo.GetValue(TvProductHelper.ConvertKeyIfTvProduct(key), out bool val); + InformationError ret = Interop.RuntimeInfo.GetValue(key, out bool val); if (ret != InformationError.None) { @@ -106,7 +106,7 @@ namespace Tizen.System } else if(type == typeof(int)) { - InformationError ret = Interop.RuntimeInfo.GetValue(TvProductHelper.ConvertKeyIfTvProduct(key), out int val); + InformationError ret = Interop.RuntimeInfo.GetValue(key, out int val); if (ret != InformationError.None) { diff --git a/src/Tizen.System.Information/RuntimeInfo/RuntimeInfoEventHandler.cs b/src/Tizen.System.Information/RuntimeInfo/RuntimeInfoEventHandler.cs index 8dde55d..9405f15 100755 --- a/src/Tizen.System.Information/RuntimeInfo/RuntimeInfoEventHandler.cs +++ b/src/Tizen.System.Information/RuntimeInfo/RuntimeInfoEventHandler.cs @@ -40,11 +40,10 @@ namespace Tizen.System __callback = (RuntimeInfoKey num, IntPtr userData) => { string strKey = "Invalid"; - RuntimeInfoKey key = TvProductHelper.ReconvertKeyIfTvProduct(num); - if (key > 0 && Information.EnumStringMapping.ContainsKey(key)) + if (num > 0 && Information.EnumStringMapping.ContainsKey(num)) { - strKey = Information.EnumStringMapping[key]; + strKey = Information.EnumStringMapping[num]; } RuntimeFeatureStatusChangedEventArgs eventArgs = new RuntimeFeatureStatusChangedEventArgs() @@ -55,7 +54,7 @@ namespace Tizen.System Handler?.Invoke(null, eventArgs); }; - InformationError ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(TvProductHelper.ConvertKeyIfTvProduct(Key), __callback, IntPtr.Zero); + InformationError ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(Key, __callback, IntPtr.Zero); if (ret != InformationError.None) { Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); @@ -69,7 +68,7 @@ namespace Tizen.System Handler -= value; if (Handler == null) { - InformationError ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(TvProductHelper.ConvertKeyIfTvProduct(Key)); + InformationError ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(Key); if (ret != InformationError.None) { Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); diff --git a/src/Tizen.System.Information/RuntimeInfo/TvProductHelper.cs b/src/Tizen.System.Information/RuntimeInfo/TvProductHelper.cs deleted file mode 100755 index 5454f25..0000000 --- a/src/Tizen.System.Information/RuntimeInfo/TvProductHelper.cs +++ /dev/null @@ -1,108 +0,0 @@ -/* -* Copyright (c) 2016 - 2017 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; -using System.Collections.Generic; - -namespace Tizen.System -{ - /// This class is for a TV product. It will be removed. - internal static class TvProductHelper - { - private static int is_TV_product = -1; - - private static readonly Dictionary s_keyTVkeyMapping = new Dictionary - { - [RuntimeInfoKey.Bluetooth] = 5, - [RuntimeInfoKey.WifiHotspot] = 6, - [RuntimeInfoKey.BluetoothTethering] = 7, - [RuntimeInfoKey.UsbTethering] = 8, - [RuntimeInfoKey.PacketData] = 13, - [RuntimeInfoKey.DataRoaming] = 14, - [RuntimeInfoKey.Vibration] = 16, - [RuntimeInfoKey.AudioJack] = 20, - [RuntimeInfoKey.BatteryIsCharging] = 22, - [RuntimeInfoKey.TvOut] = 18, - [RuntimeInfoKey.Charger] = 26, - [RuntimeInfoKey.AutoRotation] = 28, - [RuntimeInfoKey.Gps] = 21, - [RuntimeInfoKey.AudioJackConnector] = 20 - }; - - private static void CheckTvProduct() - { - bool is_key_existed = false; - string profile; - -#pragma warning disable CS0618 // Type or member is obsolete - is_key_existed = SystemInfo.TryGetValue("http://com.samsung/build_config/product_type", out profile); -#pragma warning restore CS0618 // Type or member is obsolete - if (is_key_existed && String.Compare(profile, "TV") == 0) - { - is_TV_product = 1; - } - else - { - is_TV_product = 0; - } - } - - internal static RuntimeInfoKey ConvertKeyIfTvProduct(RuntimeInfoKey key) - { - if (is_TV_product == -1) - { - CheckTvProduct(); - } - - if (is_TV_product == 1) - { - if (!s_keyTVkeyMapping.TryGetValue(key, out int key_TV)) - { - InformationErrorFactory.ThrowException(InformationError.InvalidParameter); - } - return (RuntimeInfoKey)key_TV; - } - else - { - return key; - } - } - - internal static RuntimeInfoKey ReconvertKeyIfTvProduct(RuntimeInfoKey key) - { - if (is_TV_product == -1) - { - CheckTvProduct(); - } - - if (is_TV_product == 1) - { - foreach (KeyValuePair kvp in s_keyTVkeyMapping) - { - if (kvp.Value == (int)key) - return kvp.Key; - } - - Log.Error(InformationErrorFactory.LogTag, "Key mapping failed"); - return 0; - } - else - { - return key; - } - } - } -} -- 2.7.4