Modern Apps git

← Modern-Apps.git

camera: start wear companion sync after the first frame

Commit
0243343f5eb928a81aab9eff9fae2258c2743bb6
Author
Vayun Mathur <[email protected]>
When
2026-12-05 18:26 UTC (17 hours ago)
Parents
0482b87
WearCameraSync.start and setPhoneOpen(true) ran synchronously in
onCreateBeforeContent, before the viewfinder's first frame. The
watch link is not first-frame content, so both now run via
MaActivity.deferAfterFirstFrame; the capture-for-result intent
handling stays synchronous, and onDestroy still clears the
phone-open flag.

Verified: :camera:lint :camera:lintVitalRelease
:camera:testDevUnitTest pass.

Diff

camera/src/main/java/com/vayunmathur/camera/MainActivity.kt
diff --git a/camera/src/main/java/com/vayunmathur/camera/MainActivity.kt b/camera/src/main/java/com/vayunmathur/camera/MainActivity.ktindex 76e2f56dca..f9989724ab 100644--- a/camera/src/main/java/com/vayunmathur/camera/MainActivity.kt+++ b/camera/src/main/java/com/vayunmathur/camera/MainActivity.kt@@ -84,10 +84,13 @@ class MainActivity : MaActivity() {         // the Watch app owns the conduit link and its permission.         val wearSync = com.vayunmathur.camera.platform.WearCameraSync.get(this)         wearSync.viewModel = viewModel-        wearSync.start()-        // The watch leaves its "Open in phone" button only while this is-        // set; onDestroy clears it, returning the watch to that button.-        wearSync.setPhoneOpen(true)+        // The viewfinder is the first frame; the watch companion link is+        // not. Start it (and the phone-open flag the watch reads) once+        // the first frame is drawn; onDestroy still clears the flag.+        deferAfterFirstFrame {+            wearSync.start()+            wearSync.setPhoneOpen(true)+        }     }      override fun onDestroy() {