1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-18 09:13:15 +00:00
Files
mobile/src/UWP/Services/DeviceInfoService.cs
2017-10-02 22:38:10 -04:00

44 lines
1.3 KiB
C#

using Bit.App.Abstractions;
using Microsoft.Toolkit.Uwp.Helpers;
using System;
using System.Linq;
using System.Threading.Tasks;
using Windows.Graphics.Display;
using Windows.Devices.SmartCards;
using Windows.Devices.Enumeration;
namespace Bit.UWP.Services
{
public class DeviceInfoService : IDeviceInfoService
{
private const string SmartCardEmulatorType = "Windows.Devices.SmartCards.SmartCardEmulator";
public string Model => SystemInformation.DeviceModel;
public int Version => SystemInformation.OperatingSystemVersion.Build;
public float Scale => (float)DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;
public bool NfcEnabled
{
get
{
if(!Windows.Foundation.Metadata.ApiInformation.IsTypePresent(SmartCardEmulatorType))
{
return false;
}
return Task.Run(async () => await SmartCardEmulator.GetDefaultAsync()).Result != null;
}
}
public bool HasCamera
{
get
{
var cameraList = Task.Run(async () =>
await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture)).Result;
return cameraList?.Any() ?? false;
}
}
}
}