ReviewOS

also looking at this

craft-native/craft

feat(android): a main-thread trampoline, and the orientation pair to prove it — ratchet 72 → 70

#173
Merged glennmichael123 wants to merge feat/android-main-thread into main
7 files +568 -3
packages/android/templates/CraftBridge.kt.templatemodified+6-0
Changes to packages/android/templates/CraftBridge.kt.template
@@ -2592,6 +2592,10 @@ class CraftBridge(
25922592
25932593 @JavascriptInterface
25942594 fun lockOrientation(orientation: String): Boolean {
2595 // Zig queues the same work on the same looper, through a Runnable
2596 // this file's holder owns — see CraftNative.runOnMain.
2597 if (CraftNative.lockOrientation(activity, orientation)) return true
2598
25952599 activity.runOnUiThread {
25962600 activity.requestedOrientation = when (orientation) {
25972601 "portrait" -> ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
@@ -2606,6 +2610,8 @@ class CraftBridge(
26062610
26072611 @JavascriptInterface
26082612 fun unlockOrientation(): Boolean {
2613 if (CraftNative.unlockOrientation(activity)) return true
2614
26092615 activity.runOnUiThread {
26102616 activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
26112617 }