ReviewOS

also looking at this

craft-native/craft

feat(android): setKeepAwake through the trampoline — ratchet 70 → 69

#174
Merged glennmichael123 wants to merge feat/android-keep-awake into main
7 files +140 -13
9 days ago

The first thing the main-thread hop paid for. Window.addFlags touches the view hierarchy, so this could not be served before #173 at all.

Safe to take where the flashlight pair is not

The shim's block ends isKeepingAwake = enabled, and that field is written there and read nowhere else in CraftBridge.kt.

So unlike setFlashlight / toggleFlashlight — where the second reads what the first wrote, and serving one from Zig would leave the other inverting a stale value, turning the torch on when it is already on — there is no state to keep in step here.

The two look identical from the outside and only one is safe to take, which is why the reason is written at the seam rather than left implied by the fact that it works.

The flag is read, and the direction is tested

FLAG_KEEP_SCREEN_ON goes through JNI rather than being written down. A wrong flag does not throw — the window would quietly get FLAG_DIM_BEHIND or FLAG_BLUR_BEHIND instead, and the screen would keep timing out while every layer reported success. Same asymmetry that made addContact read its MIME types.

windowFlagMethod is split out for the same reason: addFlags and clearFlags are one boolean apart, and swapping them fails a test rather than a device. That mutation was run.

Also

bridge_android_orientation.zig is now bridge_android_screen.zig. A file named for orientation that also keeps the screen awake is the same misnaming bridge_android_notifcancel carried until #172.

Testing

zig build test:android passes with the ratchet at 69. Both libcraft.so targets still build with no NDK.

7 changed files on the files tab, with 0 review threads.

Sign in to comment on this pull request.