-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Termux app specific logic out of CrashHandler
Create the TermuxCrashUtils class that provides the default path and app for termux instead of hardcoding it in CrashHandler. TermuxCrashUtils can be used by termux plugins as well for their own usage or they can implement the CrashHandler.CrashHandlerClient if they want to log to different files or want custom logic.
- Loading branch information
1 parent
93a7525
commit 23a900c
Showing
3 changed files
with
72 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
termux-shared/src/main/java/com/termux/shared/crash/TermuxCrashUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.termux.shared.crash; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import com.termux.shared.termux.TermuxConstants; | ||
import com.termux.shared.termux.TermuxUtils; | ||
|
||
public class TermuxCrashUtils implements CrashHandler.CrashHandlerClient { | ||
|
||
/** | ||
* Set default uncaught crash handler of current thread to {@link CrashHandler} for Termux app | ||
* and its plugin to log crashes at {@link TermuxConstants#TERMUX_CRASH_LOG_FILE_PATH}. | ||
*/ | ||
public static void setCrashHandler(@NonNull final Context context) { | ||
CrashHandler.setCrashHandler(context, new TermuxCrashUtils()); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public String getCrashLogFilePath(Context context) { | ||
return TermuxConstants.TERMUX_CRASH_LOG_FILE_PATH; | ||
} | ||
|
||
@Override | ||
public String getAppInfoMarkdownString(Context context) { | ||
return TermuxUtils.getAppInfoMarkdownString(context, true); | ||
} | ||
|
||
} |