Skip to content

Commit

Permalink
feat: EasClientDeviceInformation
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Dec 20, 2021
1 parent cb7edc2 commit fb8ba79
Show file tree
Hide file tree
Showing 7 changed files with 161 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
#pragma warning disable 114 // new keyword hiding
namespace Windows.Security.ExchangeActiveSyncProvisioning
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false || false || false || false || false || false || false
[global::Uno.NotImplemented]
#endif
public partial class EasClientDeviceInformation
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
#if false || false || false || false || false || false || false
[global::Uno.NotImplemented]
public string FriendlyName
{
get
Expand All @@ -17,8 +17,8 @@ public string FriendlyName
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
#if false || false || false || false || false || false || false
[global::Uno.NotImplemented]
public global::System.Guid Id
{
get
Expand All @@ -27,8 +27,8 @@ public string FriendlyName
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
#if false || false || false || false || false || false || false
[global::Uno.NotImplemented]
public string OperatingSystem
{
get
Expand All @@ -37,8 +37,8 @@ public string OperatingSystem
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
#if false || false || false || false || false || false || false
[global::Uno.NotImplemented]
public string SystemManufacturer
{
get
Expand All @@ -47,8 +47,8 @@ public string SystemManufacturer
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
#if false || false || false || false || false || false || false
[global::Uno.NotImplemented]
public string SystemProductName
{
get
Expand All @@ -57,8 +57,8 @@ public string SystemProductName
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
#if false || false || false || false || false || false || false
[global::Uno.NotImplemented]
public string SystemSku
{
get
Expand All @@ -67,8 +67,8 @@ public string SystemSku
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
#if false || false || false || false || false || false || false
[global::Uno.NotImplemented]
public string SystemFirmwareVersion
{
get
Expand All @@ -77,8 +77,8 @@ public string SystemFirmwareVersion
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
#if false || false || false || false || false || false || false
[global::Uno.NotImplemented]
public string SystemHardwareVersion
{
get
Expand All @@ -87,8 +87,8 @@ public string SystemHardwareVersion
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
#if false || false || false || false || false || false || false
[global::Uno.NotImplemented]
public EasClientDeviceInformation()
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation", "EasClientDeviceInformation.EasClientDeviceInformation()");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Uno.UI;
using Settings = Android.Provider.Settings;

namespace Windows.Security.ExchangeActiveSyncProvisioning
{
public partial class EasClientDeviceInformation
{
partial void Initialize()
{
OperatingSystem = "ANDROID";
SystemManufacturer = Android.OS.Build.Manufacturer;
SystemProductName = Android.OS.Build.Model;
FriendlyName = Settings.Global.GetString(ContextHelper.Current.ContentResolver, Settings.Global.DeviceName);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Windows.Security.ExchangeActiveSyncProvisioning
{
public partial class EasClientDeviceInformation
{
partial void Initialize()
{
OperatingSystem = Environment
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System;
using Uno;

namespace Windows.Security.ExchangeActiveSyncProvisioning
{
/// <summary>
/// Provides the app with the ability to retrieve device information from the local device.
/// </summary>
public partial class EasClientDeviceInformation
{
/// <summary>
/// Creates an instance of an object that allows the caller
/// app to retrieve device information from the local device.
/// </summary>
public EasClientDeviceInformation() => Initialize();

partial void Initialize();

/// <summary>
/// Gets the friendly name of the local device.
/// This value might come from a NetBIOS computer name.
/// </summary>
[NotImplemented("__ANDROID__", "__IOS__", "__WASM__", "__SKIA__", "__MACOS__")]
public string FriendlyName { get; private set; } = "";

/// <summary>
/// Returns the identifier of the local device.
/// </summary>
[NotImplemented("__ANDROID__", "__IOS__", "__WASM__", "__SKIA__", "__MACOS__")]
public Guid Id { get; private set; } = Guid.Empty;

/// <summary>
/// Gets the name of the operating system of the local device.
/// </summary>
public string OperatingSystem { get; private set; } = "";

/// <summary>
/// Gets the system manufacturer of the local device.
/// Use SystemManufacturer only if the value of SystemSku is empty.
/// </summary>
[NotImplemented("__WASM__")]
public string SystemManufacturer { get; private set; } = "";

/// <summary>
/// Gets the system product name of the local device.
/// Use SystemProductName only if the value of SystemSku is empty.
/// </summary>
[NotImplemented("__IOS__", "__WASM__", "__SKIA__", "__MACOS__")]
public string SystemProductName { get; private set; } = "";

/// <summary>
/// Gets the system SKU of the local device.
/// </summary>
public string SystemSku { get; private set; } = "";

/// <summary>
/// Gets the system firmware version of the local device.
/// </summary>
public string SystemFirmwareVersion { get; private set; } = "";

/// <summary>
/// Gets the system hardware version of the local device.
/// </summary>
public string SystemHardwareVersion { get; private set; } = "";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Windows.Security.ExchangeActiveSyncProvisioning
{
public partial class EasClientDeviceInformation
{
partial void Initialize()
{
OperatingSystem = "IOS";
SystemManufacturer = "Apple inc.";
SystemProductName = Android.OS.Build.Model;
FriendlyName = Settings.Global.GetString(ContextHelper.Current.ContentResolver, Settings.Global.DeviceName);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Windows.Security.ExchangeActiveSyncProvisioning
{
public partial class EasClientDeviceInformation
{
partial void Initialize()
{
OperatingSystem = "MACOS";
SystemManufacturer = "Apple inc.";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using static Uno.Foundation.WebAssemblyRuntime;

namespace Windows.Security.ExchangeActiveSyncProvisioning
{
public partial class EasClientDeviceInformation
{
private const string BrowserVersionFallback = "Unknown";
private const string JsType = "Windows.System.Profile.AnalyticsVersionInfo";

partial void Initialize()
{
OperatingSystem = "Browser";
SystemSku = GetUserAgent();
}

private string GetUserAgent()
{
var userAgent = InvokeJS(JsType + ".getUserAgent()");
if (!string.IsNullOrEmpty(userAgent))
{
return userAgent;
}
return BrowserVersionFallback;
}
}
}

0 comments on commit fb8ba79

Please sign in to comment.