How to identify a Login Page of a App from my app using Accessibility in android

474 views Asked by At
  1. Hi. Using Accessibility, i am trying to auto fill username & password of an any app from my app which is managing username & password of all apps like dashlane. i found one way to auto fill field value using Action_Paste. when user starts to focusing on EditText it will get the AccessibilityNodeInfo by using getSource() method, using that it auto fills EditText Filed, below is a code for above process.

Code:

    AccessibilityNodeInfo source = event.getSource();
            if (source != null) {
            ClipboardManager clipboard = (ClipboardManager) MyAccessibilityService.this.getSystemService(Context.CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText("label", "TEST DATA");
            clipboard.setPrimaryClip(clip);
            source.performAction(AccessibilityNodeInfo.ACTION_PASTE);
            Toast.makeText(MyAccessibilityService.this, "Pasted Successfully", Toast.LENGTH_LONG).show(0;
             }

Here i need to extend my ui like, it needs identify the login page, once its confirmed as a login page it will show the list of login item. based on user selection it will auto fill username field & password field.

Here i have two question

  1. how to identify the login page of an app, i tried something like, when user clicks a First Edittext filed i will search for next node and check whether it is password filed or not? i used getchild() method. but does not give the child element. When login page loaded in app, i need identify whether it is login field or not? How can i identify a login page, please any tutorial welcome.

  2. based on the source i am filling the field values. if i identified a login page then how to get AccessibilityNodeInfo of username & password. So that i can fill both fields rite?

i spent time for those problem.but i cant get any thing. please anyone can give deep explanation & tutorials for the above problems. thanks.

1

There are 1 answers

0
Prasad Pawar On

Use getRootInActiveWindow() to get the root node & iterate the tree to check all the nodes.

My answer here might help.

This way, you will find your Username & Password nodes.

Now, you can paste the text in these nodes.

But i will suggest to not use clipboard to fill passwords as there are some apps that continuously watch your clipboard.

Such apps can intercept your login credentials.