From c9725d71868384193e470938850571a9f3cbde66 Mon Sep 17 00:00:00 2001 From: Matthew Wong Date: Mon, 7 Mar 2016 20:35:24 -0500 Subject: fix crash if url not found --- .../com/zeapo/pwdstore/autofill/AutofillService.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'app') 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 145843fc..4cd91abd 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java @@ -200,6 +200,7 @@ public class AutofillService extends AccessibilityService { setMatchingPasswords(appName, packageName, false); } else { + // now we may have found a title but webViewURL could be null packageName = setMatchingPasswords(webViewTitle, webViewURL, true); appName = packageName; isWeb = true; @@ -255,6 +256,7 @@ public class AutofillService extends AccessibilityService { } } + // TODO split this into 2 functions for isWeb and !isWeb private String setMatchingPasswords(String appName, String packageName, boolean isWeb) { // Return the URL needed to open the corresponding Settings. String settingsURL = packageName; @@ -272,12 +274,14 @@ public class AutofillService extends AccessibilityService { } else { prefs = getSharedPreferences("autofill_web", Context.MODE_PRIVATE); preference = defValue; - Map prefsMap = prefs.getAll(); - for (String key : prefsMap.keySet()) { - if ((webViewURL.toLowerCase().contains(key.toLowerCase()) || key.toLowerCase().contains(webViewURL.toLowerCase())) - && !prefs.getString(key, null).equals("")) { - preference = prefs.getString(key, null); - settingsURL = key; + if (webViewURL != null) { + Map prefsMap = prefs.getAll(); + for (String key : prefsMap.keySet()) { + if ((webViewURL.toLowerCase().contains(key.toLowerCase()) || key.toLowerCase().contains(webViewURL.toLowerCase())) + && !prefs.getString(key, null).equals("")) { + preference = prefs.getString(key, null); + settingsURL = key; + } } } } -- cgit v1.2.3