fix for crash on Android 4.x (NoBackupFilesDir is ApiLevel >= 21)

try to fall back to Samsung fingerprint API even on Android 6
-> 1.0.0c
This commit is contained in:
Philipp Crocoll
2016-04-13 19:52:26 +02:00
parent 80d1788c60
commit 832722a90e
6 changed files with 42 additions and 23 deletions

View File

@@ -253,7 +253,7 @@ namespace keepass2android.Io
if (ioc.IsLocalFile())
{
bool requiresPermission = !(ioc.Path.StartsWith(activity.Activity.FilesDir.CanonicalPath)
|| ioc.Path.StartsWith(activity.Activity.NoBackupFilesDir.CanonicalPath));
|| ioc.Path.StartsWith(IoUtil.GetInternalDirectory(activity.Activity).CanonicalPath));
var extDirectory = activity.Activity.GetExternalFilesDir(null);
if ((extDirectory != null) && (ioc.Path.StartsWith(extDirectory.CanonicalPath)))

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using Android.Content;
using Android.OS;
using Java.IO;
using KeePassLib.Serialization;
@@ -53,7 +54,7 @@ namespace keepass2android.Io
try
{
File filesDir = context.FilesDir.CanonicalFile;
File noBackupDir = context.NoBackupFilesDir.CanonicalFile;
File noBackupDir = GetInternalDirectory(context).CanonicalFile;
File ourFile = new File(path).CanonicalFile;
//http://www.java2s.com/Tutorial/Java/0180__File/Checkswhetherthechilddirectoryisasubdirectoryofthebasedirectory.htm
@@ -93,5 +94,13 @@ namespace keepass2android.Io
writeTransaction.CommitWrite();
}
}
public static Java.IO.File GetInternalDirectory(Context ctx)
{
if ((int)Android.OS.Build.VERSION.SdkInt >= 21)
return ctx.NoBackupFilesDir;
else
return ctx.FilesDir;
}
}
}

View File

@@ -101,7 +101,7 @@ namespace keepass2android
}
catch (DuplicateUuidsException e)
{
Kp2aLog.LogUnexpectedError(e);
Kp2aLog.Log(e.ToString());
Finish(false, _app.GetResourceString(UiStringKey.DuplicateUuidsError) + " " + e.Message + _app.GetResourceString(UiStringKey.DuplicateUuidsErrorAdditional), Exception);
return;
}