diff --git a/uniffi_bindgen/src/bindings/kotlin/templates/ObjectCleanerHelperAndroid.kt b/uniffi_bindgen/src/bindings/kotlin/templates/ObjectCleanerHelperAndroid.kt index 2513a6a29e..d025879848 100644 --- a/uniffi_bindgen/src/bindings/kotlin/templates/ObjectCleanerHelperAndroid.kt +++ b/uniffi_bindgen/src/bindings/kotlin/templates/ObjectCleanerHelperAndroid.kt @@ -2,14 +2,15 @@ {{- self.add_import("androidx.annotation.RequiresApi") }} private fun UniffiCleaner.Companion.create(): UniffiCleaner = - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { AndroidSystemCleaner() } else { UniffiJnaCleaner() } // The SystemCleaner, available from API Level 33. -@RequiresApi(Build.VERSION_CODES.TIRAMISU) +// Some API Level 33 OSes do not support using it, so we require API Level 34. +@RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) private class AndroidSystemCleaner : UniffiCleaner { val cleaner = android.system.SystemCleaner.cleaner() @@ -17,7 +18,7 @@ private class AndroidSystemCleaner : UniffiCleaner { AndroidSystemCleanable(cleaner.register(value, cleanUpTask)) } -@RequiresApi(Build.VERSION_CODES.TIRAMISU) +@RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) private class AndroidSystemCleanable( private val cleanable: java.lang.ref.Cleaner.Cleanable, ) : UniffiCleaner.Cleanable {