|
4 | 4 |
|
5 | 5 | namespace MXR.SDK {
|
6 | 6 | public static partial class MXRAndroidUtils {
|
| 7 | + /// <summary> |
| 8 | + /// The minimum Admin App version that supports the <see cref="DeviceData"/> features |
| 9 | + /// </summary> |
| 10 | + public static Version MinAdminAppVersionSupportingDeviceData => new Version(1, 7, 74); |
| 11 | + |
7 | 12 | /// <summary>
|
8 | 13 | /// Gets the class name using the package name of an app
|
9 | 14 | /// </summary>
|
@@ -92,16 +97,67 @@ public static void LaunchAppWithPackageAndClassNames(string packageName, string
|
92 | 97 | public static void LaunchIntentAction(string intentAction) =>
|
93 | 98 | NativeUtils.SafeCall<bool>("launchIntentAction", intentAction);
|
94 | 99 |
|
| 100 | + /// <summary> |
| 101 | + /// The package name of the Admin App installed on an Android device |
| 102 | + /// </summary> |
| 103 | + /// <returns>Returns null if unsuccessful</returns> |
| 104 | + public static string GetAdminAppPackageName() { |
| 105 | + if(NativeUtils != null) |
| 106 | + return NativeUtils.SafeCall<string>("getInstalledAdminAppPackageName"); |
| 107 | + return null; |
| 108 | + } |
95 | 109 |
|
96 |
| - public static string GetAdminAppPackageName() => |
97 |
| - NativeUtils.SafeCall<string>("getInstalledAdminAppPackageName"); |
98 |
| - |
| 110 | + /// <summary> |
| 111 | + /// The version code of the Admin App installed on an Android device |
| 112 | + /// </summary> |
| 113 | + /// <returns>Returns -1 if unsuccessful</returns> |
99 | 114 | public static int GetAdminAppVersionCode() {
|
100 | 115 | if (NativeUtils != null)
|
101 | 116 | return NativeUtils.SafeCall<int>("getInstalledAdminAppVersionCode");
|
102 | 117 | return -1;
|
103 | 118 | }
|
104 | 119 |
|
| 120 | + /// <summary> |
| 121 | + /// The version name string of the Admin App installed on an Android device |
| 122 | + /// </summary> |
| 123 | + /// <returns>Returns null if unsuccessful</returns> |
| 124 | + public static string GetAdminAppVersionName() { |
| 125 | + if (NativeUtils != null) |
| 126 | + return NativeUtils.SafeCall<string>("getInstalledAdminAppVersionName"); |
| 127 | + return null; |
| 128 | + } |
| 129 | + |
| 130 | + /// <summary> |
| 131 | + /// The <see cref="Version"/> of the Admin App installed on an Android device |
| 132 | + /// </summary> |
| 133 | + /// <returns>Returns null if the version name of the installed Admin App could not be retrieved |
| 134 | + /// or if the retrieved value is invalid. |
| 135 | + /// </returns> |
| 136 | + public static Version GetAdminAppVersion() { |
| 137 | + var versionName = GetAdminAppVersionName(); |
| 138 | + if (versionName == null) |
| 139 | + return null; |
| 140 | + |
| 141 | + // The version name may have a hyphen, e.g. "1.0.0-test" |
| 142 | + var versionString = versionName.Split('-')[0]; |
| 143 | + if (Version.TryParse(versionString, out var version)) |
| 144 | + return version; |
| 145 | + return null; |
| 146 | + } |
| 147 | + |
| 148 | + /// <summary> |
| 149 | + /// Whether the Admin App installed on an Android device supports the <see cref="DeviceData"/> features |
| 150 | + /// </summary> |
| 151 | + /// <returns>Returns false if the version of the installed Admin App could not be retrieved</returns> |
| 152 | + public static bool IsDeviceDataSupported { |
| 153 | + get { |
| 154 | + var version = GetAdminAppVersion(); |
| 155 | + if (version == null) |
| 156 | + return false; |
| 157 | + return version >= MinAdminAppVersionSupportingDeviceData; |
| 158 | + } |
| 159 | + } |
| 160 | + |
105 | 161 | /// <summary>
|
106 | 162 | /// Returns a system property using the android.os.SystemProperties.get method
|
107 | 163 | /// </summary>
|
|
0 commit comments