added to login service for android

This commit is contained in:
Kyle Spearrin 2016-06-06 22:17:09 -04:00
parent 15e154feb0
commit a871a839e7
2 changed files with 44 additions and 1 deletions

View file

@ -5,6 +5,7 @@ using System.Text;
using Android.AccessibilityServices; using Android.AccessibilityServices;
using Android.App; using Android.App;
using Android.Content; using Android.Content;
using Android.Graphics;
using Android.OS; using Android.OS;
using Android.Runtime; using Android.Runtime;
using Android.Views; using Android.Views;
@ -18,14 +19,20 @@ namespace Bit.Android
[MetaData("android.accessibilityservice", Resource = "@xml/accessibilityservice")] [MetaData("android.accessibilityservice", Resource = "@xml/accessibilityservice")]
public class LoginService : AccessibilityService public class LoginService : AccessibilityService
{ {
private View mView;
private WindowManagerLayoutParams mParams;
private IWindowManager mWindowManager;
public override void OnAccessibilityEvent(AccessibilityEvent e) public override void OnAccessibilityEvent(AccessibilityEvent e)
{ {
var eventType = e.EventType; var eventType = e.EventType;
switch(eventType) switch(eventType)
{ {
case EventTypes.ViewTextSelectionChanged: case EventTypes.ViewTextSelectionChanged:
if(e.Source.Password) if(e.Source.Password && string.IsNullOrWhiteSpace(e.Source.Text))
{ {
MakeWindow();
var bundle = new Bundle(); var bundle = new Bundle();
bundle.PutCharSequence(AccessibilityNodeInfo.ActionArgumentSetTextCharsequence, "mypassword"); bundle.PutCharSequence(AccessibilityNodeInfo.ActionArgumentSetTextCharsequence, "mypassword");
e.Source.PerformAction(global::Android.Views.Accessibility.Action.SetText, bundle); e.Source.PerformAction(global::Android.Views.Accessibility.Action.SetText, bundle);
@ -40,5 +47,40 @@ namespace Bit.Android
{ {
} }
public void MakeWindow()
{
mView = new MyLoadView(this);
mParams = new WindowManagerLayoutParams(
WindowManagerTypes.SystemOverlay,
WindowManagerFlags.WatchOutsideTouch,
Format.Translucent);
mParams.Gravity = GravityFlags.Top | GravityFlags.Right;
mParams.Title = "Test window";
mWindowManager = GetSystemService(WindowService).JavaCast<IWindowManager>();
mWindowManager.AddView(mView, mParams);
}
public class MyLoadView : View
{
private Paint mPaint;
public MyLoadView(Context context)
: base(context)
{
mPaint = new Paint();
mPaint.TextSize = 50;
mPaint.SetARGB(200, 200, 200, 200);
}
protected override void OnDraw(Canvas canvas)
{
base.OnDraw(canvas);
canvas.DrawText("test test test", 0, 100, mPaint);
}
}
} }
} }

View file

@ -3,5 +3,6 @@
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="23" /> <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="23" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" /> <uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<application android:label="bitwarden" android:theme="@style/BitwardenTheme"></application> <application android:label="bitwarden" android:theme="@style/BitwardenTheme"></application>
</manifest> </manifest>