mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-26 03:19:45 +00:00
So long redphone
// FREEBIE
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package org.thoughtcrime.securesms.webrtc;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Allows multiple default uncaught exception handlers to be registered
|
||||
*
|
||||
* Calls all registered handlers in reverse order of registration.
|
||||
* Errors in one handler do not prevent subsequent handlers from being called.
|
||||
*/
|
||||
public class UncaughtExceptionHandlerManager implements Thread.UncaughtExceptionHandler {
|
||||
private final Thread.UncaughtExceptionHandler originalHandler;
|
||||
private final List<Thread.UncaughtExceptionHandler> handlers = new ArrayList<Thread.UncaughtExceptionHandler>();
|
||||
|
||||
public UncaughtExceptionHandlerManager() {
|
||||
originalHandler = Thread.getDefaultUncaughtExceptionHandler();
|
||||
registerHandler(originalHandler);
|
||||
Thread.setDefaultUncaughtExceptionHandler(this);
|
||||
}
|
||||
|
||||
public void registerHandler(Thread.UncaughtExceptionHandler handler) {
|
||||
handlers.add(handler);
|
||||
}
|
||||
|
||||
public void unregister() {
|
||||
Thread.setDefaultUncaughtExceptionHandler(originalHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uncaughtException(Thread thread, Throwable throwable) {
|
||||
for (int i = handlers.size() - 1; i >= 0; i--) {
|
||||
try {
|
||||
handlers.get(i).uncaughtException(thread, throwable);
|
||||
} catch(Throwable t) {
|
||||
Log.e("UncaughtExceptionHandlerManager", "Error in uncaught exception handling", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user