Bug fixes:

* make sure we never have an invalid startIndex in PwGroup.SearchEvalAdd
 * make sure AndroidContentStorage does never throw (not if permission denial exception occurs) and make sure we always return a reason for read-only. Also don't return read-only when it's not.
 * StopListening doesn't log Invalid State Exception as unexpected
This commit is contained in:
Philipp Crocoll 2016-01-18 21:18:22 +01:00
parent 311316ea50
commit aaa6b371e0
5 changed files with 38 additions and 19 deletions

View File

@ -990,7 +990,7 @@ namespace KeePassLib
if (contextString.Length > SearchContextStringMaxLength)
{
// Start 10% before actual data, and don't run over
var startPos = Math.Min(matchPos - (SearchContextStringMaxLength / 10), contextString.Length - SearchContextStringMaxLength);
var startPos = Math.Max(0, Math.Min(matchPos - (SearchContextStringMaxLength / 10), contextString.Length - SearchContextStringMaxLength));
contextString = "… " + contextString.Substring(startPos, SearchContextStringMaxLength) + ((startPos + SearchContextStringMaxLength < contextString.Length) ? " …" : null);
}
resultContexts[pe.Uuid] = new KeyValuePair<string, string>(contextFieldName, contextString);

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using Android.Content;
using Android.Database;
using Android.OS;
using Android.Provider;
using KeePassLib.Serialization;
@ -209,22 +210,23 @@ namespace keepass2android.Io
public bool IsReadOnly(IOConnectionInfo ioc, OptionalOut<UiStringKey> reason = null)
{
//on pre-Kitkat devices, we can't write content:// files
if (!IsKitKatOrLater)
{
Kp2aLog.Log("File is read-only because we're not on KitKat or later.");
if (reason != null)
reason.Result = UiStringKey.ReadOnlyReason_PreKitKat;
return true;
}
ICursor cursor = null;
try
{
//on pre-Kitkat devices, we can't write content:// files
if (!IsKitKatOrLater)
{
Kp2aLog.Log("File is read-only because we're not on KitKat or later.");
if (reason != null)
reason.Result = UiStringKey.ReadOnlyReason_PreKitKat;
return true;
}
//KitKat or later...
var uri = Android.Net.Uri.Parse(ioc.Path);
var cursor = _ctx.ContentResolver.Query(uri, null, null, null, null, null);
//KitKat or later...
var uri = Android.Net.Uri.Parse(ioc.Path);
cursor = _ctx.ContentResolver.Query(uri, null, null, null, null, null);
try
{
if (cursor != null && cursor.MoveToFirst())
{
int flags = cursor.GetInt(cursor.GetColumnIndex(DocumentsContract.Document.ColumnFlags));
@ -235,14 +237,23 @@ namespace keepass2android.Io
reason.Result = UiStringKey.ReadOnlyReason_ReadOnlyFlag;
return true;
}
else return false;
}
else throw new Exception("couldn't move to first result element");
}
catch (Exception e)
{
Kp2aLog.LogUnexpectedError(e);
//better return false here. We don't really know what happened (as this is unexpected).
//let the user try to write the file. If it fails they will get an exception string.
return false;
}
finally
{
if (cursor != null)
cursor.Close();
}
return true;
}
}

View File

@ -134,7 +134,11 @@ namespace keepass2android
}
catch (IllegalStateException ise)
{
Kp2aLog.LogUnexpectedError(ise);
Kp2aLog.Log(ise.ToString());
}
catch (System.Exception e)
{
Kp2aLog.LogUnexpectedError(e);
}
}
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="71"
android:versionName="1.0.0 preview 4"
android:versionCode="73"
android:versionName="1.0.0 preview 6"
package="keepass2android.keepass2android"
android:installLocation="auto">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="23" />

View File

@ -616,6 +616,7 @@
<string name="PreviewWarning">Please note! This is a preview release and might come with some flaws! If you experience *anything* unexpected, please let me know (on Codeplex or by email).</string>
<string name="PreviewErrorReports"> Whenever you see a question if you want to enable error reports, please do so!</string>
<string name="Continue">Continue</string>
<string name="NoFilenameWarning">The URI you have entered does not look like a filename. Are you sure this is a valid file?</string>
@ -655,7 +656,7 @@
</string>
<string name="ChangeLog_1_0_0">
Version 1.0.0 - preview 4\n
Version 1.0.0 - preview 5\n
* Fingerprint Unlock (requires Android 6.0+ or a Samsung device)\n
* Added support for entry templates\n
* Added "work offline" mode\n
@ -663,6 +664,9 @@
* Auto-complete mode for field names\n
* Allow to remove items from recent files list\n
* Request permissions at runtime in Android 6.0\n
* Bug fixes (in built-in keyboard, when selecting icons)\n
* Included option to send error reports\n
* Added help messages at several points\n
* more to come...\n
</string>