diff --git a/src/Android/Android.csproj b/src/Android/Android.csproj index 63b5a73c5..12c7de4ec 100644 --- a/src/Android/Android.csproj +++ b/src/Android/Android.csproj @@ -298,6 +298,7 @@ + diff --git a/src/Android/AutofillActivity.cs b/src/Android/AutofillActivity.cs index 54f23c2ec..217fbb5e5 100644 --- a/src/Android/AutofillActivity.cs +++ b/src/Android/AutofillActivity.cs @@ -22,19 +22,25 @@ namespace Bit.Android var url = Intent.GetStringExtra("url"); _lastQueriedUrl = url; - //StartActivityForResult(Kp2aControl.GetQueryEntryIntent(url), 123); + + Intent intent = new Intent(this, typeof(AutofillSelectLoginActivity)); + intent.PutExtra("url", url); + StartActivityForResult(intent, 123); } string _lastQueriedUrl; protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) { + var url = data.GetStringExtra("url"); + var username = data.GetStringExtra("username"); + var password = data.GetStringExtra("password"); + base.OnActivityResult(requestCode, resultCode, data); try { - // TODO: lookup login - LastReceivedCredentials = new Credentials { User = "username", Password = "12345678", Url = _lastQueriedUrl }; + LastReceivedCredentials = new Credentials { User = username, Password = password, Url = _lastQueriedUrl }; } catch(Exception e) { diff --git a/src/Android/AutofillSelectLoginActivity.cs b/src/Android/AutofillSelectLoginActivity.cs new file mode 100644 index 000000000..01e3cc800 --- /dev/null +++ b/src/Android/AutofillSelectLoginActivity.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Android.App; +using Android.Content; +using Android.OS; + +namespace Bit.Android +{ + //[Activity(LaunchMode = global::Android.Content.PM.LaunchMode.SingleInstance)] + public class AutofillSelectLoginActivity : Activity + { + protected override void OnCreate(Bundle bundle) + { + base.OnCreate(bundle); + var url = Intent.GetStringExtra("url"); + + Intent data = new Intent(); + data.PutExtra("url", url); + data.PutExtra("username", "user123"); + data.PutExtra("password", "pass123"); + + if(Parent == null) + { + SetResult(Result.Ok, data); + } + else + { + Parent.SetResult(Result.Ok, data); + } + + Finish(); + } + } +} \ No newline at end of file diff --git a/src/Android/AutofillService.cs b/src/Android/AutofillService.cs index c03f6adeb..a232e70b5 100644 --- a/src/Android/AutofillService.cs +++ b/src/Android/AutofillService.cs @@ -25,6 +25,7 @@ namespace Bit.Android public override void OnAccessibilityEvent(AccessibilityEvent e) { var eventType = e.EventType; + System.Diagnostics.Debug.WriteLine(DateTime.UtcNow.ToString() + " Event Type: " + eventType); var package = e.PackageName; switch(eventType) { @@ -122,8 +123,9 @@ namespace Bit.Android { if(url1.StartsWith("androidapp://")) return url1 == url2; - //return KeePassLib.Utility.UrlUtil.GetHost(url1) == KeePassLib.Utility.UrlUtil.GetHost(url2); - return false; + // TODO: host check + return url1 == url2; + //return false; } private static bool IsPasswordField(AccessibilityNodeInfo n) diff --git a/src/Android/Resources/xml/accessibilityservice.xml b/src/Android/Resources/xml/accessibilityservice.xml index a8a416552..0c63cc3b8 100644 --- a/src/Android/Resources/xml/accessibilityservice.xml +++ b/src/Android/Resources/xml/accessibilityservice.xml @@ -4,4 +4,5 @@ android:accessibilityFeedbackType="feedbackSpoken" android:accessibilityFlags="flagDefault" android:notificationTimeout="100" - android:canRetrieveWindowContent="true"/> \ No newline at end of file + android:canRetrieveWindowContent="true" + android:canRequestEnhancedWebAccessibility="true"/> \ No newline at end of file