修复 某些情况下调用app.sendBroadcast("inspect_layout_bounds")等崩溃的问题

This commit is contained in:
hyb1996
2018-10-18 00:21:26 +08:00
parent fbe2df406a
commit 0bccf1c3a3

View File

@@ -63,12 +63,18 @@ public class AutoJs extends com.stardust.autojs.AutoJs {
private BroadcastReceiver mLayoutInspectBroadcastReceiver = new BroadcastReceiver() { private BroadcastReceiver mLayoutInspectBroadcastReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
ensureAccessibilityServiceEnabled(); try {
String action = intent.getAction(); ensureAccessibilityServiceEnabled();
if (LayoutBoundsFloatyWindow.class.getName().equals(action)) { String action = intent.getAction();
capture(LayoutBoundsFloatyWindow::new); if (LayoutBoundsFloatyWindow.class.getName().equals(action)) {
} else if (LayoutHierarchyFloatyWindow.class.getName().equals(action)) { capture(LayoutBoundsFloatyWindow::new);
capture(LayoutHierarchyFloatyWindow::new); } else if (LayoutHierarchyFloatyWindow.class.getName().equals(action)) {
capture(LayoutHierarchyFloatyWindow::new);
}
} catch (Exception e) {
if (Looper.myLooper() != Looper.getMainLooper()) {
throw e;
}
} }
} }
}; };