Skip to content

Commit f565dae

Browse files
authored
Merge f269e08 into 98f55ae
2 parents 98f55ae + f269e08 commit f565dae

File tree

3 files changed

+48
-3
lines changed

3 files changed

+48
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- Session Replay: Do not capture current replay for cached events from the past ([#4474](https://github.com/getsentry/sentry-java/pull/4474))
1111
- Session Replay: Correctly capture Dialogs and non full-sized windows ([#4354](https://github.com/getsentry/sentry-java/pull/4354))
1212
- Session Replay: Fix inconsistent `segment_id` ([#4471](https://github.com/getsentry/sentry-java/pull/4471))
13+
- Session Replay: Fix crash on devices with the Unisoc/Spreadtrum T606 chipset ([#4477](https://github.com/getsentry/sentry-java/pull/4477))
1314

1415
## 8.13.2
1516

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package io.sentry.android.replay.util
2+
3+
import android.annotation.SuppressLint
4+
import android.os.Build
5+
import java.lang.reflect.Method
6+
7+
internal object SystemProperties {
8+
// 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
9+
// these props are not available on API < 31 via Build, so we use reflection to access them
10+
const val SOC_MODEL = "ro.soc.model"
11+
const val SOC_MANUFACTURER = "ro.soc.manufacturer"
12+
13+
@delegate:SuppressLint("PrivateApi")
14+
private val getProperty: Method by lazy {
15+
val clazz = Class.forName("android.os.SystemProperties")
16+
clazz.getMethod("get", String::class.java)
17+
}
18+
19+
fun get(key: String, defaultValue: String = ""): String {
20+
return if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
21+
try {
22+
getProperty.invoke(null, key) as? String ?: defaultValue
23+
} catch (e: Throwable) {
24+
defaultValue
25+
}
26+
} else {
27+
when (key) {
28+
SOC_MODEL -> Build.SOC_MODEL
29+
SOC_MANUFACTURER -> Build.SOC_MANUFACTURER
30+
else -> throw IllegalArgumentException("Unknown system property: $key")
31+
}
32+
}
33+
}
34+
}

sentry-android-replay/src/main/java/io/sentry/android/replay/video/SimpleVideoEncoder.kt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import android.os.Build
3939
import android.view.Surface
4040
import io.sentry.SentryLevel.DEBUG
4141
import io.sentry.SentryOptions
42+
import io.sentry.android.replay.util.SystemProperties
4243
import java.io.File
4344
import java.nio.ByteBuffer
4445
import kotlin.LazyThreadSafetyMode.NONE
@@ -155,11 +156,20 @@ internal class SimpleVideoEncoder(
155156
}
156157

157158
fun encode(image: Bitmap) {
158-
// it seems that Xiaomi devices have problems with hardware canvas, so we have to use
159-
// lockCanvas instead https://stackoverflow.com/a/73520742
159+
/** it seems that Xiaomi devices have problems with hardware canvas, so we have to use
160+
* lockCanvas instead https://stackoverflow.com/a/73520742
161+
* ---
162+
* Same for Motorola devices.
163+
* ---
164+
* As for the T606, it's a Spreadtrum/Unisoc chipset and can be spread across various
165+
* devices, so we have to check the SOC_MODEL property, as the manufacturer name might have
166+
* changed.
167+
* https://github.com/getsentry/sentry-android-gradle-plugin/issues/861#issuecomment-2867021256
168+
*/
160169
val canvas = if (
161170
Build.MANUFACTURER.contains("xiaomi", ignoreCase = true) ||
162-
Build.MANUFACTURER.contains("motorola", ignoreCase = true)
171+
Build.MANUFACTURER.contains("motorola", ignoreCase = true) ||
172+
SystemProperties.get(SystemProperties.SOC_MODEL).equals("T606", ignoreCase = true)
163173
) {
164174
surface?.lockCanvas(null)
165175
} else {

0 commit comments

Comments
 (0)