Skip to content

Commit

Permalink
Merge pull request #1965 from bugsnag/PLAT-11483/native-event-decoder…
Browse files Browse the repository at this point in the history
…-skeleton

Add the skeleton NativeEventDecoder
  • Loading branch information
lemnik authored Jan 31, 2024
2 parents baf6804 + 1f1924e commit 69b7016
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.bugsnag.android.ndk

import java.nio.ByteBuffer

internal fun ByteBuffer.getNativeInt(): Int = getInt()
internal fun ByteBuffer.getNativeLong(): Long = getLong()

internal fun ByteBuffer.getCString(byteCount: Int): String {
position(position() + byteCount)
return ""
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.bugsnag.android.ndk

import androidx.annotation.VisibleForTesting
import com.bugsnag.android.Event
import java.io.File
import java.nio.ByteBuffer
import java.nio.ByteOrder
import java.nio.channels.FileChannel

internal object NativeEventDecoder {
fun decode(
event: File,
@Suppress("UNUSED_PARAMETER")
staticData: File = File(event.parentFile, event.name + ".static_data.json")
): Event {
return event.inputStream().channel.use {
// mmap the entire file in READ_ONLY mode
val eventBytes = it.map(FileChannel.MapMode.READ_ONLY, 0L, event.length())
decodeEventFromBytes(eventBytes)
}
}

@VisibleForTesting
internal fun decodeEventFromBytes(
eventBytes: ByteBuffer
): Event {
eventBytes.order(ByteOrder.nativeOrder())
@Suppress("StopShip") // This is targeting an integration branch
TODO("To be completed")
}
}
Binary file not shown.

0 comments on commit 69b7016

Please sign in to comment.