Package org.mozilla.geckoview
Class CrashHandler
Object
org.mozilla.geckoview.CrashHandler
- All Implemented Interfaces:
Thread.UncaughtExceptionHandler
Handler for processing application crashes and sending crash reports.
-
Constructor Summary
ConstructorsConstructorDescriptionCrashHandler(Context aAppContext, Class<? extends Service> aHandlerService) Create and register a CrashHandler for all threads and thread groups.CrashHandler(Class<? extends Service> handlerService) Create and register a CrashHandler for all threads and thread groups.CrashHandler(Thread thread, Context aAppContext, Class<? extends Service> aHandlerService) Create and register a CrashHandler for a particular thread.CrashHandler(Thread thread, Class<? extends Service> handlerService) Create and register a CrashHandler for a particular thread. -
Method Summary
Modifier and TypeMethodDescriptionstatic CrashHandlercreateDefaultCrashHandler(Context context) Return a default CrashHandler object for all threads and thread groups.byte[]getCrashDump(Thread thread, Throwable exc) Get the crash minidump content to be reported.getCrashExtras(Thread thread, Throwable exc) Get the crash "extras" to be reported.static StringGet the standard stack trace string of an exception.static ThrowableGet the root exception from the 'cause' chain of an exception.getServerUrl(Bundle extras) Get the server URL to send the crash report to.booleanlaunchCrashReporter(String dumpFile, String extraFile) Launch the crash reporter activity that sends the crash report to the server.static voidlogException(Thread thread, Throwable exc) Record an exception stack in logs.booleanreportException(Thread thread, Throwable exc) Report an exception to Socorro.static voidTerminate the current process.voiduncaughtException(Thread thread, Throwable exc) Implements the default behavior for handling uncaught exceptions.voidUnregister this CrashHandler for exception handling.
-
Constructor Details
-
CrashHandler
Create and register a CrashHandler for all threads and thread groups.- Parameters:
handlerService- Service receiving native code crashes
-
CrashHandler
public CrashHandler(@Nullable Context aAppContext, @Nullable Class<? extends Service> aHandlerService) Create and register a CrashHandler for all threads and thread groups.- Parameters:
aAppContext- A Context for retrieving application information.aHandlerService- Service receiving native code crashes
-
CrashHandler
Create and register a CrashHandler for a particular thread.- Parameters:
thread- A thread to register the CrashHandlerhandlerService- Service receiving native code crashes
-
CrashHandler
public CrashHandler(@Nullable Thread thread, Context aAppContext, Class<? extends Service> aHandlerService) Create and register a CrashHandler for a particular thread.- Parameters:
thread- A thread to register the CrashHandleraAppContext- A Context for retrieving application information.aHandlerService- Service receiving native code crashes
-
-
Method Details
-
getRootException
Get the root exception from the 'cause' chain of an exception.- Parameters:
exc- An exception- Returns:
- The root exception
-
getExceptionStackTrace
Get the standard stack trace string of an exception.- Parameters:
exc- An exception- Returns:
- The exception stack trace.
-
terminateProcess
@AnyThread public static void terminateProcess()Terminate the current process. -
unregister
@AnyThread public void unregister()Unregister this CrashHandler for exception handling. -
logException
Record an exception stack in logs.- Parameters:
thread- The exception threadexc- An exception
-
getAppPackageName
- Returns:
- the application package name. if context is not null; if context is null, CrashHandler's package name will be returned.
-
getAppContext
- Returns:
- application context.
-
getCrashExtras
Get the crash "extras" to be reported.- Parameters:
thread- The exception threadexc- An exception- Returns:
- "Extras" in the from of a Bundle
-
getCrashDump
Get the crash minidump content to be reported.- Parameters:
thread- The exception threadexc- An exception- Returns:
- Minidump content
-
getServerUrl
Get the server URL to send the crash report to.- Parameters:
extras- The crash extras Bundle- Returns:
- the URL that the crash reporter will submit reports to.
-
launchCrashReporter
Launch the crash reporter activity that sends the crash report to the server.- Parameters:
dumpFile- Path for the minidump fileextraFile- Path for the crash extra file- Returns:
- Whether the crash reporter was successfully launched
-
reportException
Report an exception to Socorro.- Parameters:
thread- The exception threadexc- An exception- Returns:
- Whether the exception was successfully reported
-
uncaughtException
Implements the default behavior for handling uncaught exceptions.- Specified by:
uncaughtExceptionin interfaceThread.UncaughtExceptionHandler- Parameters:
thread- The exception threadexc- An uncaught exception
-
createDefaultCrashHandler
Return a default CrashHandler object for all threads and thread groups.- Parameters:
context- application context- Returns:
- a default CrashHandler object
-