Skip to content

Fix EventChannel calls from background thread on Android#22

Open
maik-kluwe wants to merge 1 commit into
mway-io:masterfrom
maik-kluwe:master
Open

Fix EventChannel calls from background thread on Android#22
maik-kluwe wants to merge 1 commit into
mway-io:masterfrom
maik-kluwe:master

Conversation

@maik-kluwe
Copy link
Copy Markdown

@maik-kluwe maik-kluwe commented Mar 27, 2026

Fixes #23

This fixes a crash on Android when managed app configurations are changed while listening to mangedConfigurationsStream.

Cause:
eventSink.success() / eventSink.error() were triggered from the executor background thread in getApplicationRestrictionsAsync(...).

Effect:
Flutter crashes with FlutterJNI.ensureRunningOnMainThread when TestDPC or another EMM updates managed configurations.

Fix:
Post EventChannel callbacks back to the main thread using Handler(Looper.getMainLooper()).

I verified this on a real Android device provisioned with TestDPC as Device Owner by changing managed configurations multiple times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Crash on managed configuration update (EventChannel not on main thread)

1 participant