summaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorMatthew Wong <wongma7@outlook.com>2016-01-03 20:39:37 -0500
committerMatthew Wong <wongma7@outlook.com>2016-01-03 20:39:37 -0500
commitaaa9af93defeee1daea6c79b517e67a7ce754803 (patch)
tree3dee726fe2f7a7295ea41253547dbc095e687b1b /app/src
parent6ef9e3bbcabdc24ee6d89529dd2513ac842df986 (diff)
fix getrootinactivewindow() nullpointerexceptions
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java15
1 files changed, 6 insertions, 9 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 7346973c..526d6f98 100644
--- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java
+++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java
@@ -108,17 +108,14 @@ public class AutofillService extends AccessibilityService {
&& event.getSource() != null
&& (event.getSource().getPackageName().equals("com.android.chrome")
|| event.getSource().getPackageName().equals("com.android.browser")))) {
- webViewTitle = searchWebView(getRootInActiveWindow());
-
- // non-null webViewTitle means there is a webView. But still somehow
- // getRootInActiveWindow() can be null, when switching windows
+ // there is a chance for getRootInActiveWindow() to return null at any time. save it.
+ AccessibilityNodeInfo root = getRootInActiveWindow();
+ webViewTitle = searchWebView(root);
webViewURL = null;
- if (webViewTitle != null && getRootInActiveWindow() != null) {
- List<AccessibilityNodeInfo> nodes = getRootInActiveWindow()
- .findAccessibilityNodeInfosByViewId("com.android.chrome:id/url_bar");
+ if (webViewTitle != null) {
+ List<AccessibilityNodeInfo> nodes = root.findAccessibilityNodeInfosByViewId("com.android.chrome:id/url_bar");
if (nodes.isEmpty()) {
- nodes = getRootInActiveWindow()
- .findAccessibilityNodeInfosByViewId("com.android.browser:id/url");
+ nodes = root.findAccessibilityNodeInfosByViewId("com.android.browser:id/url");
}
for (AccessibilityNodeInfo node : nodes)
if (node.getText() != null) {