Skip to content
This repository was archived by the owner on May 15, 2024. It is now read-only.

Commit 852e563

Browse files
authored
Merge branch 'develop' into gh-1112
2 parents bc3c859 + 21a0a46 commit 852e563

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

Xamarin.Essentials/Permissions/Permissions.android.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ public override (string androidPermission, bool isRuntime)[] RequiredPermissions
230230
{
231231
var permissions = new List<(string, bool)>();
232232
#if __ANDROID_29__
233-
if (Platform.HasApiLevelQ)
233+
// Check if running and targeting Q
234+
if (Platform.HasApiLevelQ && Platform.AppContext.ApplicationInfo.TargetSdkVersion >= BuildVersionCodes.Q)
234235
permissions.Add((Manifest.Permission.AccessBackgroundLocation, true));
235236
#endif
236237

Xamarin.Essentials/Permissions/Permissions.ios.tvos.watchos.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public override async Task<PermissionStatus> RequestAsync()
100100
EnsureDeclared();
101101

102102
var status = GetLocationStatus(true);
103-
if (status == PermissionStatus.Granted)
103+
if (status == PermissionStatus.Granted || status == PermissionStatus.Disabled)
104104
return status;
105105

106106
EnsureMainThread();

Xamarin.Essentials/Platform/Platform.ios.tvos.watchos.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ internal static UIViewController GetCurrentViewController(bool throwIfNull = tru
6666

6767
var window = UIApplication.SharedApplication.KeyWindow;
6868

69-
if (window.WindowLevel == UIWindowLevel.Normal)
69+
if (window != null && window.WindowLevel == UIWindowLevel.Normal)
7070
viewController = window.RootViewController;
7171

7272
if (viewController == null)
@@ -76,13 +76,13 @@ internal static UIViewController GetCurrentViewController(bool throwIfNull = tru
7676
.OrderByDescending(w => w.WindowLevel)
7777
.FirstOrDefault(w => w.RootViewController != null && w.WindowLevel == UIWindowLevel.Normal);
7878

79-
if (window == null)
79+
if (window == null && throwIfNull)
8080
throw new InvalidOperationException("Could not find current view controller.");
8181
else
82-
viewController = window.RootViewController;
82+
viewController = window?.RootViewController;
8383
}
8484

85-
while (viewController.PresentedViewController != null)
85+
while (viewController?.PresentedViewController != null)
8686
viewController = viewController.PresentedViewController;
8787

8888
if (throwIfNull && viewController == null)
@@ -95,7 +95,7 @@ internal static UIWindow GetCurrentWindow(bool throwIfNull = true)
9595
{
9696
var window = UIApplication.SharedApplication.KeyWindow;
9797

98-
if (window.WindowLevel == UIWindowLevel.Normal)
98+
if (window != null && window.WindowLevel == UIWindowLevel.Normal)
9999
return window;
100100

101101
if (window == null)

0 commit comments

Comments
 (0)