Skip to content

Commit

Permalink
Don't crash on missing extra (#1615)
Browse files Browse the repository at this point in the history
Fixes #1607
  • Loading branch information
pyricau committed Nov 13, 2019
1 parent b31c6c3 commit c9f2e66
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ internal class HeapAnalyzerService : ForegroundService(
), OnAnalysisProgressListener {

override fun onHandleIntentInForeground(intent: Intent?) {
if (intent == null) {
SharkLog.d { "HeapAnalyzerService received a null intent, ignoring." }
if (intent == null || !intent.hasExtra(HEAPDUMP_FILE_EXTRA)) {
SharkLog.d { "HeapAnalyzerService received a null or empty intent, ignoring." }
return
}

// Since we're running in the main process we should be careful not to impact it.
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND)
val heapDumpFile = intent.getSerializableExtra(HEAPDUMP_FILE_EXTRA) as File
Expand Down Expand Up @@ -89,7 +90,7 @@ internal class HeapAnalyzerService : ForegroundService(
startForegroundService(context, intent)
}

fun startForegroundService(
private fun startForegroundService(
context: Context,
intent: Intent
) {
Expand Down

0 comments on commit c9f2e66

Please sign in to comment.