shiyinghan / UVCAndroid

Apache License 2.0
184 stars 50 forks source link

Target SDK 34 (Android 14) #62

Closed akhahaha closed 1 month ago

akhahaha commented 3 months ago

In addition to updating the target SDK versions, also updates USBMonitor to always use the FLAG_IMMUTABLE when attempting to request device permissions.

This fixes an issue when using the library with apps targeting 34, where CameraHelper would be unable to open devices due to USBMonitor attempting to build the device permissions intent using FLAG_MUTABLE. This is no longer allowed, and will throw a RemoteException with the message:

Targeting U+ (version 34 and above) disallows creating or retrieving a PendingIntent with FLAG_MUTABLE, an implicit Intent within and without FLAG_NO_CREATE and FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT for security reasons. To retrieve an already existing PendingIntent, use FLAG_NO_CREATE, however, to create a new PendingIntent with an implicit Intent use FLAG_IMMUTABLE.

Camera device attach/detach events were not being received due to a SecurityException:

One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts

shiyinghan commented 1 month ago

I have merged this PR and released the new version 1.0.7