public static void RegisterLocalServices() { if (ServiceContainer.Resolve <ILogService>("logService", true) == null) { ServiceContainer.Register <ILogService>("logService", new ConsoleLogService()); } var preferencesStorage = new PreferencesStorageService(AppGroupId); var appGroupContainer = new NSFileManager().GetContainerUrl(AppGroupId); var liteDbStorage = new LiteDbStorageService( Path.Combine(appGroupContainer.Path, "Library", "bitwarden.db")); liteDbStorage.InitAsync(); var localizeService = new LocalizeService(); var broadcasterService = new BroadcasterService(); var messagingService = new MobileBroadcasterMessagingService(broadcasterService); var i18nService = new MobileI18nService(localizeService.GetCurrentCultureInfo()); var secureStorageService = new KeyChainStorageService(AppId, AccessGroup, () => ServiceContainer.Resolve <IAppIdService>("appIdService").GetAppIdAsync()); var cryptoPrimitiveService = new CryptoPrimitiveService(); var mobileStorageService = new MobileStorageService(preferencesStorage, liteDbStorage); var deviceActionService = new DeviceActionService(mobileStorageService, messagingService); var platformUtilsService = new MobilePlatformUtilsService(deviceActionService, messagingService, broadcasterService); ServiceContainer.Register <IBroadcasterService>("broadcasterService", broadcasterService); ServiceContainer.Register <IMessagingService>("messagingService", messagingService); ServiceContainer.Register <ILocalizeService>("localizeService", localizeService); ServiceContainer.Register <II18nService>("i18nService", i18nService); ServiceContainer.Register <ICryptoPrimitiveService>("cryptoPrimitiveService", cryptoPrimitiveService); ServiceContainer.Register <IStorageService>("storageService", mobileStorageService); ServiceContainer.Register <IStorageService>("secureStorageService", secureStorageService); ServiceContainer.Register <IDeviceActionService>("deviceActionService", deviceActionService); ServiceContainer.Register <IPlatformUtilsService>("platformUtilsService", platformUtilsService); }
private void RegisterLocalServices() { ServiceContainer.Register <ILogService>("logService", new AndroidLogService()); // Note: This might cause a race condition. Investigate more. Task.Run(() => { FFImageLoading.Forms.Platform.CachedImageRenderer.Init(true); FFImageLoading.ImageService.Instance.Initialize(new FFImageLoading.Config.Configuration { FadeAnimationEnabled = false, FadeAnimationForCachedImages = false }); ZXing.Net.Mobile.Forms.Android.Platform.Init(); }); CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity); var preferencesStorage = new PreferencesStorageService(null); var documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); var liteDbStorage = new LiteDbStorageService(Path.Combine(documentsPath, "bitwarden.db")); var localizeService = new LocalizeService(); var broadcasterService = new BroadcasterService(); var messagingService = new MobileBroadcasterMessagingService(broadcasterService); var i18nService = new MobileI18nService(localizeService.GetCurrentCultureInfo()); var secureStorageService = new SecureStorageService(); var cryptoPrimitiveService = new CryptoPrimitiveService(); var mobileStorageService = new MobileStorageService(preferencesStorage, liteDbStorage); var deviceActionService = new DeviceActionService(mobileStorageService, messagingService, broadcasterService, () => ServiceContainer.Resolve <IEventService>("eventService")); var platformUtilsService = new MobilePlatformUtilsService(deviceActionService, messagingService, broadcasterService); var biometricService = new BiometricService(); ServiceContainer.Register <IBroadcasterService>("broadcasterService", broadcasterService); ServiceContainer.Register <IMessagingService>("messagingService", messagingService); ServiceContainer.Register <ILocalizeService>("localizeService", localizeService); ServiceContainer.Register <II18nService>("i18nService", i18nService); ServiceContainer.Register <ICryptoPrimitiveService>("cryptoPrimitiveService", cryptoPrimitiveService); ServiceContainer.Register <IStorageService>("storageService", mobileStorageService); ServiceContainer.Register <IStorageService>("secureStorageService", secureStorageService); ServiceContainer.Register <IDeviceActionService>("deviceActionService", deviceActionService); ServiceContainer.Register <IPlatformUtilsService>("platformUtilsService", platformUtilsService); ServiceContainer.Register <IBiometricService>("biometricService", biometricService); // Push #if FDROID ServiceContainer.Register <IPushNotificationListenerService>( "pushNotificationListenerService", new NoopPushNotificationListenerService()); ServiceContainer.Register <IPushNotificationService>( "pushNotificationService", new NoopPushNotificationService()); #else var notificationListenerService = new PushNotificationListenerService(); ServiceContainer.Register <IPushNotificationListenerService>( "pushNotificationListenerService", notificationListenerService); var androidPushNotificationService = new AndroidPushNotificationService( mobileStorageService, notificationListenerService); ServiceContainer.Register <IPushNotificationService>( "pushNotificationService", androidPushNotificationService); #endif }
public static void RegisterLocalServices() { if (ServiceContainer.Resolve <INativeLogService>("nativeLogService", true) == null) { ServiceContainer.Register <INativeLogService>("nativeLogService", new ConsoleLogService()); } ILogger logger = null; if (ServiceContainer.Resolve <ILogger>("logger", true) == null) { #if DEBUG logger = DebugLogger.Instance; #else logger = Logger.Instance; #endif ServiceContainer.Register("logger", logger); } var preferencesStorage = new PreferencesStorageService(AppGroupId); var appGroupContainer = new NSFileManager().GetContainerUrl(AppGroupId); var liteDbStorage = new LiteDbStorageService( Path.Combine(appGroupContainer.Path, "Library", "bitwarden.db")); var localizeService = new LocalizeService(); var broadcasterService = new BroadcasterService(logger); var messagingService = new MobileBroadcasterMessagingService(broadcasterService); var i18nService = new MobileI18nService(localizeService.GetCurrentCultureInfo()); var secureStorageService = new KeyChainStorageService(AppId, AccessGroup, () => ServiceContainer.Resolve <IAppIdService>("appIdService").GetAppIdAsync()); var cryptoPrimitiveService = new CryptoPrimitiveService(); var mobileStorageService = new MobileStorageService(preferencesStorage, liteDbStorage); var stateService = new StateService(mobileStorageService, secureStorageService, messagingService); var stateMigrationService = new StateMigrationService(liteDbStorage, preferencesStorage, secureStorageService); var deviceActionService = new DeviceActionService(stateService, messagingService); var clipboardService = new ClipboardService(stateService); var platformUtilsService = new MobilePlatformUtilsService(deviceActionService, clipboardService, messagingService, broadcasterService); var biometricService = new BiometricService(mobileStorageService); var cryptoFunctionService = new PclCryptoFunctionService(cryptoPrimitiveService); var cryptoService = new CryptoService(stateService, cryptoFunctionService); var passwordRepromptService = new MobilePasswordRepromptService(platformUtilsService, cryptoService); ServiceContainer.Register <IBroadcasterService>("broadcasterService", broadcasterService); ServiceContainer.Register <IMessagingService>("messagingService", messagingService); ServiceContainer.Register <ILocalizeService>("localizeService", localizeService); ServiceContainer.Register <II18nService>("i18nService", i18nService); ServiceContainer.Register <ICryptoPrimitiveService>("cryptoPrimitiveService", cryptoPrimitiveService); ServiceContainer.Register <IStorageService>("storageService", mobileStorageService); ServiceContainer.Register <IStorageService>("secureStorageService", secureStorageService); ServiceContainer.Register <IStateService>("stateService", stateService); ServiceContainer.Register <IStateMigrationService>("stateMigrationService", stateMigrationService); ServiceContainer.Register <IDeviceActionService>("deviceActionService", deviceActionService); ServiceContainer.Register <IClipboardService>("clipboardService", clipboardService); ServiceContainer.Register <IPlatformUtilsService>("platformUtilsService", platformUtilsService); ServiceContainer.Register <IBiometricService>("biometricService", biometricService); ServiceContainer.Register <ICryptoFunctionService>("cryptoFunctionService", cryptoFunctionService); ServiceContainer.Register <ICryptoService>("cryptoService", cryptoService); ServiceContainer.Register <IPasswordRepromptService>("passwordRepromptService", passwordRepromptService); }
private async void CipherSelected(object sender, SelectedItemChangedEventArgs e) { var cipher = e.SelectedItem as AutofillCipher; if (cipher == null) { return; } if (_deviceInfoService.Version < 21) { Helpers.CipherMoreClickedAsync(this, cipher, true); } else { bool doAutofill = true; if (cipher.Fuzzy) { doAutofill = await DisplayAlert(null, string.Format(AppResources.BitwardenAutofillServiceMatchConfirm, _name), AppResources.Yes, AppResources.No); } if (doAutofill) { GoogleAnalyticsService.TrackExtensionEvent("AutoFilled", Uri.StartsWith("http") ? "Website" : "App"); DeviceActionService.Autofill(cipher); } } ((ListView)sender).SelectedItem = null; }
public DevicesController(MediatorForStorages <AdInputType> mediatorForStorages, DeviceActionService <AdInputType> deviceActionService, ILogger logger) { _mediatorForStorages = mediatorForStorages; _deviceActionService = deviceActionService; _logger = logger; }
private void RegisterLocalServices() { Refractored.FabControl.Droid.FloatingActionButtonViewRenderer.Init(); // Note: This might cause a race condition. Investigate more. Task.Run(() => { FFImageLoading.Forms.Platform.CachedImageRenderer.Init(true); ZXing.Net.Mobile.Forms.Android.Platform.Init(); }); CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity); var preferencesStorage = new PreferencesStorageService(null); var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); var liteDbStorage = new LiteDbStorageService(Path.Combine(documentsPath, "bitwarden.db")); liteDbStorage.InitAsync(); var localizeService = new LocalizeService(); var broadcasterService = new BroadcasterService(); var messagingService = new MobileBroadcasterMessagingService(broadcasterService); var i18nService = new MobileI18nService(localizeService.GetCurrentCultureInfo()); var secureStorageService = new SecureStorageService(); var cryptoPrimitiveService = new CryptoPrimitiveService(); var mobileStorageService = new MobileStorageService(preferencesStorage, liteDbStorage); var deviceActionService = new DeviceActionService(mobileStorageService, messagingService, broadcasterService); var platformUtilsService = new MobilePlatformUtilsService(deviceActionService, messagingService, broadcasterService); ServiceContainer.Register <IBroadcasterService>("broadcasterService", broadcasterService); ServiceContainer.Register <IMessagingService>("messagingService", messagingService); ServiceContainer.Register <ILocalizeService>("localizeService", localizeService); ServiceContainer.Register <II18nService>("i18nService", i18nService); ServiceContainer.Register <ICryptoPrimitiveService>("cryptoPrimitiveService", cryptoPrimitiveService); ServiceContainer.Register <IStorageService>("storageService", mobileStorageService); ServiceContainer.Register <IStorageService>("secureStorageService", secureStorageService); ServiceContainer.Register <IDeviceActionService>("deviceActionService", deviceActionService); ServiceContainer.Register <IPlatformUtilsService>("platformUtilsService", platformUtilsService); // Push #if FDROID container.RegisterSingleton <IPushNotificationListener, NoopPushNotificationListener>(); container.RegisterSingleton <IPushNotificationService, NoopPushNotificationService>(); #else var notificationListenerService = new PushNotificationListenerService(); ServiceContainer.Register <IPushNotificationListenerService>( "pushNotificationListenerService", notificationListenerService); var androidPushNotificationService = new AndroidPushNotificationService( mobileStorageService, notificationListenerService); ServiceContainer.Register <IPushNotificationService>( "pushNotificationService", androidPushNotificationService); #endif }
public async void ByDeviceId_Not_Exists() { var mock = new ServiceMockFacade <IDeviceActionService, IDeviceActionRepository>(); mock.RepositoryMock.Setup(x => x.ByDeviceId(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult <List <DeviceAction> >(new List <DeviceAction>())); var service = new DeviceActionService(mock.LoggerMock.Object, mock.MediatorMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.DeviceActionModelValidatorMock.Object, mock.DALMapperMockFactory.DALDeviceActionMapperMock); List <ApiDeviceActionServerResponseModel> response = await service.ByDeviceId(default(int)); response.Should().BeEmpty(); mock.RepositoryMock.Verify(x => x.ByDeviceId(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>())); }
public async void Get_ShouldReturnNullBecauseRecordNotFound() { var mock = new ServiceMockFacade <IDeviceActionService, IDeviceActionRepository>(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <DeviceAction>(null)); var service = new DeviceActionService(mock.LoggerMock.Object, mock.MediatorMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.DeviceActionModelValidatorMock.Object, mock.DALMapperMockFactory.DALDeviceActionMapperMock); ApiDeviceActionServerResponseModel response = await service.Get(default(int)); response.Should().BeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>())); }
public async void Get() { var mock = new ServiceMockFacade <IDeviceActionRepository>(); var record = new DeviceAction(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record)); var service = new DeviceActionService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.DeviceActionModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLDeviceActionMapperMock, mock.DALMapperMockFactory.DALDeviceActionMapperMock); ApiDeviceActionResponseModel response = await service.Get(default(int)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>())); }
public async void All_ShouldReturnRecords() { var mock = new ServiceMockFacade <IDeviceActionService, IDeviceActionRepository>(); var records = new List <DeviceAction>(); records.Add(new DeviceAction()); mock.RepositoryMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>())).Returns(Task.FromResult(records)); var service = new DeviceActionService(mock.LoggerMock.Object, mock.MediatorMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.DeviceActionModelValidatorMock.Object, mock.DALMapperMockFactory.DALDeviceActionMapperMock); List <ApiDeviceActionServerResponseModel> response = await service.All(); response.Should().HaveCount(1); mock.RepositoryMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>())); }
public async void Delete() { var mock = new ServiceMockFacade <IDeviceActionRepository>(); var model = new ApiDeviceActionRequestModel(); mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask); var service = new DeviceActionService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.DeviceActionModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLDeviceActionMapperMock, mock.DALMapperMockFactory.DALDeviceActionMapperMock); ActionResponse response = await service.Delete(default(int)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>())); mock.ModelValidatorMockFactory.DeviceActionModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>())); }
public async void Create() { var mock = new ServiceMockFacade <IDeviceActionRepository>(); var model = new ApiDeviceActionRequestModel(); mock.RepositoryMock.Setup(x => x.Create(It.IsAny <DeviceAction>())).Returns(Task.FromResult(new DeviceAction())); var service = new DeviceActionService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.DeviceActionModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLDeviceActionMapperMock, mock.DALMapperMockFactory.DALDeviceActionMapperMock); CreateResponse <ApiDeviceActionResponseModel> response = await service.Create(model); response.Should().NotBeNull(); mock.ModelValidatorMockFactory.DeviceActionModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiDeviceActionRequestModel>())); mock.RepositoryMock.Verify(x => x.Create(It.IsAny <DeviceAction>())); }
public async void Delete_NoErrorsOccurred_ShouldReturnResponse() { var mock = new ServiceMockFacade <IDeviceActionService, IDeviceActionRepository>(); var model = new ApiDeviceActionServerRequestModel(); mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask); var service = new DeviceActionService(mock.LoggerMock.Object, mock.MediatorMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.DeviceActionModelValidatorMock.Object, mock.DALMapperMockFactory.DALDeviceActionMapperMock); ActionResponse response = await service.Delete(default(int)); response.Should().NotBeNull(); response.Success.Should().BeTrue(); mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>())); mock.ModelValidatorMockFactory.DeviceActionModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>())); mock.MediatorMock.Verify(x => x.Publish(It.IsAny <DeviceActionDeletedNotification>(), It.IsAny <CancellationToken>())); }
public async void Delete_ErrorsOccurred_ShouldReturnErrorResponse() { var mock = new ServiceMockFacade <IDeviceActionService, IDeviceActionRepository>(); var model = new ApiDeviceActionServerRequestModel(); var validatorMock = new Mock <IApiDeviceActionServerRequestModelValidator>(); validatorMock.Setup(x => x.ValidateDeleteAsync(It.IsAny <int>())).Returns(Task.FromResult(new FluentValidation.Results.ValidationResult(new List <ValidationFailure>() { new ValidationFailure("text", "test") }))); var service = new DeviceActionService(mock.LoggerMock.Object, mock.MediatorMock.Object, mock.RepositoryMock.Object, validatorMock.Object, mock.DALMapperMockFactory.DALDeviceActionMapperMock); ActionResponse response = await service.Delete(default(int)); response.Should().NotBeNull(); response.Success.Should().BeFalse(); validatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>())); mock.MediatorMock.Verify(x => x.Publish(It.IsAny <DeviceActionDeletedNotification>(), It.IsAny <CancellationToken>()), Times.Never()); }
protected override bool OnBackButtonPressed() { GoogleAnalyticsService.TrackExtensionEvent("BackClosed", Uri.StartsWith("http") ? "Website" : "App"); DeviceActionService.CloseAutofill(); return(true); }
private async void CipherSelected(object sender, SelectedItemChangedEventArgs e) { var cipher = e.SelectedItem as AutofillCipher; if (cipher == null) { return; } if (_deviceInfoService.Version < 21) { Helpers.CipherMoreClickedAsync(this, cipher, true); } else { var autofillResponse = AppResources.Yes; if (cipher.Fuzzy) { var options = new List <string> { AppResources.Yes }; if (cipher.Type == CipherType.Login && _connectivity.IsConnected) { options.Add(AppResources.YesAndSave); } autofillResponse = await DeviceActionService.DisplayAlertAsync(null, string.Format(AppResources.BitwardenAutofillServiceMatchConfirm, _name), AppResources.No, options.ToArray()); } if (autofillResponse == AppResources.YesAndSave && cipher.Type == CipherType.Login) { if (!_connectivity.IsConnected) { Helpers.AlertNoConnection(this); } else { var uris = cipher.CipherModel.Login?.Uris?.ToList(); if (uris == null) { uris = new List <LoginUri>(); } uris.Add(new LoginUri { Uri = Uri.Encrypt(cipher.CipherModel.OrganizationId), Match = null }); cipher.CipherModel.Login.Uris = uris; await DeviceActionService.ShowLoadingAsync(AppResources.Saving); var saveTask = await _cipherService.SaveAsync(cipher.CipherModel); await DeviceActionService.HideLoadingAsync(); if (saveTask.Succeeded) { GoogleAnalyticsService.TrackAppEvent("AddedLoginUriDuringAutofill"); } } } if (autofillResponse == AppResources.Yes || autofillResponse == AppResources.YesAndSave) { GoogleAnalyticsService.TrackExtensionEvent("AutoFilled", Uri.StartsWith("http") ? "Website" : "App"); DeviceActionService.Autofill(cipher); } } ((ListView)sender).SelectedItem = null; }
private void RegisterLocalServices() { ServiceContainer.Register <INativeLogService>("nativeLogService", new AndroidLogService()); #if FDROID var logger = new StubLogger(); #elif DEBUG var logger = DebugLogger.Instance; #else var logger = Logger.Instance; #endif ServiceContainer.Register("logger", logger); // Note: This might cause a race condition. Investigate more. Task.Run(() => { FFImageLoading.Forms.Platform.CachedImageRenderer.Init(true); FFImageLoading.ImageService.Instance.Initialize(new FFImageLoading.Config.Configuration { FadeAnimationEnabled = false, FadeAnimationForCachedImages = false, HttpClient = new HttpClient(new AndroidClientHandler() { AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate }) }); ZXing.Net.Mobile.Forms.Android.Platform.Init(); }); CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity); var preferencesStorage = new PreferencesStorageService(null); var documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); var liteDbStorage = new LiteDbStorageService(Path.Combine(documentsPath, "bitwarden.db")); var localizeService = new LocalizeService(); var broadcasterService = new BroadcasterService(logger); var messagingService = new MobileBroadcasterMessagingService(broadcasterService); var i18nService = new MobileI18nService(localizeService.GetCurrentCultureInfo()); var secureStorageService = new SecureStorageService(); var cryptoPrimitiveService = new CryptoPrimitiveService(); var mobileStorageService = new MobileStorageService(preferencesStorage, liteDbStorage); var stateService = new StateService(mobileStorageService, secureStorageService, messagingService); var stateMigrationService = new StateMigrationService(liteDbStorage, preferencesStorage, secureStorageService); var clipboardService = new ClipboardService(stateService); var deviceActionService = new DeviceActionService(clipboardService, stateService, messagingService, broadcasterService, () => ServiceContainer.Resolve <IEventService>("eventService")); var platformUtilsService = new MobilePlatformUtilsService(deviceActionService, clipboardService, messagingService, broadcasterService); var biometricService = new BiometricService(); var cryptoFunctionService = new PclCryptoFunctionService(cryptoPrimitiveService); var cryptoService = new CryptoService(stateService, cryptoFunctionService); var passwordRepromptService = new MobilePasswordRepromptService(platformUtilsService, cryptoService); ServiceContainer.Register <IBroadcasterService>("broadcasterService", broadcasterService); ServiceContainer.Register <IMessagingService>("messagingService", messagingService); ServiceContainer.Register <ILocalizeService>("localizeService", localizeService); ServiceContainer.Register <II18nService>("i18nService", i18nService); ServiceContainer.Register <ICryptoPrimitiveService>("cryptoPrimitiveService", cryptoPrimitiveService); ServiceContainer.Register <IStorageService>("storageService", mobileStorageService); ServiceContainer.Register <IStorageService>("secureStorageService", secureStorageService); ServiceContainer.Register <IStateService>("stateService", stateService); ServiceContainer.Register <IStateMigrationService>("stateMigrationService", stateMigrationService); ServiceContainer.Register <IClipboardService>("clipboardService", clipboardService); ServiceContainer.Register <IDeviceActionService>("deviceActionService", deviceActionService); ServiceContainer.Register <IPlatformUtilsService>("platformUtilsService", platformUtilsService); ServiceContainer.Register <IBiometricService>("biometricService", biometricService); ServiceContainer.Register <ICryptoFunctionService>("cryptoFunctionService", cryptoFunctionService); ServiceContainer.Register <ICryptoService>("cryptoService", cryptoService); ServiceContainer.Register <IPasswordRepromptService>("passwordRepromptService", passwordRepromptService); ServiceContainer.Register <IAvatarImageSourcePool>("avatarImageSourcePool", new AvatarImageSourcePool()); // Push #if FDROID ServiceContainer.Register <IPushNotificationListenerService>( "pushNotificationListenerService", new NoopPushNotificationListenerService()); ServiceContainer.Register <IPushNotificationService>( "pushNotificationService", new NoopPushNotificationService()); #else var notificationListenerService = new PushNotificationListenerService(); ServiceContainer.Register <IPushNotificationListenerService>( "pushNotificationListenerService", notificationListenerService); var androidPushNotificationService = new AndroidPushNotificationService( stateService, notificationListenerService); ServiceContainer.Register <IPushNotificationService>( "pushNotificationService", androidPushNotificationService); #endif }
private void RegisterLocalServices() { ServiceContainer.Register <ILogService>("logService", new AndroidLogService()); ServiceContainer.Register("settingsShim", new App.Migration.SettingsShim()); if (App.Migration.MigrationHelpers.NeedsMigration()) { ServiceContainer.Register <App.Migration.Abstractions.IOldSecureStorageService>( "oldSecureStorageService", new Migration.AndroidKeyStoreStorageService()); } Refractored.FabControl.Droid.FloatingActionButtonViewRenderer.Init(); // Note: This might cause a race condition. Investigate more. Task.Run(() => { FFImageLoading.Forms.Platform.CachedImageRenderer.Init(true); FFImageLoading.ImageService.Instance.Initialize(new FFImageLoading.Config.Configuration { FadeAnimationEnabled = false, FadeAnimationForCachedImages = false }); ZXing.Net.Mobile.Forms.Android.Platform.Init(); }); CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity); CrossFingerprint.SetDialogFragmentType <CustomFingerprintDialogFragment>(); var preferencesStorage = new PreferencesStorageService(null); var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); var liteDbStorage = new LiteDbStorageService(Path.Combine(documentsPath, "bitwarden.db")); liteDbStorage.InitAsync(); var localizeService = new LocalizeService(); var broadcasterService = new BroadcasterService(); var messagingService = new MobileBroadcasterMessagingService(broadcasterService); var i18nService = new MobileI18nService(localizeService.GetCurrentCultureInfo()); var secureStorageService = new SecureStorageService(); var cryptoPrimitiveService = new CryptoPrimitiveService(); var mobileStorageService = new MobileStorageService(preferencesStorage, liteDbStorage); var deviceActionService = new DeviceActionService(mobileStorageService, messagingService, broadcasterService); var platformUtilsService = new MobilePlatformUtilsService(deviceActionService, messagingService, broadcasterService); ServiceContainer.Register <IBroadcasterService>("broadcasterService", broadcasterService); ServiceContainer.Register <IMessagingService>("messagingService", messagingService); ServiceContainer.Register <ILocalizeService>("localizeService", localizeService); ServiceContainer.Register <II18nService>("i18nService", i18nService); ServiceContainer.Register <ICryptoPrimitiveService>("cryptoPrimitiveService", cryptoPrimitiveService); ServiceContainer.Register <IStorageService>("storageService", mobileStorageService); ServiceContainer.Register <IStorageService>("secureStorageService", secureStorageService); ServiceContainer.Register <IDeviceActionService>("deviceActionService", deviceActionService); ServiceContainer.Register <IPlatformUtilsService>("platformUtilsService", platformUtilsService); // Push #if FDROID ServiceContainer.Register <IPushNotificationListenerService>( "pushNotificationListenerService", new NoopPushNotificationListenerService()); ServiceContainer.Register <IPushNotificationService>( "pushNotificationService", new NoopPushNotificationService()); #else var notificationListenerService = new PushNotificationListenerService(); ServiceContainer.Register <IPushNotificationListenerService>( "pushNotificationListenerService", notificationListenerService); var androidPushNotificationService = new AndroidPushNotificationService( mobileStorageService, notificationListenerService); ServiceContainer.Register <IPushNotificationService>( "pushNotificationService", androidPushNotificationService); #endif }