From: kichankwon <35328573+kichankwon@users.noreply.github.com> Date: Tue, 16 Jan 2018 05:25:07 +0000 (+0900) Subject: Restore converted key before calling a callback (#30) X-Git-Tag: submit/tizen_4.0/20180116.112824~1^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=941fb9c2065e5eba8f7b2b7d3f573e18dde8f12a;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git Restore converted key before calling a callback (#30) --- diff --git a/src/Tizen.System.Information/RuntimeInfo/RuntimeInfoEventHandler.cs b/src/Tizen.System.Information/RuntimeInfo/RuntimeInfoEventHandler.cs old mode 100644 new mode 100755 index 973957d4d..011073afc --- a/src/Tizen.System.Information/RuntimeInfo/RuntimeInfoEventHandler.cs +++ b/src/Tizen.System.Information/RuntimeInfo/RuntimeInfoEventHandler.cs @@ -59,11 +59,19 @@ namespace Tizen.System } } - private void RuntimeInformationChangedCallback(RuntimeInfoKey key, IntPtr userData) + private void RuntimeInformationChangedCallback(RuntimeInfoKey num, IntPtr userData) { + string strKey = "Invalid"; + RuntimeInfoKey key = TvProductHelper.ReconvertKeyIfTvProduct(num); + + if (key > 0 && Information.EnumStringMapping.ContainsKey(key)) + { + strKey = Information.EnumStringMapping[key]; + } + RuntimeFeatureStatusChangedEventArgs eventArgs = new RuntimeFeatureStatusChangedEventArgs() { - Key = Information.HttpPrefix + Information.RuntimeInfoStringKeyPrefix + (Information.EnumStringMapping.ContainsKey(key) ? Information.EnumStringMapping[key] : "Invalid") + Key = Information.HttpPrefix + Information.RuntimeInfoStringKeyPrefix + strKey }; Handler?.Invoke(null, eventArgs); diff --git a/src/Tizen.System.Information/RuntimeInfo/TvProductHelper.cs b/src/Tizen.System.Information/RuntimeInfo/TvProductHelper.cs old mode 100644 new mode 100755 index ef5f84687..5454f2540 --- a/src/Tizen.System.Information/RuntimeInfo/TvProductHelper.cs +++ b/src/Tizen.System.Information/RuntimeInfo/TvProductHelper.cs @@ -19,6 +19,7 @@ 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; @@ -41,40 +42,67 @@ namespace Tizen.System [RuntimeInfoKey.AudioJackConnector] = 20 }; - /// This function is for a TV product. It will be removed. - internal static RuntimeInfoKey ConvertKeyIfTvProduct(RuntimeInfoKey key) + private static void CheckTvProduct() { bool is_key_existed = false; string profile; - int key_TV = -1; - if (is_TV_product == -1) - { #pragma warning disable CS0618 // Type or member is obsolete - is_key_existed = SystemInfo.TryGetValue("http://com.samsung/build_config/product_type", out profile); + 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; - } + if (is_key_existed && String.Compare(profile, "TV") == 0) + { + is_TV_product = 1; } + else + { + is_TV_product = 0; + } + } - if (is_TV_product == 0) + internal static RuntimeInfoKey ConvertKeyIfTvProduct(RuntimeInfoKey key) + { + if (is_TV_product == -1) { - return key; + CheckTvProduct(); } - else + + if (is_TV_product == 1) { - if (!s_keyTVkeyMapping.TryGetValue(key, out key_TV)) + 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; + } } } }