mirror of
https://github.com/bitwarden/mobile
synced 2026-01-04 17:43:17 +00:00
Added custom device info service for determining model and version (ios = major version, android = API level).
This commit is contained in:
@@ -155,14 +155,6 @@
|
||||
<HintPath>..\..\packages\Plugin.CurrentActivity.1.0.1\lib\MonoAndroid10\Plugin.CurrentActivity.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Plugin.DeviceInfo, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Xam.Plugin.DeviceInfo.2.0.2\lib\MonoAndroid10\Plugin.DeviceInfo.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Plugin.DeviceInfo.Abstractions, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Xam.Plugin.DeviceInfo.2.0.2\lib\MonoAndroid10\Plugin.DeviceInfo.Abstractions.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Plugin.Fingerprint, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Plugin.Fingerprint.1.2.0\lib\MonoAndroid\Plugin.Fingerprint.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
@@ -305,6 +297,7 @@
|
||||
<Compile Include="Controls\ExtendedEntryRenderer.cs" />
|
||||
<Compile Include="MainApplication.cs" />
|
||||
<Compile Include="Resources\Resource.Designer.cs" />
|
||||
<Compile Include="Services\DeviceInfoService.cs" />
|
||||
<Compile Include="Services\GoogleAnalyticsService.cs" />
|
||||
<Compile Include="Services\AppInfoService.cs" />
|
||||
<Compile Include="Services\ClipboardService.cs" />
|
||||
|
||||
@@ -11,7 +11,6 @@ using Bit.App.Services;
|
||||
using Microsoft.Practices.Unity;
|
||||
using Plugin.Connectivity;
|
||||
using Plugin.CurrentActivity;
|
||||
using Plugin.DeviceInfo;
|
||||
using Plugin.Fingerprint;
|
||||
using Plugin.Settings;
|
||||
using PushNotification.Plugin;
|
||||
@@ -143,6 +142,7 @@ namespace Bit.Android
|
||||
.RegisterType<ILockService, LockService>(new ContainerControlledLifetimeManager())
|
||||
.RegisterType<IAppInfoService, AppInfoService>(new ContainerControlledLifetimeManager())
|
||||
.RegisterType<IGoogleAnalyticsService, GoogleAnalyticsService>(new ContainerControlledLifetimeManager())
|
||||
.RegisterType<IDeviceInfoService, DeviceInfoService>(new ContainerControlledLifetimeManager())
|
||||
// Repositories
|
||||
.RegisterType<IFolderRepository, FolderRepository>(new ContainerControlledLifetimeManager())
|
||||
.RegisterType<IFolderApiRepository, FolderApiRepository>(new ContainerControlledLifetimeManager())
|
||||
@@ -153,7 +153,6 @@ namespace Bit.Android
|
||||
.RegisterType<IAccountsApiRepository, AccountsApiRepository>(new ContainerControlledLifetimeManager())
|
||||
.RegisterType<ICipherApiRepository, CipherApiRepository>(new ContainerControlledLifetimeManager())
|
||||
// Other
|
||||
.RegisterInstance(CrossDeviceInfo.Current, new ContainerControlledLifetimeManager())
|
||||
.RegisterInstance(CrossSettings.Current, new ContainerControlledLifetimeManager())
|
||||
.RegisterInstance(CrossConnectivity.Current, new ContainerControlledLifetimeManager())
|
||||
.RegisterInstance(UserDialogs.Instance, new ContainerControlledLifetimeManager())
|
||||
|
||||
11
src/Android/Services/DeviceInfoService.cs
Normal file
11
src/Android/Services/DeviceInfoService.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Android.OS;
|
||||
using Bit.App.Abstractions;
|
||||
|
||||
namespace Bit.Android.Services
|
||||
{
|
||||
public class DeviceInfoService : IDeviceInfoService
|
||||
{
|
||||
public string Model => Build.Model;
|
||||
public int Version => (int)Build.VERSION.SdkInt;
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,6 @@
|
||||
<package id="Unity" version="3.5.1405-prerelease" targetFramework="monoandroid60" />
|
||||
<package id="Validation" version="2.2.8" targetFramework="monoandroid60" />
|
||||
<package id="Xam.Plugin.Connectivity" version="2.2.12" targetFramework="monoandroid60" />
|
||||
<package id="Xam.Plugin.DeviceInfo" version="2.0.2" targetFramework="monoandroid60" />
|
||||
<package id="Xam.Plugin.PushNotification" version="1.2.2" targetFramework="monoandroid60" developmentDependency="true" />
|
||||
<package id="Xam.Plugins.Settings" version="2.1.0" targetFramework="monoandroid60" />
|
||||
<package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="23.3.0" targetFramework="monoandroid60" />
|
||||
|
||||
8
src/App/Abstractions/Services/IDeviceInfoService.cs
Normal file
8
src/App/Abstractions/Services/IDeviceInfoService.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Bit.App.Abstractions
|
||||
{
|
||||
public interface IDeviceInfoService
|
||||
{
|
||||
string Model { get; }
|
||||
int Version { get; }
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Abstractions\Repositories\IAccountsApiRepository.cs" />
|
||||
<Compile Include="Abstractions\Repositories\IDeviceApiRepository.cs" />
|
||||
<Compile Include="Abstractions\Services\IDeviceInfoService.cs" />
|
||||
<Compile Include="Abstractions\Services\IGoogleAnalyticsService.cs" />
|
||||
<Compile Include="Abstractions\Services\IAppInfoService.cs" />
|
||||
<Compile Include="Abstractions\Services\IAppIdService.cs" />
|
||||
@@ -246,14 +247,6 @@
|
||||
<HintPath>..\..\packages\Xam.Plugin.Connectivity.2.2.12\lib\portable-net45+wp80+wp81+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+Xamarin.Mac20+UAP10\Plugin.Connectivity.Abstractions.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Plugin.DeviceInfo, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Xam.Plugin.DeviceInfo.2.0.2\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\Plugin.DeviceInfo.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Plugin.DeviceInfo.Abstractions, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Xam.Plugin.DeviceInfo.2.0.2\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\Plugin.DeviceInfo.Abstractions.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Plugin.Fingerprint, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Plugin.Fingerprint.1.2.0\lib\portable-net45+win8+wpa81+wp8\Plugin.Fingerprint.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Bit.App.Abstractions;
|
||||
using Plugin.DeviceInfo.Abstractions;
|
||||
using PushNotification.Plugin.Abstractions;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Bit.App.Models.Api
|
||||
{
|
||||
@@ -8,11 +8,11 @@ namespace Bit.App.Models.Api
|
||||
{
|
||||
public DeviceRequest() { }
|
||||
|
||||
public DeviceRequest(IAppIdService appIdService, IDeviceInfo deviceInfo)
|
||||
public DeviceRequest(IAppIdService appIdService, IDeviceInfoService deviceInfoService)
|
||||
{
|
||||
Identifier = appIdService.AppId;
|
||||
Name = deviceInfo.Model;
|
||||
Type = deviceInfo.Platform == Platform.Android ? DeviceType.Android : DeviceType.iOS;
|
||||
Name = deviceInfoService.Model;
|
||||
Type = Device.OS == TargetPlatform.Android ? DeviceType.Android : DeviceType.iOS;
|
||||
}
|
||||
|
||||
public DeviceType Type { get; set; }
|
||||
|
||||
@@ -4,7 +4,6 @@ using Bit.App.Abstractions;
|
||||
using Bit.App.Controls;
|
||||
using Bit.App.Models.Api;
|
||||
using Bit.App.Resources;
|
||||
using Plugin.DeviceInfo.Abstractions;
|
||||
using Xamarin.Forms;
|
||||
using XLabs.Ioc;
|
||||
using Acr.UserDialogs;
|
||||
@@ -18,7 +17,7 @@ namespace Bit.App.Pages
|
||||
{
|
||||
private ICryptoService _cryptoService;
|
||||
private IAuthService _authService;
|
||||
private IDeviceInfo _deviceInfo;
|
||||
private IDeviceInfoService _deviceInfoService;
|
||||
private IAppIdService _appIdService;
|
||||
private IUserDialogs _userDialogs;
|
||||
private ISyncService _syncService;
|
||||
@@ -33,7 +32,7 @@ namespace Bit.App.Pages
|
||||
_email = email;
|
||||
_cryptoService = Resolver.Resolve<ICryptoService>();
|
||||
_authService = Resolver.Resolve<IAuthService>();
|
||||
_deviceInfo = Resolver.Resolve<IDeviceInfo>();
|
||||
_deviceInfoService = Resolver.Resolve<IDeviceInfoService>();
|
||||
_appIdService = Resolver.Resolve<IAppIdService>();
|
||||
_userDialogs = Resolver.Resolve<IUserDialogs>();
|
||||
_syncService = Resolver.Resolve<ISyncService>();
|
||||
@@ -184,7 +183,7 @@ namespace Bit.App.Pages
|
||||
{
|
||||
Email = normalizedEmail,
|
||||
MasterPasswordHash = _cryptoService.HashPasswordBase64(key, PasswordCell.Entry.Text),
|
||||
Device = new DeviceRequest(_appIdService, _deviceInfo)
|
||||
Device = new DeviceRequest(_appIdService, _deviceInfoService)
|
||||
};
|
||||
|
||||
_userDialogs.ShowLoading("Logging in...", MaskType.Black);
|
||||
|
||||
@@ -4,7 +4,6 @@ using Bit.App.Abstractions;
|
||||
using Bit.App.Controls;
|
||||
using Bit.App.Models.Api;
|
||||
using Bit.App.Resources;
|
||||
using Plugin.DeviceInfo.Abstractions;
|
||||
using Xamarin.Forms;
|
||||
using XLabs.Ioc;
|
||||
using Acr.UserDialogs;
|
||||
@@ -16,7 +15,7 @@ namespace Bit.App.Pages
|
||||
{
|
||||
private ICryptoService _cryptoService;
|
||||
private IAuthService _authService;
|
||||
private IDeviceInfo _deviceInfo;
|
||||
private IDeviceInfoService _deviceInfoService;
|
||||
private IAppIdService _appIdService;
|
||||
private IUserDialogs _userDialogs;
|
||||
private ISyncService _syncService;
|
||||
@@ -26,7 +25,7 @@ namespace Bit.App.Pages
|
||||
{
|
||||
_cryptoService = Resolver.Resolve<ICryptoService>();
|
||||
_authService = Resolver.Resolve<IAuthService>();
|
||||
_deviceInfo = Resolver.Resolve<IDeviceInfo>();
|
||||
_deviceInfoService = Resolver.Resolve<IDeviceInfoService>();
|
||||
_appIdService = Resolver.Resolve<IAppIdService>();
|
||||
_userDialogs = Resolver.Resolve<IUserDialogs>();
|
||||
_syncService = Resolver.Resolve<ISyncService>();
|
||||
@@ -124,7 +123,7 @@ namespace Bit.App.Pages
|
||||
{
|
||||
Code = CodeCell.Entry.Text,
|
||||
Provider = "Authenticator",
|
||||
Device = new DeviceRequest(_appIdService, _deviceInfo)
|
||||
Device = new DeviceRequest(_appIdService, _deviceInfoService)
|
||||
};
|
||||
|
||||
_userDialogs.ShowLoading("Validating code...", MaskType.Black);
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
<package id="Unity" version="3.5.1405-prerelease" targetFramework="portable45-net45+win8+wpa81" />
|
||||
<package id="Validation" version="2.2.8" targetFramework="portable45-net45+win8+wpa81" />
|
||||
<package id="Xam.Plugin.Connectivity" version="2.2.12" targetFramework="portable45-net45+win8+wpa81" />
|
||||
<package id="Xam.Plugin.DeviceInfo" version="2.0.2" targetFramework="portable45-net45+win8+wpa81" />
|
||||
<package id="Xam.Plugin.PushNotification" version="1.2.2" targetFramework="portable45-net45+win8+wpa81" developmentDependency="true" />
|
||||
<package id="Xam.Plugins.Settings" version="2.1.0" targetFramework="portable45-net45+win8+wpa81" />
|
||||
<package id="Xamarin.Forms" version="2.3.1.114" targetFramework="portable45-net45+win8+wpa81" />
|
||||
|
||||
25
src/iOS.Core/Services/DeviceInfoService.cs
Normal file
25
src/iOS.Core/Services/DeviceInfoService.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Bit.App.Abstractions;
|
||||
using UIKit;
|
||||
|
||||
namespace Bit.iOS.Core.Services
|
||||
{
|
||||
public class DeviceInfoService : IDeviceInfoService
|
||||
{
|
||||
public string Model => UIDevice.CurrentDevice.Model;
|
||||
public int Version
|
||||
{
|
||||
get
|
||||
{
|
||||
int version;
|
||||
var versionParts = UIDevice.CurrentDevice.SystemVersion.Split('.');
|
||||
if(versionParts.Length > 0 && int.TryParse(versionParts[0], out version))
|
||||
{
|
||||
return version;
|
||||
}
|
||||
|
||||
// unable to determine version
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,6 +87,7 @@
|
||||
<Compile Include="Controllers\ExtendedUIViewController.cs" />
|
||||
<Compile Include="HockeyAppCrashManagerDelegate.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Services\DeviceInfoService.cs" />
|
||||
<Compile Include="Services\KeyChainStorageService.cs" />
|
||||
<Compile Include="Services\CommonCryptoKeyDerivationService.cs" />
|
||||
<Compile Include="Services\Settings.cs" />
|
||||
|
||||
@@ -20,10 +20,8 @@ using System.Diagnostics;
|
||||
using Xamarin.Forms;
|
||||
using Bit.iOS.Core.Services;
|
||||
using PushNotification.Plugin;
|
||||
using Plugin.DeviceInfo;
|
||||
using Plugin.Connectivity.Abstractions;
|
||||
using Bit.App.Pages;
|
||||
using PushNotification.Plugin.Abstractions;
|
||||
using HockeyApp.iOS;
|
||||
using Bit.iOS.Core;
|
||||
using Google.Analytics;
|
||||
@@ -260,6 +258,7 @@ namespace Bit.iOS
|
||||
.RegisterType<ILockService, LockService>(new ContainerControlledLifetimeManager())
|
||||
.RegisterType<IAppInfoService, AppInfoService>(new ContainerControlledLifetimeManager())
|
||||
.RegisterType<IGoogleAnalyticsService, GoogleAnalyticsService>(new ContainerControlledLifetimeManager())
|
||||
.RegisterType<IDeviceInfoService, DeviceInfoService>(new ContainerControlledLifetimeManager())
|
||||
// Repositories
|
||||
.RegisterType<IFolderRepository, FolderRepository>(new ContainerControlledLifetimeManager())
|
||||
.RegisterType<IFolderApiRepository, FolderApiRepository>(new ContainerControlledLifetimeManager())
|
||||
@@ -270,7 +269,6 @@ namespace Bit.iOS
|
||||
.RegisterType<IAccountsApiRepository, AccountsApiRepository>(new ContainerControlledLifetimeManager())
|
||||
.RegisterType<ICipherApiRepository, CipherApiRepository>(new ContainerControlledLifetimeManager())
|
||||
// Other
|
||||
.RegisterInstance(CrossDeviceInfo.Current, new ContainerControlledLifetimeManager())
|
||||
.RegisterInstance(CrossConnectivity.Current, new ContainerControlledLifetimeManager())
|
||||
.RegisterInstance(UserDialogs.Instance, new ContainerControlledLifetimeManager())
|
||||
.RegisterInstance(CrossFingerprint.Current, new ContainerControlledLifetimeManager());
|
||||
|
||||
@@ -394,12 +394,6 @@
|
||||
<Reference Include="XLabs.Ioc.Unity, Version=2.0.5782.12230, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>..\..\packages\XLabs.IoC.Unity.2.0.5782\lib\portable-net45+netcore45+wp8+MonoAndroid1+MonoTouch1\XLabs.Ioc.Unity.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Plugin.DeviceInfo, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>..\..\packages\Xam.Plugin.DeviceInfo.2.0.2\lib\Xamarin.iOS10\Plugin.DeviceInfo.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Plugin.DeviceInfo.Abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>..\..\packages\Xam.Plugin.DeviceInfo.2.0.2\lib\Xamarin.iOS10\Plugin.DeviceInfo.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PushNotification.Plugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>..\..\packages\Xam.Plugin.PushNotification.1.2.2\lib\Xamarin.iOS10\PushNotification.Plugin.dll</HintPath>
|
||||
</Reference>
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
<package id="Unity" version="3.5.1405-prerelease" targetFramework="xamarinios10" />
|
||||
<package id="Validation" version="2.2.8" targetFramework="xamarinios10" />
|
||||
<package id="Xam.Plugin.Connectivity" version="2.2.12" targetFramework="xamarinios10" />
|
||||
<package id="Xam.Plugin.DeviceInfo" version="2.0.2" targetFramework="xamarinios10" />
|
||||
<package id="Xam.Plugin.PushNotification" version="1.2.2" targetFramework="xamarinios10" developmentDependency="true" />
|
||||
<package id="Xam.Plugins.Settings" version="2.1.0" targetFramework="xamarinios10" />
|
||||
<package id="Xamarin.Build.Download" version="0.2.2-beta2" targetFramework="xamarinios10" />
|
||||
|
||||
Reference in New Issue
Block a user