Ejemplo n.º 1
0
        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
        }
Ejemplo n.º 2
0
        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      = System.Environment.GetFolderPath(System.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, () => ServiceContainer.Resolve <IEventService>("eventService"));
            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
        }
Ejemplo n.º 3
0
        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,
                    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();
            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();
            var cryptoFunctionService   = new PclCryptoFunctionService(cryptoPrimitiveService);
            var cryptoService           = new CryptoService(mobileStorageService, secureStorageService, 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 <IClipboardService>("clipboardService", new ClipboardService(mobileStorageService));
            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);

            // 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
        }