Skip to content

Commit 6ddaea9

Browse files
authored
Merge branch 'main' into fix/add_tombstone_mechanism
2 parents 0082e7d + af6aa3f commit 6ddaea9

File tree

8 files changed

+63
-25
lines changed

8 files changed

+63
-25
lines changed

.github/workflows/changelog-preview.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
permissions:
1212
contents: write
1313
pull-requests: write
14+
statuses: write
1415

1516
jobs:
1617
changelog-preview:

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22

33
## Unreleased
44

5+
### Features
6+
7+
- Update Android targetSdk to API 36 (Android 16) ([#5016](https://github.com/getsentry/sentry-java/pull/5016))
8+
59
### Internal
610

711
- Establish new native exception mechanisms to differentiate events generated by `sentry-native` from `ApplicationExitInfo`. ([#5052](https://github.com/getsentry/sentry-java/pull/5052))
12+
- Set `write` permission for `statuses` in the changelog preview GHA workflow. ([#5053](https://github.com/getsentry/sentry-java/pull/5053))
813

914
## 8.31.0
1015

gradle/libs.versions.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ springboot2 = "2.7.18"
3434
springboot3 = "3.5.0"
3535
springboot4 = "4.0.0"
3636
# Android
37-
targetSdk = "34"
38-
compileSdk = "34"
37+
targetSdk = "36"
38+
compileSdk = "36"
3939
minSdk = "21"
4040
spotless = "7.0.4"
4141
gummyBears = "0.12.0"
@@ -204,15 +204,15 @@ tomcat-catalina-jakarta = { module = "org.apache.tomcat:tomcat-catalina", versio
204204
tomcat-embed-jasper-jakarta = { module = "org.apache.tomcat.embed:tomcat-embed-jasper", version = "11.0.10" }
205205

206206
# test libraries
207-
androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version = "1.6.8" }
207+
androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version = "1.9.5" }
208208
androidx-test-core = { module = "androidx.test:core", version.ref = "androidxTestCore" }
209209
androidx-test-core-ktx = { module = "androidx.test:core-ktx", version.ref = "androidxTestCore" }
210210
androidx-test-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso" }
211211
androidx-test-espresso-idling-resource = { module = "androidx.test.espresso:espresso-idling-resource", version.ref = "espresso" }
212-
androidx-test-ext-junit = { module = "androidx.test.ext:junit", version = "1.1.5" }
213-
androidx-test-orchestrator = { module = "androidx.test:orchestrator", version = "1.5.0" }
212+
androidx-test-ext-junit = { module = "androidx.test.ext:junit", version = "1.3.0" }
213+
androidx-test-orchestrator = { module = "androidx.test:orchestrator", version = "1.6.1" }
214214
androidx-test-rules = { module = "androidx.test:rules", version.ref = "androidxTestCore" }
215-
androidx-test-runner = { module = "androidx.test:runner", version = "1.6.2" }
215+
androidx-test-runner = { module = "androidx.test:runner", version = "1.7.0" }
216216
awaitility-kotlin = { module = "org.awaitility:awaitility-kotlin", version = "4.1.1" }
217217
awaitility-kotlin-spring7 = { module = "org.awaitility:awaitility-kotlin", version = "4.3.0" }
218218
awaitility3-kotlin = { module = "org.awaitility:awaitility-kotlin", version = "3.1.6" }

sentry-android-core/src/main/java/io/sentry/android/core/AppComponentsBreadcrumbsIntegration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public void onConfigurationChanged(@NotNull Configuration newConfig) {
9898
executeInBackground(() -> captureConfigurationChangedBreadcrumb(now, newConfig));
9999
}
100100

101+
@SuppressWarnings("deprecation")
101102
@Override
102103
public void onLowMemory() {
103104
// we do this in onTrimMemory below already, this is legacy API (14 or below)

sentry-android-core/src/main/java/io/sentry/android/core/internal/util/AndroidThreadChecker.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.sentry.android.core.internal.util;
22

3+
import android.os.Build;
34
import android.os.Handler;
45
import android.os.Looper;
56
import android.os.Process;
@@ -24,14 +25,32 @@ private AndroidThreadChecker() {
2425
new Handler(Looper.getMainLooper()).post(() -> mainThreadSystemId = Process.myTid());
2526
}
2627

28+
/**
29+
* Gets the thread ID in a way that's compatible across Android versions.
30+
*
31+
* <p>Uses {@link Thread#threadId()} on Android 16 (API 36) and above, and falls back to {@link
32+
* Thread#getId()} on older versions.
33+
*
34+
* @param thread the thread to get the ID for
35+
* @return the thread ID
36+
*/
37+
@SuppressWarnings("deprecation")
38+
public static long getThreadId(final @NotNull Thread thread) {
39+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.BAKLAVA) {
40+
return thread.threadId();
41+
} else {
42+
return thread.getId();
43+
}
44+
}
45+
2746
@Override
2847
public boolean isMainThread(final long threadId) {
29-
return Looper.getMainLooper().getThread().getId() == threadId;
48+
return getThreadId(Looper.getMainLooper().getThread()) == threadId;
3049
}
3150

3251
@Override
3352
public boolean isMainThread(final @NotNull Thread thread) {
34-
return isMainThread(thread.getId());
53+
return isMainThread(getThreadId(thread));
3554
}
3655

3756
@Override

sentry-android-core/src/main/java/io/sentry/android/core/performance/ActivityLifecycleSpanHelper.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import io.sentry.SpanDataConvention;
99
import io.sentry.SpanStatus;
1010
import io.sentry.android.core.AndroidDateUtils;
11+
import io.sentry.android.core.internal.util.AndroidThreadChecker;
1112
import java.util.concurrent.TimeUnit;
1213
import org.jetbrains.annotations.ApiStatus;
1314
import org.jetbrains.annotations.NotNull;
@@ -129,7 +130,9 @@ public void clear() {
129130
}
130131

131132
private void setDefaultStartSpanData(final @NotNull ISpan span) {
132-
span.setData(SpanDataConvention.THREAD_ID, Looper.getMainLooper().getThread().getId());
133+
span.setData(
134+
SpanDataConvention.THREAD_ID,
135+
AndroidThreadChecker.getThreadId(Looper.getMainLooper().getThread()));
133136
span.setData(SpanDataConvention.THREAD_NAME, "main");
134137
span.setData(SpanDataConvention.CONTRIBUTES_TTID, true);
135138
span.setData(SpanDataConvention.CONTRIBUTES_TTFD, true);

sentry-android-integration-tests/sentry-uitest-android/src/androidTest/java/io/sentry/uitest/android/UserFeedbackUiTest.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package io.sentry.uitest.android
22

33
import android.graphics.Color
4-
import android.util.TypedValue
54
import android.view.View
65
import android.widget.EditText
6+
import android.widget.FrameLayout
77
import android.widget.LinearLayout
88
import androidx.test.core.app.launchActivity
99
import androidx.test.espresso.Espresso.onView
@@ -550,10 +550,6 @@ class UserFeedbackUiTest : BaseUiTest() {
550550
assertEquals((densityScale * 12).toInt(), widget.paddingTop)
551551
assertEquals((densityScale * 12).toInt(), widget.paddingBottom)
552552

553-
val typedValue = TypedValue()
554-
widget.context.theme.resolveAttribute(android.R.attr.colorForeground, typedValue, true)
555-
assertEquals(typedValue.data, widget.currentTextColor)
556-
557553
assertEquals("Report a Bug", widget.text)
558554
}
559555

@@ -666,14 +662,19 @@ class UserFeedbackUiTest : BaseUiTest() {
666662
val buttonId = Int.MAX_VALUE - 1
667663
val feedbackScenario = launchActivity<EmptyActivity>()
668664
feedbackScenario.onActivity {
665+
val layoutParams =
666+
FrameLayout.LayoutParams(
667+
LinearLayout.LayoutParams.MATCH_PARENT,
668+
LinearLayout.LayoutParams.MATCH_PARENT,
669+
)
669670
val view =
670-
LinearLayout(it).apply {
671-
orientation = LinearLayout.VERTICAL
671+
FrameLayout(it).apply {
672672
addView(
673673
SentryUserFeedbackButton(it).apply {
674674
id = buttonId
675675
widgetConfig?.invoke(this)
676-
}
676+
},
677+
layoutParams,
677678
)
678679
}
679680
it.setContentView(view)

sentry-samples/sentry-samples-android/src/main/java/io/sentry/samples/android/ProfilingActivity.kt

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.os.Bundle
44
import android.view.View
55
import android.widget.SeekBar
66
import android.widget.Toast
7+
import androidx.activity.OnBackPressedCallback
78
import androidx.appcompat.app.AppCompatActivity
89
import androidx.recyclerview.widget.LinearLayoutManager
910
import io.sentry.ITransaction
@@ -24,6 +25,21 @@ class ProfilingActivity : AppCompatActivity() {
2425

2526
override fun onCreate(savedInstanceState: Bundle?) {
2627
super.onCreate(savedInstanceState)
28+
29+
onBackPressedDispatcher.addCallback(
30+
this,
31+
object : OnBackPressedCallback(true) {
32+
override fun handleOnBackPressed() {
33+
if (profileFinished) {
34+
isEnabled = false
35+
onBackPressedDispatcher.onBackPressed()
36+
} else {
37+
Toast.makeText(this@ProfilingActivity, R.string.profiling_running, Toast.LENGTH_SHORT)
38+
.show()
39+
}
40+
}
41+
},
42+
)
2743
binding = ActivityProfilingBinding.inflate(layoutInflater)
2844

2945
binding.profilingDurationSeekbar.setOnSeekBarChangeListener(
@@ -156,14 +172,6 @@ class ProfilingActivity : AppCompatActivity() {
156172
else -> fibonacci(n - 1) + fibonacci(n - 2)
157173
}
158174

159-
override fun onBackPressed() {
160-
if (profileFinished) {
161-
super.onBackPressed()
162-
} else {
163-
Toast.makeText(this, R.string.profiling_running, Toast.LENGTH_SHORT).show()
164-
}
165-
}
166-
167175
private fun getProfileDuration(): Float {
168176
// Minimum duration of the profile is 100 milliseconds
169177
return binding.profilingDurationSeekbar.progress / 10.0F + 0.1F

0 commit comments

Comments
 (0)