2016-08-26 04:43:47 +03:00
|
|
|
using Android.App;
|
2017-09-07 07:33:19 +03:00
|
|
|
using Android.Content.PM;
|
2016-08-24 05:43:17 +03:00
|
|
|
using Android.OS;
|
2017-11-28 01:27:11 +03:00
|
|
|
using Android.Views.Autofill;
|
2016-08-24 05:43:17 +03:00
|
|
|
using Bit.App.Abstractions;
|
2017-12-22 19:23:03 +03:00
|
|
|
using Plugin.CurrentActivity;
|
2016-08-24 05:43:17 +03:00
|
|
|
|
|
|
|
namespace Bit.Android.Services
|
|
|
|
{
|
|
|
|
public class DeviceInfoService : IDeviceInfoService
|
|
|
|
{
|
2017-12-21 21:10:55 +03:00
|
|
|
public string Type => Xamarin.Forms.Device.Android;
|
2016-08-24 05:43:17 +03:00
|
|
|
public string Model => Build.Model;
|
|
|
|
public int Version => (int)Build.VERSION.SdkInt;
|
2016-08-26 04:43:47 +03:00
|
|
|
public float Scale
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
var density = Application.Context.Resources.DisplayMetrics.Density;
|
|
|
|
if(density <= 0.75)
|
|
|
|
{
|
|
|
|
return 0.75f;
|
|
|
|
}
|
|
|
|
else if(density <= 1)
|
|
|
|
{
|
|
|
|
return 1f;
|
|
|
|
}
|
|
|
|
else if(density <= 1.5)
|
|
|
|
{
|
|
|
|
return 1.5f;
|
|
|
|
}
|
|
|
|
else if(density <= 2)
|
|
|
|
{
|
|
|
|
return 2f;
|
|
|
|
}
|
|
|
|
else if(density <= 3)
|
|
|
|
{
|
|
|
|
return 3f;
|
|
|
|
}
|
|
|
|
else if(density <= 4)
|
|
|
|
{
|
|
|
|
return 4f;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1f;
|
|
|
|
}
|
|
|
|
}
|
2017-06-29 05:24:04 +03:00
|
|
|
public bool NfcEnabled => Utilities.NfcEnabled();
|
2017-12-22 19:23:03 +03:00
|
|
|
public bool HasCamera => CrossCurrentActivity.Current.Activity.PackageManager.HasSystemFeature(
|
|
|
|
PackageManager.FeatureCamera);
|
2017-11-28 01:27:11 +03:00
|
|
|
public bool AutofillServiceSupported => AutofillSupported();
|
2017-11-29 23:47:43 +03:00
|
|
|
public bool HasFaceIdSupport => false;
|
2017-11-28 01:27:11 +03:00
|
|
|
private bool AutofillSupported()
|
|
|
|
{
|
|
|
|
if(Build.VERSION.SdkInt < BuildVersionCodes.O)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2017-12-22 19:23:03 +03:00
|
|
|
|
|
|
|
var afm = (AutofillManager)CrossCurrentActivity.Current.Activity.GetSystemService(
|
|
|
|
Java.Lang.Class.FromType(typeof(AutofillManager)));
|
2017-11-28 01:27:11 +03:00
|
|
|
return afm.IsAutofillSupported;
|
|
|
|
}
|
2016-08-24 05:43:17 +03:00
|
|
|
}
|
2016-08-26 04:43:47 +03:00
|
|
|
}
|