summaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorMatthew Wong <wongma@protonmail.ch>2015-12-31 06:51:47 -0500
committerMatthew Wong <wongma@protonmail.ch>2015-12-31 06:51:47 -0500
commitc3b87f5b18aabf0da72f48259463e4d66ddf6dc7 (patch)
treea1ccdb1c55d51c15b4c78dcf54051874176f1bdd /app/src/main
parentba1ef7a38e1d923d1e0e31f0e16528649df41af8 (diff)
Also check for default browser webview
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java25
1 files changed, 17 insertions, 8 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java
index 39849181..c17d25d5 100644
--- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java
+++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java
@@ -90,6 +90,11 @@ public class AutofillService extends AccessibilityService {
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
+ // TODO there should be a better way of disabling service
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
+ return;
+ }
+
// if returning to the source app from a successful AutofillActivity
if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
&& event.getPackageName().equals(packageName) && resultData != null) {
@@ -98,15 +103,20 @@ public class AutofillService extends AccessibilityService {
// look for webView and trigger accessibility events if window changes
// or if page changes in chrome
- if ((event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
+ if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
|| (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED
- && event.getSource().getPackageName().equals("com.android.chrome")))
- && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
+ && (event.getSource().getPackageName().equals("com.android.chrome")
+ || event.getSource().getPackageName().equals("com.android.browser")))) {
webViewTitle = searchWebView(getRootInActiveWindow());
+
webViewURL = null;
- if (webViewTitle != null && getRootInActiveWindow() != null) {
- List<AccessibilityNodeInfo> nodes = getRootInActiveWindow()
- .findAccessibilityNodeInfosByViewId("com.android.chrome:id/url_bar");
+ if (webViewTitle != null) {
+ List<AccessibilityNodeInfo> nodes = new ArrayList<>();
+ if (event.getSource().getPackageName().equals("com.android.chrome")) {
+ nodes = getRootInActiveWindow().findAccessibilityNodeInfosByViewId("com.android.chrome:id/url_bar");
+ } else if (event.getSource().getPackageName().equals("com.android.browser")) {
+ nodes = getRootInActiveWindow().findAccessibilityNodeInfosByViewId("com.android.browser:id/url");
+ }
for (AccessibilityNodeInfo node : nodes)
if (node.getText() != null) {
try {
@@ -123,10 +133,9 @@ public class AutofillService extends AccessibilityService {
}
}
- // nothing to do if not password field focus, android version, or field is keychain app
+ // nothing to do if not password field focus, field is keychain app
if (!event.isPassword()
|| event.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED
- || Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2
|| event.getPackageName().equals("org.sufficientlysecure.keychain")) {
dismissDialog(event);
return;