Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ import com.f0x1d.logfox.feature.crashes.impl.data.AppInfoDataSource
import com.f0x1d.logfox.feature.crashes.impl.data.CrashCollectorDataSource
import com.f0x1d.logfox.feature.crashes.impl.data.reader.base.BaseCrashDataSource
import com.f0x1d.logfox.feature.logging.api.model.LogLine
import com.f0x1d.logfox.feature.preferences.api.data.LogsSettingsRepository
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
internal class ANRDataSource @Inject constructor(
appInfoDataSource: AppInfoDataSource,
crashCollectorDataSource: CrashCollectorDataSource,
logsSettingsRepository: LogsSettingsRepository,
) : BaseCrashDataSource(appInfoDataSource, crashCollectorDataSource, logsSettingsRepository) {
) : BaseCrashDataSource(appInfoDataSource, crashCollectorDataSource) {

override val crashType = CrashType.ANR

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ import com.f0x1d.logfox.feature.crashes.impl.data.AppInfoDataSource
import com.f0x1d.logfox.feature.crashes.impl.data.CrashCollectorDataSource
import com.f0x1d.logfox.feature.crashes.impl.data.reader.base.BaseCrashDataSource
import com.f0x1d.logfox.feature.logging.api.model.LogLine
import com.f0x1d.logfox.feature.preferences.api.data.LogsSettingsRepository
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
internal class JNICrashDataSource @Inject constructor(
appInfoDataSource: AppInfoDataSource,
crashCollectorDataSource: CrashCollectorDataSource,
logsSettingsRepository: LogsSettingsRepository,
) : BaseCrashDataSource(appInfoDataSource, crashCollectorDataSource, logsSettingsRepository) {
) : BaseCrashDataSource(appInfoDataSource, crashCollectorDataSource) {

override val crashType = CrashType.JNI

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ import com.f0x1d.logfox.feature.crashes.impl.data.AppInfoDataSource
import com.f0x1d.logfox.feature.crashes.impl.data.CrashCollectorDataSource
import com.f0x1d.logfox.feature.crashes.impl.data.reader.base.BaseCrashDataSource
import com.f0x1d.logfox.feature.logging.api.model.LogLine
import com.f0x1d.logfox.feature.preferences.api.data.LogsSettingsRepository
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
internal class JavaCrashDataSource @Inject constructor(
appInfoDataSource: AppInfoDataSource,
crashCollectorDataSource: CrashCollectorDataSource,
logsSettingsRepository: LogsSettingsRepository,
) : BaseCrashDataSource(appInfoDataSource, crashCollectorDataSource, logsSettingsRepository) {
) : BaseCrashDataSource(appInfoDataSource, crashCollectorDataSource) {

override val crashType = CrashType.JAVA

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ import com.f0x1d.logfox.feature.crashes.impl.data.AppInfoDataSource
import com.f0x1d.logfox.feature.crashes.impl.data.CrashCollectorDataSource
import com.f0x1d.logfox.feature.crashes.impl.data.CrashDataSource
import com.f0x1d.logfox.feature.logging.api.model.LogLine
import com.f0x1d.logfox.feature.preferences.api.data.LogsSettingsRepository

internal abstract class BaseCrashDataSource(
private val appInfoDataSource: AppInfoDataSource,
private val crashCollectorDataSource: CrashCollectorDataSource,
private val logsSettingsRepository: LogsSettingsRepository,
) : CrashDataSource {

protected abstract val crashType: CrashType
Expand All @@ -30,8 +28,7 @@ internal abstract class BaseCrashDataSource(

open fun shouldContinueCollecting(line: LogLine): Boolean {
// Continue if within time window (crashes can have interleaved output)
val timeWindowMs = logsSettingsRepository.logsUpdateInterval().value + timeBufferMs
if (collectionStartTime + timeWindowMs > System.currentTimeMillis()) return true
if (collectionStartTime + timeBufferMs > System.currentTimeMillis()) return true

// Fall back to PID checking
val first = firstLine ?: return false
Expand Down