From 7ccf55f84fd79ed64b4e3bb4d297144bb9d786eb Mon Sep 17 00:00:00 2001 From: Philipp Crocoll Date: Wed, 25 Jan 2017 05:01:26 +0100 Subject: [PATCH] make sure quick-unlock code is respected always, release 1.01b --- .../Io/AndroidContentStorage.cs | 5 ++- src/keepass2android/ChangeLog.cs | 1 + src/keepass2android/PasswordActivity.cs | 33 +++++++++++-------- .../Properties/AndroidManifest_net.xml | 4 +-- .../Resources/values-el/strings.xml | 2 +- .../Resources/values/strings.xml | 5 +++ 6 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/Kp2aBusinessLogic/Io/AndroidContentStorage.cs b/src/Kp2aBusinessLogic/Io/AndroidContentStorage.cs index 675a915c..56cdfc1a 100644 --- a/src/Kp2aBusinessLogic/Io/AndroidContentStorage.cs +++ b/src/Kp2aBusinessLogic/Io/AndroidContentStorage.cs @@ -229,7 +229,10 @@ namespace keepass2android.Io if (cursor != null && cursor.MoveToFirst()) { - int flags = cursor.GetInt(cursor.GetColumnIndex(DocumentsContract.Document.ColumnFlags)); + int column = cursor.GetColumnIndex(DocumentsContract.Document.ColumnFlags); + if (column < 0) + return false; //seems like this is not supported. See below for reasoning to return false. + int flags = cursor.GetInt(column); Kp2aLog.Log("File flags: " + flags); if ((flags & (long) DocumentContractFlags.SupportsWrite) == 0) { diff --git a/src/keepass2android/ChangeLog.cs b/src/keepass2android/ChangeLog.cs index c327e88c..a9ab2681 100644 --- a/src/keepass2android/ChangeLog.cs +++ b/src/keepass2android/ChangeLog.cs @@ -26,6 +26,7 @@ namespace keepass2android AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(ctx, Android.Resource.Style.ThemeHoloLightDialog)); builder.SetTitle(ctx.GetString(Resource.String.ChangeLog_title)); List changeLog = new List{ + ctx.GetString(Resource.String.ChangeLog_1_01b), ctx.GetString(Resource.String.ChangeLog_1_01), ctx.GetString(Resource.String.ChangeLog_1_0_0e), ctx.GetString(Resource.String.ChangeLog_1_0_0), diff --git a/src/keepass2android/PasswordActivity.cs b/src/keepass2android/PasswordActivity.cs index 50469066..e84851e2 100644 --- a/src/keepass2android/PasswordActivity.cs +++ b/src/keepass2android/PasswordActivity.cs @@ -925,7 +925,7 @@ namespace keepass2android RequestPermissions(new[] { Manifest.Permission.UseFingerprint }, FingerprintPermissionRequestCode); } - const int FingerprintPermissionRequestCode = 0; + const int FingerprintPermissionRequestCode = 99; public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults) { @@ -1768,34 +1768,39 @@ namespace keepass2android FindViewById(Resource.Id.otpInitView).Visibility = _challengeSecret == null ? ViewStates.Visible : ViewStates.Gone; } - // OnResume is run every time the activity comes to the foreground. This code should only run when the activity is started (OnStart), but must - // be run in OnResume rather than OnStart so that it always occurrs after OnActivityResult (when re-creating a killed activity, OnStart occurs before OnActivityResult) //use !IsFinishing to make sure we're not starting another activity when we're already finishing (e.g. due to TaskComplete in OnActivityResult) //use !performingLoad to make sure we're not already loading the database (after ActivityResult from File-Prepare-Activity; this would cause _loadDbTask to exist when we reload later!) - if (_starting && !IsFinishing && !_performingLoad) + if ( !IsFinishing && !_performingLoad) { - _starting = false; if (App.Kp2a.DatabaseIsUnlocked) { LaunchNextActivity(); } else if (App.Kp2a.QuickUnlockEnabled && App.Kp2a.QuickLocked) { - var i = new Intent(this, typeof(QuickUnlock)); + var i = new Intent(this, typeof (QuickUnlock)); PutIoConnectionToIntent(_ioConnection, i); Kp2aLog.Log("Starting QuickUnlock"); StartActivityForResult(i, 0); } - else + else { - //database not yet loaded. - - //check if pre-loading is enabled but wasn't started yet: - if (_loadDbTask == null && _prefs.GetBoolean(GetString(Resource.String.PreloadDatabaseEnabled_key), true)) + // OnResume is run every time the activity comes to the foreground. This code should only run when the activity is started (OnStart), but must + // be run in OnResume rather than OnStart so that it always occurrs after OnActivityResult (when re-creating a killed activity, OnStart occurs before OnActivityResult) + if (!_starting) { - // Create task to kick off file loading while the user enters the password - _loadDbTask = Task.Factory.StartNew(PreloadDbFile); - _loadDbTaskOffline = App.Kp2a.OfflineMode; + + _starting = false; + + //database not yet loaded. + + //check if pre-loading is enabled but wasn't started yet: + if (_loadDbTask == null && _prefs.GetBoolean(GetString(Resource.String.PreloadDatabaseEnabled_key), true)) + { + // Create task to kick off file loading while the user enters the password + _loadDbTask = Task.Factory.StartNew(PreloadDbFile); + _loadDbTaskOffline = App.Kp2a.OfflineMode; + } } } } diff --git a/src/keepass2android/Properties/AndroidManifest_net.xml b/src/keepass2android/Properties/AndroidManifest_net.xml index 43fce32c..111a1772 100644 --- a/src/keepass2android/Properties/AndroidManifest_net.xml +++ b/src/keepass2android/Properties/AndroidManifest_net.xml @@ -1,7 +1,7 @@  diff --git a/src/keepass2android/Resources/values-el/strings.xml b/src/keepass2android/Resources/values-el/strings.xml index 8b7fc5f6..dffccb16 100644 --- a/src/keepass2android/Resources/values-el/strings.xml +++ b/src/keepass2android/Resources/values-el/strings.xml @@ -710,7 +710,7 @@ * Bug fixes -Έκδοση 0.8.6\n +Έκδοση 0.8.6\n * Support for Twofish cipher\n * Allow editing of groups\n * Allow moving of entries and groups\n diff --git a/src/keepass2android/Resources/values/strings.xml b/src/keepass2android/Resources/values/strings.xml index 98708a97..85d5894f 100644 --- a/src/keepass2android/Resources/values/strings.xml +++ b/src/keepass2android/Resources/values/strings.xml @@ -680,6 +680,11 @@ Use AutoFill service Please enable the Keepass2Android service. Show soft keyboard for password input when fingerprint scan is active. + + Version 1.01-b\n + * Fix for QuickUnlock sometimes failing despite correct code.\n + + Version 0.9.8c\n * Fix for SSL vulnerability in Microsoft Live SDK (used when accessing files via OneDrive)\n