fix: app ANR when crash
This commit is contained in:
@@ -1 +1 @@
|
|||||||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1},"path":"inrt-release.apk","properties":{"packageId":"com.stardust.auojs.inrt","split":"","minSdkVersion":"17"}}]
|
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":231},"path":"release-3.0.0 Alpha31.apk","properties":{"packageId":"com.stardust.scriptdroid","split":"","minSdkVersion":"17"}}]
|
||||||
@@ -14,7 +14,7 @@ function showLoginUI(){
|
|||||||
</linear>
|
</linear>
|
||||||
<linear>
|
<linear>
|
||||||
<text w="56" gravity="center" color="#111111" size="16">密码</text>
|
<text w="56" gravity="center" color="#111111" size="16">密码</text>
|
||||||
<input id="password" w="*" h="40" inputType="password"/>
|
<input id="password" w="*" h="40" password="true"/>
|
||||||
</linear>
|
</linear>
|
||||||
<linear gravity="center">
|
<linear gravity="center">
|
||||||
<button id="login" text="登录"/>
|
<button id="login" text="登录"/>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import android.graphics.Bitmap;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.support.multidex.MultiDexApplication;
|
import android.support.multidex.MultiDexApplication;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
@@ -57,6 +58,8 @@ public class App extends MultiDexApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setUpStaticsTool() {
|
private void setUpStaticsTool() {
|
||||||
|
if (BuildConfig.DEBUG)
|
||||||
|
return;
|
||||||
new FlurryAgent.Builder()
|
new FlurryAgent.Builder()
|
||||||
.withLogEnabled(BuildConfig.DEBUG)
|
.withLogEnabled(BuildConfig.DEBUG)
|
||||||
.build(this, "D42MH48ZN4PJC5TKNYZD");
|
.build(this, "D42MH48ZN4PJC5TKNYZD");
|
||||||
@@ -68,8 +71,8 @@ public class App extends MultiDexApplication {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LeakCanary.install(this);
|
LeakCanary.install(this);
|
||||||
if (!BuildConfig.DEBUG)
|
//if (!BuildConfig.DEBUG)
|
||||||
Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(ErrorReportActivity.class));
|
Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(ErrorReportActivity.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
|
|||||||
@@ -6,14 +6,15 @@ package com.stardust.scriptdroid.tool;
|
|||||||
|
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.Build;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.stardust.scriptdroid.App;
|
import com.stardust.scriptdroid.App;
|
||||||
import com.stardust.scriptdroid.R;
|
import com.stardust.scriptdroid.R;
|
||||||
import com.stardust.scriptdroid.accessibility.AccessibilityService;
|
|
||||||
import com.stardust.util.IntentUtil;
|
import com.stardust.util.IntentUtil;
|
||||||
|
import com.stardust.view.accessibility.AccessibilityService;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
@@ -37,13 +38,19 @@ public class CrashHandler implements UncaughtExceptionHandler {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Log.e(TAG, "Uncaught Exception", ex);
|
Log.e(TAG, "Uncaught Exception", ex);
|
||||||
|
AccessibilityService service = AccessibilityService.getInstance();
|
||||||
|
if (service != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
service.disableSelf();
|
||||||
|
}
|
||||||
if (crashTooManyTimes())
|
if (crashTooManyTimes())
|
||||||
return;
|
return;
|
||||||
String msg = App.getApp().getString(R.string.sorry_for_crash) + ex.toString();
|
String msg = App.getApp().getString(R.string.sorry_for_crash) + ex.toString();
|
||||||
startErrorReportActivity(msg, throwableToString(ex));
|
startErrorReportActivity(msg, throwableToString(ex));
|
||||||
|
System.exit(0);
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
throwable.printStackTrace();
|
throwable.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean causedByBadWindowToken(Throwable e) {
|
private static boolean causedByBadWindowToken(Throwable e) {
|
||||||
|
|||||||
@@ -313,20 +313,25 @@ public class ScriptRuntime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onExit() {
|
public void onExit() {
|
||||||
threads.shutDownAll();
|
try {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
threads.shutDownAll();
|
||||||
images.releaseScreenCapturer();
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||||
}
|
images.releaseScreenCapturer();
|
||||||
if (mRootShell != null) {
|
}
|
||||||
mRootShell.exitAndWaitFor();
|
|
||||||
}
|
if (events != null) {
|
||||||
mRootShell = null;
|
events.recycle();
|
||||||
mShellSupplier = null;
|
}
|
||||||
if (events != null) {
|
if (loopers != null) {
|
||||||
events.recycle();
|
loopers.quitAll();
|
||||||
}
|
}
|
||||||
if (loopers != null) {
|
if (mRootShell != null) {
|
||||||
loopers.quitAll();
|
mRootShell.exitAndWaitFor();
|
||||||
|
}
|
||||||
|
mRootShell = null;
|
||||||
|
mShellSupplier = null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user