mirror of
https://github.com/android-password-store/Android-Password-Store.git
synced 2025-09-07 16:09:38 +02:00
getRootInActiveWindow throws an exception if it is unable to get root
This commit is contained in:
parent
9b646222ce
commit
a45946988e
|
@ -110,27 +110,32 @@ public class AutofillService extends AccessibilityService {
|
||||||
&& (event.getPackageName().equals("com.android.chrome")
|
&& (event.getPackageName().equals("com.android.chrome")
|
||||||
|| event.getPackageName().equals("com.android.browser")))) {
|
|| event.getPackageName().equals("com.android.browser")))) {
|
||||||
// there is a chance for getRootInActiveWindow() to return null at any time. save it.
|
// there is a chance for getRootInActiveWindow() to return null at any time. save it.
|
||||||
AccessibilityNodeInfo root = getRootInActiveWindow();
|
try {
|
||||||
webViewTitle = searchWebView(root);
|
AccessibilityNodeInfo root = getRootInActiveWindow();
|
||||||
webViewURL = null;
|
webViewTitle = searchWebView(root);
|
||||||
if (webViewTitle != null) {
|
webViewURL = null;
|
||||||
List<AccessibilityNodeInfo> nodes = root.findAccessibilityNodeInfosByViewId("com.android.chrome:id/url_bar");
|
if (webViewTitle != null) {
|
||||||
if (nodes.isEmpty()) {
|
List<AccessibilityNodeInfo> nodes = root.findAccessibilityNodeInfosByViewId("com.android.chrome:id/url_bar");
|
||||||
nodes = root.findAccessibilityNodeInfosByViewId("com.android.browser:id/url");
|
if (nodes.isEmpty()) {
|
||||||
}
|
nodes = root.findAccessibilityNodeInfosByViewId("com.android.browser:id/url");
|
||||||
for (AccessibilityNodeInfo node : nodes)
|
}
|
||||||
if (node.getText() != null) {
|
for (AccessibilityNodeInfo node : nodes)
|
||||||
try {
|
if (node.getText() != null) {
|
||||||
webViewURL = new URL(node.getText().toString()).getHost();
|
try {
|
||||||
} catch (MalformedURLException e) {
|
webViewURL = new URL(node.getText().toString()).getHost();
|
||||||
if (e.toString().contains("Protocol not found")) {
|
} catch (MalformedURLException e) {
|
||||||
try {
|
if (e.toString().contains("Protocol not found")) {
|
||||||
webViewURL = new URL("http://" + node.getText().toString()).getHost();
|
try {
|
||||||
} catch (MalformedURLException ignored) {
|
webViewURL = new URL("http://" + node.getText().toString()).getHost();
|
||||||
|
} catch (MalformedURLException ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// sadly we were unable to access the data we wanted
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue