Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
QuasselDroid-ng
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Janne Mareike Koschinski
QuasselDroid-ng
Commits
998d8af8
Commit
998d8af8
authored
7 years ago
by
Janne Mareike Koschinski
Browse files
Options
Downloads
Patches
Plain Diff
Improve crash reporting
parent
d93d70c3
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
malheur/src/main/AndroidManifest.xml
+1
-5
1 addition, 5 deletions
malheur/src/main/AndroidManifest.xml
malheur/src/main/java/de/kuschku/malheur/CrashHandler.kt
+26
-1
26 additions, 1 deletion
malheur/src/main/java/de/kuschku/malheur/CrashHandler.kt
with
27 additions
and
6 deletions
malheur/src/main/AndroidManifest.xml
+
1
−
5
View file @
998d8af8
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"de.kuschku.malheur"
>
<uses-permission
android:name=
"android.permission.READ_LOGS"
/>
</manifest>
<manifest
package=
"de.kuschku.malheur"
/>
This diff is collapsed.
Click to expand it.
malheur/src/main/java/de/kuschku/malheur/CrashHandler.kt
+
26
−
1
View file @
998d8af8
package
de.kuschku.malheur
import
android.app.Application
import
android.os.Handler
import
android.os.HandlerThread
import
android.util.Log
import
android.widget.Toast
import
com.google.gson.GsonBuilder
import
de.kuschku.malheur.collectors.ReportCollector
import
de.kuschku.malheur.config.ReportConfig
import
java.io.File
import
java.util.*
object
CrashHandler
{
...
...
@@ -12,16 +17,26 @@ object CrashHandler {
private
val
startTime
=
Date
()
private
var
originalHandler
:
Thread
.
UncaughtExceptionHandler
?
=
null
private
lateinit
var
handler
:
Handler
fun
init
(
application
:
Application
,
config
:
ReportConfig
=
ReportConfig
(),
buildConfig
:
Class
<
*
>?)
{
if
(
myHandler
==
null
)
{
originalHandler
=
Thread
.
getDefaultUncaughtExceptionHandler
()
}
val
handlerThread
=
HandlerThread
(
"Malheur"
)
handlerThread
.
start
()
handler
=
Handler
(
handlerThread
.
looper
)
val
reportCollector
=
ReportCollector
(
application
)
myHandler
=
Thread
.
UncaughtExceptionHandler
{
activeThread
,
throwable
->
val
crashTime
=
Date
()
val
stackTraces
=
Thread
.
getAllStackTraces
()
Log
.
e
(
"Malheur"
,
"Creating crash report"
)
handler
.
post
{
Toast
.
makeText
(
application
,
"Creating crash report"
,
Toast
.
LENGTH_LONG
).
show
()
}
Thread
{
try
{
val
json
=
gson
.
toJson
(
...
...
@@ -38,7 +53,17 @@ object CrashHandler {
),
config
)
)
// FIXME STOPSHIP Implement crash handling
val
crashDirectory
=
File
(
application
.
cacheDir
,
"crashes"
)
crashDirectory
.
mkdirs
()
val
crashFile
=
File
(
crashDirectory
,
"${System.currentTimeMillis()}.json"
)
crashFile
.
createNewFile
()
crashFile
.
writeText
(
json
)
Log
.
e
(
"Malheur"
,
"Crash report saved: $crashFile"
)
handler
.
post
{
Toast
.
makeText
(
application
,
"Crash report saved: ${crashFile.name}"
,
Toast
.
LENGTH_LONG
).
show
()
}
}
catch
(
e
:
Throwable
)
{
e
.
printStackTrace
()
originalHandler
?.
uncaughtException
(
activeThread
,
throwable
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment