Skip to content

Commit b4ff9bc

Browse files
author
维术
committed
[Exposed-core] crash handler for virtual process.
1 parent 82f43ed commit b4ff9bc

File tree

1 file changed

+13
-0
lines changed
  • VirtualApp/app/src/main/java/io/virtualapp

1 file changed

+13
-0
lines changed

VirtualApp/app/src/main/java/io/virtualapp/VApp.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import android.content.Context;
44
import android.content.SharedPreferences;
5+
import android.os.Looper;
56
import android.support.multidex.MultiDexApplication;
67
import android.util.Log;
78

89
import com.flurry.android.FlurryAgent;
10+
import com.lody.virtual.client.core.CrashHandler;
911
import com.lody.virtual.client.core.InstallStrategy;
1012
import com.lody.virtual.client.core.VirtualCore;
1113
import com.lody.virtual.client.stub.VASettings;
@@ -125,6 +127,17 @@ public void onVirtualProcess() {
125127
virtualCore.setPhoneInfoDelegate(new MyPhoneInfoDelegate());
126128
//fake task description's icon and title
127129
virtualCore.setTaskDescriptionDelegate(new MyTaskDescriptionDelegate());
130+
virtualCore.setCrashHandler(new CrashHandler() {
131+
@Override
132+
public void handleUncaughtException(Thread t, Throwable e) {
133+
Log.i(TAG, "uncaught :" + t, e);
134+
if (t == Looper.getMainLooper().getThread()) {
135+
System.exit(0);
136+
} else {
137+
Log.e(TAG, "ignore uncaught exception of thread: " + t);
138+
}
139+
}
140+
});
128141
// ensure the logcat service alive when every virtual process start.
129142
LogcatService.start(VApp.this, VEnvironment.getDataUserPackageDirectory(0, XPOSED_INSTALLER_PACKAGE));
130143
}

0 commit comments

Comments
 (0)