mirror of
https://github.com/bitwarden/android.git
synced 2025-01-11 18:57:39 +03:00
Fix for deadlock in iOS autofill & share extensions (#960)
This commit is contained in:
parent
fd1941cc3e
commit
473e93ea16
3 changed files with 25 additions and 24 deletions
|
@ -41,7 +41,7 @@ namespace Bit.iOS.Autofill
|
|||
};
|
||||
}
|
||||
|
||||
public override void PrepareCredentialList(ASCredentialServiceIdentifier[] serviceIdentifiers)
|
||||
public override async void PrepareCredentialList(ASCredentialServiceIdentifier[] serviceIdentifiers)
|
||||
{
|
||||
InitAppIfNeeded();
|
||||
_context.ServiceIdentifiers = serviceIdentifiers;
|
||||
|
@ -54,11 +54,11 @@ namespace Bit.iOS.Autofill
|
|||
}
|
||||
_context.UrlString = uri;
|
||||
}
|
||||
if (!IsAuthed())
|
||||
if (! await IsAuthed())
|
||||
{
|
||||
LaunchLoginFlow();
|
||||
}
|
||||
else if (IsLocked())
|
||||
else if (await IsLocked())
|
||||
{
|
||||
PerformSegue("lockPasswordSegue", this);
|
||||
}
|
||||
|
@ -75,10 +75,10 @@ namespace Bit.iOS.Autofill
|
|||
}
|
||||
}
|
||||
|
||||
public override void ProvideCredentialWithoutUserInteraction(ASPasswordCredentialIdentity credentialIdentity)
|
||||
public override async void ProvideCredentialWithoutUserInteraction(ASPasswordCredentialIdentity credentialIdentity)
|
||||
{
|
||||
InitAppIfNeeded();
|
||||
if (!IsAuthed() || IsLocked())
|
||||
if (! await IsAuthed() || await IsLocked())
|
||||
{
|
||||
var err = new NSError(new NSString("ASExtensionErrorDomain"),
|
||||
Convert.ToInt32(ASExtensionErrorCode.UserInteractionRequired), null);
|
||||
|
@ -86,13 +86,13 @@ namespace Bit.iOS.Autofill
|
|||
return;
|
||||
}
|
||||
_context.CredentialIdentity = credentialIdentity;
|
||||
ProvideCredentialAsync().GetAwaiter().GetResult();
|
||||
await ProvideCredentialAsync();
|
||||
}
|
||||
|
||||
public override void PrepareInterfaceToProvideCredential(ASPasswordCredentialIdentity credentialIdentity)
|
||||
public override async void PrepareInterfaceToProvideCredential(ASPasswordCredentialIdentity credentialIdentity)
|
||||
{
|
||||
InitAppIfNeeded();
|
||||
if (!IsAuthed())
|
||||
if (! await IsAuthed())
|
||||
{
|
||||
LaunchLoginFlow();
|
||||
return;
|
||||
|
@ -101,11 +101,11 @@ namespace Bit.iOS.Autofill
|
|||
CheckLock(async () => await ProvideCredentialAsync());
|
||||
}
|
||||
|
||||
public override void PrepareInterfaceForExtensionConfiguration()
|
||||
public override async void PrepareInterfaceForExtensionConfiguration()
|
||||
{
|
||||
InitAppIfNeeded();
|
||||
_context.Configuring = true;
|
||||
if (!IsAuthed())
|
||||
if (! await IsAuthed())
|
||||
{
|
||||
LaunchLoginFlow();
|
||||
return;
|
||||
|
@ -237,9 +237,9 @@ namespace Bit.iOS.Autofill
|
|||
CompleteRequest(decCipher.Id, decCipher.Login.Username, decCipher.Login.Password, totpCode);
|
||||
}
|
||||
|
||||
private void CheckLock(Action notLockedAction)
|
||||
private async void CheckLock(Action notLockedAction)
|
||||
{
|
||||
if (IsLocked())
|
||||
if (await IsLocked())
|
||||
{
|
||||
PerformSegue("lockPasswordSegue", this);
|
||||
}
|
||||
|
@ -249,16 +249,16 @@ namespace Bit.iOS.Autofill
|
|||
}
|
||||
}
|
||||
|
||||
private bool IsLocked()
|
||||
private Task<bool> IsLocked()
|
||||
{
|
||||
var vaultTimeoutService = ServiceContainer.Resolve<IVaultTimeoutService>("vaultTimeoutService");
|
||||
return vaultTimeoutService.IsLockedAsync().GetAwaiter().GetResult();
|
||||
return vaultTimeoutService.IsLockedAsync();
|
||||
}
|
||||
|
||||
private bool IsAuthed()
|
||||
private Task<bool> IsAuthed()
|
||||
{
|
||||
var userService = ServiceContainer.Resolve<IUserService>("userService");
|
||||
return userService.IsAuthenticatedAsync().GetAwaiter().GetResult();
|
||||
return userService.IsAuthenticatedAsync();
|
||||
}
|
||||
|
||||
private void InitApp()
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace Bit.iOS.Autofill
|
|||
|
||||
ActivatedLabel.Text = AppResources.AutofillActivated;
|
||||
ActivatedLabel.Font = UIFont.FromDescriptor(descriptor, descriptor.PointSize * 1.3f);
|
||||
ActivatedLabel.TextColor = ThemeHelpers.SuccessColor;
|
||||
|
||||
BackButton.Title = AppResources.Back;
|
||||
base.ViewDidLoad();
|
||||
|
|
|
@ -6,9 +6,9 @@ using Bit.iOS.Core;
|
|||
using Bit.iOS.Extension.Models;
|
||||
using MobileCoreServices;
|
||||
using Bit.iOS.Core.Utilities;
|
||||
using Bit.App.Resources;
|
||||
using Bit.iOS.Core.Controllers;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.iOS.Core.Models;
|
||||
using Bit.Core.Utilities;
|
||||
using Bit.Core.Abstractions;
|
||||
|
@ -63,7 +63,7 @@ namespace Bit.iOS.Extension
|
|||
}
|
||||
}
|
||||
|
||||
public override void ViewDidAppear(bool animated)
|
||||
public override async void ViewDidAppear(bool animated)
|
||||
{
|
||||
base.ViewDidAppear(animated);
|
||||
if (_context.ProviderType == Constants.UTTypeAppExtensionSetup)
|
||||
|
@ -71,12 +71,12 @@ namespace Bit.iOS.Extension
|
|||
PerformSegue("setupSegue", this);
|
||||
return;
|
||||
}
|
||||
if (!IsAuthed())
|
||||
if (! await IsAuthed())
|
||||
{
|
||||
LaunchLoginFlow();
|
||||
return;
|
||||
}
|
||||
else if (IsLocked())
|
||||
else if (await IsLocked())
|
||||
{
|
||||
PerformSegue("lockPasswordSegue", this);
|
||||
}
|
||||
|
@ -408,16 +408,16 @@ namespace Bit.iOS.Extension
|
|||
iOSCoreHelpers.SubscribeBroadcastReceiver(this, _nfcSession, _nfcDelegate);
|
||||
}
|
||||
|
||||
private bool IsLocked()
|
||||
private Task<bool> IsLocked()
|
||||
{
|
||||
var vaultTimeoutService = ServiceContainer.Resolve<IVaultTimeoutService>("vaultTimeoutService");
|
||||
return vaultTimeoutService.IsLockedAsync().GetAwaiter().GetResult();
|
||||
return vaultTimeoutService.IsLockedAsync();
|
||||
}
|
||||
|
||||
private bool IsAuthed()
|
||||
private Task<bool> IsAuthed()
|
||||
{
|
||||
var userService = ServiceContainer.Resolve<IUserService>("userService");
|
||||
return userService.IsAuthenticatedAsync().GetAwaiter().GetResult();
|
||||
return userService.IsAuthenticatedAsync();
|
||||
}
|
||||
|
||||
private void LaunchLoginFlow()
|
||||
|
|
Loading…
Reference in a new issue