mirror of
https://github.com/moparisthebest/keepass2android
synced 2024-11-26 03:02:24 -05:00
catch cancelled lookup
allow URL to change after lookup (as long as host remains) add debugging
This commit is contained in:
parent
95fe89f020
commit
641aa5a8b4
@ -73,7 +73,7 @@ namespace keepass2android.AutoFillPlugin
|
||||
var emptyPasswordFields = GetNodeOrChildren(root, n => { return IsPasswordField(n); }).ToList();
|
||||
if (emptyPasswordFields.Any())
|
||||
{
|
||||
if ((LookupCredentialsActivity.LastReceivedCredentials != null) && (LookupCredentialsActivity.LastReceivedCredentials.Url == url))
|
||||
if ((LookupCredentialsActivity.LastReceivedCredentials != null) && IsSame(LookupCredentialsActivity.LastReceivedCredentials.Url, url))
|
||||
{
|
||||
Android.Util.Log.Debug ("KP2AAS", "Filling credentials for " + url);
|
||||
|
||||
@ -82,10 +82,11 @@ namespace keepass2android.AutoFillPlugin
|
||||
else
|
||||
{
|
||||
Android.Util.Log.Debug ("KP2AAS", "Notif for " + url );
|
||||
if (LookupCredentialsActivity.LastReceivedCredentials != null) {
|
||||
if (LookupCredentialsActivity.LastReceivedCredentials != null)
|
||||
{
|
||||
Android.Util.Log.Debug ("KP2AAS", LookupCredentialsActivity.LastReceivedCredentials.Url);
|
||||
|
||||
Android.Util.Log.Debug ("KP2AAS", url);}
|
||||
Android.Util.Log.Debug ("KP2AAS", url);
|
||||
}
|
||||
|
||||
AskFillPassword(url, usernameEdit, emptyPasswordFields);
|
||||
cancelNotification = false;
|
||||
@ -114,6 +115,13 @@ namespace keepass2android.AutoFillPlugin
|
||||
|
||||
}
|
||||
|
||||
private bool IsSame(string url1, string url2)
|
||||
{
|
||||
if (url1.StartsWith ("androidapp://"))
|
||||
return url1 == url2;
|
||||
return KeePassLib.Utility.UrlUtil.GetHost (url1) == KeePassLib.Utility.UrlUtil.GetHost (url2);
|
||||
}
|
||||
|
||||
private static bool IsPasswordField(AccessibilityNodeInfo n)
|
||||
{
|
||||
//if (n.Password) Android.Util.Log.Debug(_logTag, "pwdx with " + (n.Text == null ? "null" : n.Text));
|
||||
|
@ -32,23 +32,32 @@ namespace keepass2android.AutoFillPlugin
|
||||
{
|
||||
base.OnActivityResult(requestCode, resultCode, data);
|
||||
|
||||
var jsonOutput = new Org.Json.JSONObject(data.GetStringExtra(Strings.ExtraEntryOutputData));
|
||||
Dictionary<string, string> output = new Dictionary<string, string>();
|
||||
for (var iter = jsonOutput.Keys(); iter.HasNext;)
|
||||
{
|
||||
string key = iter.Next().ToString();
|
||||
string value = jsonOutput.Get(key).ToString();
|
||||
output[key] = value;
|
||||
}
|
||||
try
|
||||
{
|
||||
|
||||
var jsonOutput = new Org.Json.JSONObject(data.GetStringExtra(Strings.ExtraEntryOutputData));
|
||||
Dictionary<string, string> output = new Dictionary<string, string>();
|
||||
for (var iter = jsonOutput.Keys(); iter.HasNext;)
|
||||
{
|
||||
string key = iter.Next().ToString();
|
||||
string value = jsonOutput.Get(key).ToString();
|
||||
output[key] = value;
|
||||
}
|
||||
|
||||
|
||||
string user = "", password = "";
|
||||
output.TryGetValue(KeePassLib.PwDefs.UserNameField, out user);
|
||||
output.TryGetValue(KeePassLib.PwDefs.PasswordField, out password);
|
||||
Android.Util.Log.Debug ("KP2AAS", "Received credentials for " + _lastQueriedUrl);
|
||||
LastReceivedCredentials = new Credentials() { User = user, Password = password, Url = _lastQueriedUrl };
|
||||
|
||||
Finish();
|
||||
string user = "", password = "";
|
||||
output.TryGetValue(KeePassLib.PwDefs.UserNameField, out user);
|
||||
output.TryGetValue(KeePassLib.PwDefs.PasswordField, out password);
|
||||
Android.Util.Log.Debug ("KP2AAS", "Received credentials for " + _lastQueriedUrl);
|
||||
LastReceivedCredentials = new Credentials() { User = user, Password = password, Url = _lastQueriedUrl };
|
||||
}
|
||||
catch(Exception e) {
|
||||
Android.Util.Log.Debug ("KP2AAS", "Exception while receiving credentials: " + e.ToString());
|
||||
}
|
||||
finally {
|
||||
|
||||
Finish ();
|
||||
}
|
||||
}
|
||||
|
||||
public static Credentials LastReceivedCredentials;
|
||||
|
Loading…
Reference in New Issue
Block a user