mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 15:15:34 +03:00
Rename accessibility service to AutofillService. Remove autofill service from app for now until it is being worked on again.
This commit is contained in:
parent
3807f185d6
commit
873ebee256
3 changed files with 46 additions and 87 deletions
|
@ -289,7 +289,7 @@
|
||||||
<Compile Include="Controls\ExtendedTabbedPageRenderer.cs" />
|
<Compile Include="Controls\ExtendedTabbedPageRenderer.cs" />
|
||||||
<Compile Include="Controls\ExtendedTableViewRenderer.cs" />
|
<Compile Include="Controls\ExtendedTableViewRenderer.cs" />
|
||||||
<Compile Include="HockeyAppCrashManagerListener.cs" />
|
<Compile Include="HockeyAppCrashManagerListener.cs" />
|
||||||
<Compile Include="LoginService.cs" />
|
<Compile Include="AutofillService.cs" />
|
||||||
<Compile Include="Controls\ExtendedEditorRenderer.cs" />
|
<Compile Include="Controls\ExtendedEditorRenderer.cs" />
|
||||||
<Compile Include="Controls\ExtendedSwitchCellRenderer.cs" />
|
<Compile Include="Controls\ExtendedSwitchCellRenderer.cs" />
|
||||||
<Compile Include="Controls\ExtendedViewCellRenderer.cs" />
|
<Compile Include="Controls\ExtendedViewCellRenderer.cs" />
|
||||||
|
|
45
src/Android/AutofillService.cs
Normal file
45
src/Android/AutofillService.cs
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Android.AccessibilityServices;
|
||||||
|
using Android.App;
|
||||||
|
using Android.Content;
|
||||||
|
using Android.Graphics;
|
||||||
|
using Android.OS;
|
||||||
|
using Android.Runtime;
|
||||||
|
using Android.Views;
|
||||||
|
using Android.Views.Accessibility;
|
||||||
|
using Android.Widget;
|
||||||
|
|
||||||
|
namespace Bit.Android
|
||||||
|
{
|
||||||
|
//[Service(Permission = "android.permission.BIND_ACCESSIBILITY_SERVICE", Label = "bitwarden")]
|
||||||
|
//[IntentFilter(new string[] { "android.accessibilityservice.AccessibilityService" })]
|
||||||
|
//[MetaData("android.accessibilityservice", Resource = "@xml/accessibilityservice")]
|
||||||
|
public class AutofillService : AccessibilityService
|
||||||
|
{
|
||||||
|
public override void OnAccessibilityEvent(AccessibilityEvent e)
|
||||||
|
{
|
||||||
|
var eventType = e.EventType;
|
||||||
|
switch(eventType)
|
||||||
|
{
|
||||||
|
case EventTypes.ViewTextSelectionChanged:
|
||||||
|
if(e.Source.Password && string.IsNullOrWhiteSpace(e.Source.Text))
|
||||||
|
{
|
||||||
|
var bundle = new Bundle();
|
||||||
|
bundle.PutCharSequence(AccessibilityNodeInfo.ActionArgumentSetTextCharsequence, "mypassword");
|
||||||
|
e.Source.PerformAction(global::Android.Views.Accessibility.Action.SetText, bundle);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnInterrupt()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,86 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Android.AccessibilityServices;
|
|
||||||
using Android.App;
|
|
||||||
using Android.Content;
|
|
||||||
using Android.Graphics;
|
|
||||||
using Android.OS;
|
|
||||||
using Android.Runtime;
|
|
||||||
using Android.Views;
|
|
||||||
using Android.Views.Accessibility;
|
|
||||||
using Android.Widget;
|
|
||||||
|
|
||||||
namespace Bit.Android
|
|
||||||
{
|
|
||||||
[Service(Permission = "android.permission.BIND_ACCESSIBILITY_SERVICE", Label = "bitwarden")]
|
|
||||||
[IntentFilter(new string[] { "android.accessibilityservice.AccessibilityService" })]
|
|
||||||
[MetaData("android.accessibilityservice", Resource = "@xml/accessibilityservice")]
|
|
||||||
public class LoginService : AccessibilityService
|
|
||||||
{
|
|
||||||
private View mView;
|
|
||||||
|
|
||||||
private WindowManagerLayoutParams mParams;
|
|
||||||
private IWindowManager mWindowManager;
|
|
||||||
|
|
||||||
public override void OnAccessibilityEvent(AccessibilityEvent e)
|
|
||||||
{
|
|
||||||
var eventType = e.EventType;
|
|
||||||
switch(eventType)
|
|
||||||
{
|
|
||||||
case EventTypes.ViewTextSelectionChanged:
|
|
||||||
if(e.Source.Password && string.IsNullOrWhiteSpace(e.Source.Text))
|
|
||||||
{
|
|
||||||
MakeWindow();
|
|
||||||
var bundle = new Bundle();
|
|
||||||
bundle.PutCharSequence(AccessibilityNodeInfo.ActionArgumentSetTextCharsequence, "mypassword");
|
|
||||||
e.Source.PerformAction(global::Android.Views.Accessibility.Action.SetText, bundle);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnInterrupt()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue