From f1c6bfe93f17541e3f38b4be5cdcda7e55b5a23c Mon Sep 17 00:00:00 2001 From: JongIn Lee Date: Wed, 13 Jun 2018 15:53:51 +0900 Subject: [PATCH] Fix UWP issues - Fix IsDevice property get false on the real device - Fix crash when I call deviceInfo.Platform in UWP unit test --- src/DeviceInfo.Plugin/DeviceInfo.uwp.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/DeviceInfo.Plugin/DeviceInfo.uwp.cs b/src/DeviceInfo.Plugin/DeviceInfo.uwp.cs index 5761382..b9330ff 100644 --- a/src/DeviceInfo.Plugin/DeviceInfo.uwp.cs +++ b/src/DeviceInfo.Plugin/DeviceInfo.uwp.cs @@ -137,9 +137,16 @@ public Abstractions.Platform Platform case "Windows.Mobile": return Abstractions.Platform.WindowsPhone; case "Windows.Desktop": - return UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse - ? Abstractions.Platform.Windows - : Abstractions.Platform.WindowsTablet; + try + { + return UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse + ? Abstractions.Platform.Windows + : Abstractions.Platform.WindowsTablet; + } + catch + { + return Abstractions.Platform.Windows; + } case "Windows.IoT": return Abstractions.Platform.IoT; case "Windows.Xbox": @@ -212,6 +219,6 @@ public Idiom Idiom /// /// Source: http://igrali.com/2014/07/17/get-device-information-windows-phone-8-1-winrt/ /// - public bool IsDevice => deviceInfo.SystemProductName == "Virtual"; + public bool IsDevice => deviceInfo.SystemProductName != "Virtual"; } }