Skip to content
Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Session Replay: Do not capture current replay for cached events from the past ([#4474](https://github.com/getsentry/sentry-java/pull/4474))
- Session Replay: Correctly capture Dialogs and non full-sized windows ([#4354](https://github.com/getsentry/sentry-java/pull/4354))
- Session Replay: Fix inconsistent `segment_id` ([#4471](https://github.com/getsentry/sentry-java/pull/4471))
- Session Replay: Fix crash on devices with the Unisoc/Spreadtrum T606 chipset ([#4477](https://github.com/getsentry/sentry-java/pull/4477))

## 8.13.2

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.sentry.android.replay.util

import android.annotation.SuppressLint
import android.os.Build
import java.lang.reflect.Method

internal object SystemProperties {
// from https://cs.android.com/android/platform/superproject/main/+/main:out/soong/.intermediates/system/libsysprop/srcs/PlatformProperties/android_common/xref/srcjars.xref/android/sysprop/SocProperties.java;l=163-171
// these props are not available on API < 31 via Build, so we use reflection to access them
const val SOC_MODEL = "ro.soc.model"
const val SOC_MANUFACTURER = "ro.soc.manufacturer"

@delegate:SuppressLint("PrivateApi")
private val getProperty: Method by lazy {
val clazz = Class.forName("android.os.SystemProperties")
clazz.getMethod("get", String::class.java)
}

fun get(key: String, defaultValue: String = ""): String {
return if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
try {
getProperty.invoke(null, key) as? String ?: defaultValue
Comment thread
markushi marked this conversation as resolved.
Outdated
} catch (e: Throwable) {
defaultValue
}
} else {
when (key) {
SOC_MODEL -> Build.SOC_MODEL
SOC_MANUFACTURER -> Build.SOC_MANUFACTURER
else -> throw IllegalArgumentException("Unknown system property: $key")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import android.os.Build
import android.view.Surface
import io.sentry.SentryLevel.DEBUG
import io.sentry.SentryOptions
import io.sentry.android.replay.util.SystemProperties
import java.io.File
import java.nio.ByteBuffer
import kotlin.LazyThreadSafetyMode.NONE
Expand Down Expand Up @@ -155,11 +156,20 @@ internal class SimpleVideoEncoder(
}

fun encode(image: Bitmap) {
// it seems that Xiaomi devices have problems with hardware canvas, so we have to use
// lockCanvas instead https://stackoverflow.com/a/73520742
/** it seems that Xiaomi devices have problems with hardware canvas, so we have to use
* lockCanvas instead https://stackoverflow.com/a/73520742
* ---
* Same for Motorola devices.
* ---
* As for the T606, it's a Spreadtrum/Unisoc chipset and can be spread across various
* devices, so we have to check the SOC_MODEL property, as the manufacturer name might have
* changed.
* https://github.com/getsentry/sentry-android-gradle-plugin/issues/861#issuecomment-2867021256
*/
val canvas = if (
Build.MANUFACTURER.contains("xiaomi", ignoreCase = true) ||
Build.MANUFACTURER.contains("motorola", ignoreCase = true)
Build.MANUFACTURER.contains("motorola", ignoreCase = true) ||
SystemProperties.get(SystemProperties.SOC_MODEL).equals("T606", ignoreCase = true)
) {
surface?.lockCanvas(null)
} else {
Expand Down
Loading