Skip to content

Commit 5d411b0

Browse files
authored
Fix warnings in SentryFlutter.kt and SentryFlutterPlugin.kt (#3274)
1 parent 8541716 commit 5d411b0

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

packages/flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class SentryFlutter {
7272
}
7373
data.getIfNotNull<String>("diagnosticLevel") {
7474
if (options.isDebug) {
75-
val sentryLevel = SentryLevel.valueOf(it.toUpperCase(Locale.ROOT))
75+
val sentryLevel = SentryLevel.valueOf(it.uppercase())
7676
options.setDiagnosticLevel(sentryLevel)
7777
}
7878
}
@@ -165,7 +165,7 @@ class SentryFlutter {
165165
?.let {
166166
type =
167167
try {
168-
Type.valueOf(it.toUpperCase(Locale.ROOT))
168+
Type.valueOf(it.uppercase())
169169
} catch (_: IllegalArgumentException) {
170170
Log.w("Sentry", "Could not parse `type` from proxy json: $proxyJson")
171171
null

packages/flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutterPlugin.kt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,16 @@ import io.flutter.plugin.common.MethodChannel.MethodCallHandler
1515
import io.flutter.plugin.common.MethodChannel.Result
1616
import io.sentry.Breadcrumb
1717
import io.sentry.DateUtils
18-
import io.sentry.HubAdapter
18+
import io.sentry.ScopesAdapter
1919
import io.sentry.Sentry
2020
import io.sentry.android.core.InternalSentrySdk
21-
import io.sentry.android.core.LoadClass
2221
import io.sentry.android.core.SentryAndroid
2322
import io.sentry.android.core.SentryAndroidOptions
2423
import io.sentry.android.core.performance.AppStartMetrics
2524
import io.sentry.android.core.performance.TimeSpan
2625
import io.sentry.android.replay.ReplayIntegration
2726
import io.sentry.android.replay.ScreenshotRecorderConfig
2827
import io.sentry.protocol.DebugImage
29-
import io.sentry.protocol.SentryId
3028
import io.sentry.protocol.User
3129
import io.sentry.transport.CurrentDateProvider
3230
import org.json.JSONObject
@@ -289,7 +287,7 @@ class SentryFlutterPlugin :
289287
result: Result,
290288
) {
291289
if (user != null) {
292-
val options = HubAdapter.getInstance().options
290+
val options = ScopesAdapter.getInstance().options
293291
val userInstance = User.fromMap(user, options)
294292
Sentry.setUser(userInstance)
295293
} else {
@@ -303,7 +301,7 @@ class SentryFlutterPlugin :
303301
result: Result,
304302
) {
305303
if (breadcrumb != null) {
306-
val options = HubAdapter.getInstance().options
304+
val options = ScopesAdapter.getInstance().options
307305
val breadcrumbInstance = Breadcrumb.fromMap(breadcrumb, options)
308306
Sentry.addBreadcrumb(breadcrumbInstance)
309307
}
@@ -371,7 +369,7 @@ class SentryFlutterPlugin :
371369
}
372370

373371
private fun closeNativeSdk(result: Result) {
374-
HubAdapter.getInstance().close()
372+
ScopesAdapter.getInstance().close()
375373

376374
result.success("")
377375
}
@@ -385,15 +383,17 @@ class SentryFlutterPlugin :
385383

386384
private const val NATIVE_CRASH_WAIT_TIME = 500L
387385

386+
@Suppress("unused") // Used by native/jni bindings
388387
@JvmStatic
389388
fun privateSentryGetReplayIntegration(): ReplayIntegration? = replay
390389

391390
@JvmStatic
392391
fun getApplicationContext(): Context? = applicationContext
393392

393+
@Suppress("unused") // Used by native/jni bindings
394394
@JvmStatic
395395
fun loadContextsAsBytes(): ByteArray? {
396-
val options = HubAdapter.getInstance().options
396+
val options = ScopesAdapter.getInstance().options
397397
val context = getApplicationContext()
398398
if (options !is SentryAndroidOptions || context == null) {
399399
return null
@@ -409,9 +409,10 @@ class SentryFlutterPlugin :
409409
return json.toByteArray(Charsets.UTF_8)
410410
}
411411

412+
@Suppress("unused") // Used by native/jni bindings
412413
@JvmStatic
413414
fun loadDebugImagesAsBytes(addresses: Set<String>): ByteArray? {
414-
val options = HubAdapter.getInstance().options as SentryAndroidOptions
415+
val options = ScopesAdapter.getInstance().options as SentryAndroidOptions
415416

416417
val debugImages =
417418
if (addresses.isEmpty()) {
@@ -447,7 +448,7 @@ class SentryFlutterPlugin :
447448
private fun crash() {
448449
val exception = RuntimeException("FlutterSentry Native Integration: Sample RuntimeException")
449450
val mainThread = Looper.getMainLooper().thread
450-
mainThread.uncaughtExceptionHandler.uncaughtException(mainThread, exception)
451+
mainThread.uncaughtExceptionHandler?.uncaughtException(mainThread, exception)
451452
mainThread.join(NATIVE_CRASH_WAIT_TIME)
452453
}
453454

packages/flutter/example/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ android {
3434
}
3535
kotlinOptions {
3636
jvmTarget = JavaVersion.VERSION_1_8
37-
languageVersion = "1.4"
37+
languageVersion = "1.8"
3838
}
3939

4040
compileSdkVersion 35

0 commit comments

Comments
 (0)