use of com.stardust.view.accessibility.AccessibilityService in project Auto.js by hyb1996.
the class CrashHandler method uncaughtException.
public void uncaughtException(Thread thread, Throwable ex) {
if (thread != Looper.getMainLooper().getThread()) {
Log.e(TAG, "Uncaught Exception", ex);
return;
}
AccessibilityService service = AccessibilityService.getInstance();
if (service != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
service.disableSelf();
}
if (BuildConfig.DEBUG) {
mDefaultHandler.uncaughtException(thread, ex);
return;
}
if (causedByBadWindowToken(ex)) {
Toast.makeText(App.getApp(), R.string.text_no_floating_window_permission, Toast.LENGTH_SHORT).show();
IntentUtil.goToAppDetailSettings(App.getApp());
} else {
try {
Log.e(TAG, "Uncaught Exception", ex);
if (crashTooManyTimes())
return;
String msg = App.getApp().getString(R.string.sorry_for_crash) + ex.toString();
startErrorReportActivity(msg, throwableToString(ex));
System.exit(1);
} catch (Throwable throwable) {
throwable.printStackTrace();
}
}
}
use of com.stardust.view.accessibility.AccessibilityService in project Auto.js by hyb1996.
the class Events method observeKey.
public void observeKey() {
if (mListeningKey)
return;
mScriptRuntime.ensureAccessibilityServiceEnabled();
AccessibilityService service = mAccessibilityBridge.getService();
if (service == null)
throw new ScriptException("AccessibilityService = null");
if ((service.getServiceInfo().flags & AccessibilityServiceInfo.FLAG_REQUEST_FILTER_KEY_EVENTS) == 0) {
throw new ScriptException(mContext.getString(R.string.text_should_enable_key_observing));
}
ensureHandler();
mLoopers.waitWhenIdle(true);
mListeningKey = true;
mAccessibilityBridge.ensureServiceEnabled();
service.getOnKeyObserver().addListener(this);
}
use of com.stardust.view.accessibility.AccessibilityService in project Auto.js by hyb1996.
the class Events method recycle.
public void recycle() {
if (mListeningKey) {
AccessibilityService service = mAccessibilityBridge.getService();
if (service != null) {
service.getOnKeyObserver().removeListener(this);
mListeningKey = false;
}
}
if (mTouchObserver != null) {
mTouchObserver.stop();
}
if (mListeningNotification) {
mAccessibilityBridge.getNotificationObserver().removeNotificationListener(this);
mAccessibilityBridge.getNotificationObserver().removeToastListener(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && NotificationListenerService.getInstance() != null) {
NotificationListenerService.getInstance().removeListener(this);
}
}
}
use of com.stardust.view.accessibility.AccessibilityService in project Auto.js by hyb1996.
the class LayoutInspector method captureCurrentWindow.
public void captureCurrentWindow() {
AccessibilityService service = AccessibilityService.getInstance();
if (service == null) {
Log.d(LOG_TAG, "captureCurrentWindow: service = null");
mCapture = null;
return;
}
final AccessibilityNodeInfo root = getRootInActiveWindow(service);
if (root == null) {
Log.d(LOG_TAG, "captureCurrentWindow: root = null");
mCapture = null;
return;
}
mExecutor.execute(() -> {
mDumping = true;
mCapture = NodeInfo.capture(root);
mDumping = false;
for (CaptureAvailableListener l : mCaptureAvailableListeners) {
l.onCaptureAvailable(mCapture);
}
});
}
Aggregations