Bump ausbc to 3.3.3 and remove ContextWrapper hack

This commit is contained in:
Jannik committed 2026-08-20 22:04:18 +02:00
1 parent a509dc4e59
commit aec447a2ff
7 files changed
+11 -50

No files matched your search

+1 -1
View File
@@ -27,7 +27,7 @@ repositories {
dependencies {
implementation 'com.facebook.react:react-android'
// AndroidUSBCamera library for USB/UVC Webcams
implementation('com.github.jiangdongguo.AndroidUSBCamera:libausbc:3.2.7') {
implementation('com.github.jiangdongguo.AndroidUSBCamera:libausbc:3.3.3') {
exclude group: 'com.gyf.immersionbar', module: 'immersionbar'
exclude group: 'com.zlc.glide', module: 'webpdecoder'
}
@@ -92,50 +92,8 @@ class UsbCameraView(context: Context, appContext: AppContext) : ExpoView(context
activityContext.registerReceiver(permissionReceiver, filter)
}
// Create a ContextWrapper that automatically injects RECEIVER_EXPORTED
// This is required to fix the crash on Android 14+ when the 3rd party ausbc library
// calls registerReceiver without the required flag.
val wrappedContext = object : android.content.ContextWrapper(activityContext), androidx.lifecycle.LifecycleOwner {
override val lifecycle: androidx.lifecycle.Lifecycle
get() {
if (activityContext is androidx.lifecycle.LifecycleOwner) {
return (activityContext as androidx.lifecycle.LifecycleOwner).lifecycle
}
// Fallback to avoid crash, though CameraX needs a real lifecycle
throw IllegalStateException("activityContext is not a LifecycleOwner!")
}
override fun getApplicationContext(): android.content.Context {
return this
}
override fun registerReceiver(
receiver: android.content.BroadcastReceiver?,
filter: android.content.IntentFilter?
): android.content.Intent? {
return if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) {
super.registerReceiver(receiver, filter, Context.RECEIVER_EXPORTED)
} else {
super.registerReceiver(receiver, filter)
}
}
override fun registerReceiver(
receiver: android.content.BroadcastReceiver?,
filter: android.content.IntentFilter?,
broadcastPermission: String?,
scheduler: android.os.Handler?
): android.content.Intent? {
return if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) {
super.registerReceiver(receiver, filter, broadcastPermission, scheduler, Context.RECEIVER_EXPORTED)
} else {
super.registerReceiver(receiver, filter, broadcastPermission, scheduler)
}
}
}
cameraClient = CameraClient.newBuilder(wrappedContext)
.setCameraStrategy(CameraUvcStrategy(wrappedContext))
cameraClient = CameraClient.newBuilder(activityContext)
.setCameraStrategy(CameraUvcStrategy(activityContext))
.setCameraRequest(cameraRequest)
.setEnableGLES(false)
.build()