email: add open-on-phone receivers for email and securemail
- Commit
29d710573db9e21066c3becf432153763cfee640- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-06 15:51 UTC (1 hour ago)
- Parents
65ed43e
Both apps have a watch Open on phone button (email: /email/open-on-phone, securemail: /securemail/open-on-phone) and a phone sync handler for it, but neither declared the manifest OpenOnPhoneReceiver the other twelve open apps have, so a tap while the phone app was not running broadcast to no receiver and was dropped (and never queued, by design). Add the standard receiver (exported only under the CONDUIT signature permission, answering the shared OPEN_ON_PHONE action for the app's own appId, launching MainActivity through the shared OpenOnPhoneLauncher) plus the manifest entry to each app. Securemail's launched MainActivity still applies its key gate. The wearlink manifest-contract test now covers both apps. Verified: :email and :securemail lint, lintVitalRelease and testDevUnitTest pass.
Diff
email/AGENTS.md
diff --git a/email/AGENTS.md b/email/AGENTS.mdindex 6a46c03863..9398916618 100644--- a/email/AGENTS.md+++ b/email/AGENTS.md@@ -131,7 +131,7 @@ _Install: ./install email (dev by default)._ - com/vayunmathur/email/ui/WearRoute.kt, WearInboxListScreen.kt, WearMessageScreen.kt - com/vayunmathur/email/data/WearEmailStore.kt — watch snapshot + pending mark-read ops - com/vayunmathur/email/sync/WearEmailSync.kt — phone conduit publish + op apply-- com/vayunmathur/email/sync/WearLinkBridge.kt, WearWatchStatePublisher.kt, ConduitSyncTriggerReceiver.kt+- com/vayunmathur/email/sync/WearLinkBridge.kt, WearWatchStatePublisher.kt, ConduitSyncTriggerReceiver.kt, OpenOnPhoneReceiver.kt - com/vayunmathur/email/platform/FormFactor.kt — watch detection (FEATURE_WATCH) ### widget/ — unified-inbox home widget - com/vayunmathur/email/widget/EmailWidget.kt — includes `EmailWidgetReceiver` (one widget, one file)
email/src/main/AndroidManifest.xml
diff --git a/email/src/main/AndroidManifest.xml b/email/src/main/AndroidManifest.xmlindex b93ba3b302..2acfd96dd6 100644--- a/email/src/main/AndroidManifest.xml+++ b/email/src/main/AndroidManifest.xml@@ -153,6 +153,18 @@ <action android:name="com.vayunmathur.watch.action.SYNC_TRIGGER" /> </intent-filter> </receiver>+ <!-- Watch "Open on phone" wake: the phone Watch conduit host fires+ OpenOnPhoneContract.ACTION (signature permission, package-addressed)+ when a watch open request arrives with no live registration in+ this app; this receiver launches the main activity. -->+ <receiver+ android:name=".sync.OpenOnPhoneReceiver"+ android:exported="true"+ android:permission="com.vayunmathur.watch.permissions.CONDUIT">+ <intent-filter>+ <action android:name="com.vayunmathur.watch.action.OPEN_ON_PHONE" />+ </intent-filter>+ </receiver> <activity android:name=".ui.WearMainActivity"
email/src/main/java/com/vayunmathur/email/sync/OpenOnPhoneReceiver.kt
diff --git a/email/src/main/java/com/vayunmathur/email/sync/OpenOnPhoneReceiver.kt b/email/src/main/java/com/vayunmathur/email/sync/OpenOnPhoneReceiver.ktnew file mode 100644index 0000000000..ed8a01f61c--- /dev/null+++ b/email/src/main/java/com/vayunmathur/email/sync/OpenOnPhoneReceiver.kt@@ -0,0 +1,56 @@+package com.vayunmathur.email.sync++import android.content.BroadcastReceiver+import android.content.Context+import android.content.Intent+import com.vayunmathur.library.wearlink.conduit.OpenOnPhoneContract+import com.vayunmathur.library.wearlink.conduit.OpenOnPhoneLauncher++/**+ * Decides whether an incoming intent is this app's open-on-phone wake and,+ * if so, invokes [launch]. Pure (no Android types) so the decision is+ * unit-tested at the shared seam; the receiver below supplies the values.+ */+object OpenOnPhoneHandler {+ /** Conduit appId this app opens under (first segment of its conduit paths). */+ const val APP_ID: String = "email"++ /** True (and [launch] invoked) only for this app's open-on-phone wake. */+ fun handle(+ action: String?,+ appId: String?,+ launch: () -> Unit,+ ): Boolean {+ if (!OpenOnPhoneContract.shouldHandle(action, appId, APP_ID)) return false+ launch()+ return true+ }+}++/**+ * Manifest wake for the watch "Open on phone" button: the phone Watch+ * conduit host fires [OpenOnPhoneContract.ACTION] (signature permission+ * [OpenOnPhoneContract.PERMISSION], package-addressed to this app) when a+ * watch open request arrives while this app has no live conduit+ * registration. This receiver launches the main activity as a new task, so+ * the button works with no phone process running first. A request that+ * arrives while the app's sync is registered is handled by that sync's+ * message listener instead and never reaches this receiver.+ */+class OpenOnPhoneReceiver : BroadcastReceiver() {+ override fun onReceive(+ context: Context,+ intent: Intent,+ ) {+ OpenOnPhoneHandler.handle(+ intent.action,+ intent.getStringExtra(OpenOnPhoneContract.EXTRA_APP_ID),+ ) {+ OpenOnPhoneLauncher.launch(+ context.applicationContext,+ com.vayunmathur.email.MainActivity::class.java,+ intent.getStringExtra(OpenOnPhoneContract.EXTRA_ENTITY_ID).orEmpty(),+ )+ }+ }+}
securemail/AGENTS.md
diff --git a/securemail/AGENTS.md b/securemail/AGENTS.mdindex bd2b20483e..1aca5ea9fb 100644--- a/securemail/AGENTS.md+++ b/securemail/AGENTS.md@@ -60,7 +60,7 @@ _Install: ./install securemail (dev by default)._ - com/vayunmathur/securemail/ui/WearRoute.kt, WearInboxListScreen.kt, WearMessageScreen.kt - com/vayunmathur/securemail/data/WearSecureMailStore.kt — watch metadata snapshot + pending ops - com/vayunmathur/securemail/sync/WearSecureMailSync.kt — phone metadata publish + op apply-- com/vayunmathur/securemail/sync/WearLinkBridge.kt, WearWatchStatePublisher.kt, ConduitSyncTriggerReceiver.kt+- com/vayunmathur/securemail/sync/WearLinkBridge.kt, WearWatchStatePublisher.kt, ConduitSyncTriggerReceiver.kt, OpenOnPhoneReceiver.kt - com/vayunmathur/securemail/platform/FormFactor.kt — watch detection (FEATURE_WATCH) ### service/ — live socket lifetime - com/vayunmathur/securemail/service/MailSocketService.kt
securemail/src/main/AndroidManifest.xml
diff --git a/securemail/src/main/AndroidManifest.xml b/securemail/src/main/AndroidManifest.xmlindex 32d4dc9c94..0d8dc084a3 100644--- a/securemail/src/main/AndroidManifest.xml+++ b/securemail/src/main/AndroidManifest.xml@@ -84,6 +84,18 @@ <action android:name="com.vayunmathur.watch.action.SYNC_TRIGGER" /> </intent-filter> </receiver>+ <!-- Watch "Open on phone" wake: the phone Watch conduit host fires+ OpenOnPhoneContract.ACTION (signature permission, package-addressed)+ when a watch open request arrives with no live registration in+ this app; this receiver launches the main activity. -->+ <receiver+ android:name=".sync.OpenOnPhoneReceiver"+ android:exported="true"+ android:permission="com.vayunmathur.watch.permissions.CONDUIT">+ <intent-filter>+ <action android:name="com.vayunmathur.watch.action.OPEN_ON_PHONE" />+ </intent-filter>+ </receiver> <activity android:name=".ui.WearMainActivity"
securemail/src/main/java/com/vayunmathur/securemail/sync/OpenOnPhoneReceiver.kt
diff --git a/securemail/src/main/java/com/vayunmathur/securemail/sync/OpenOnPhoneReceiver.kt b/securemail/src/main/java/com/vayunmathur/securemail/sync/OpenOnPhoneReceiver.ktnew file mode 100644index 0000000000..c8c727ed95--- /dev/null+++ b/securemail/src/main/java/com/vayunmathur/securemail/sync/OpenOnPhoneReceiver.kt@@ -0,0 +1,57 @@+package com.vayunmathur.securemail.sync++import android.content.BroadcastReceiver+import android.content.Context+import android.content.Intent+import com.vayunmathur.library.wearlink.conduit.OpenOnPhoneContract+import com.vayunmathur.library.wearlink.conduit.OpenOnPhoneLauncher++/**+ * Decides whether an incoming intent is this app's open-on-phone wake and,+ * if so, invokes [launch]. Pure (no Android types) so the decision is+ * unit-tested at the shared seam; the receiver below supplies the values.+ */+object OpenOnPhoneHandler {+ /** Conduit appId this app opens under (first segment of its conduit paths). */+ const val APP_ID: String = "securemail"++ /** True (and [launch] invoked) only for this app's open-on-phone wake. */+ fun handle(+ action: String?,+ appId: String?,+ launch: () -> Unit,+ ): Boolean {+ if (!OpenOnPhoneContract.shouldHandle(action, appId, APP_ID)) return false+ launch()+ return true+ }+}++/**+ * Manifest wake for the watch "Open on phone" button: the phone Watch+ * conduit host fires [OpenOnPhoneContract.ACTION] (signature permission+ * [OpenOnPhoneContract.PERMISSION], package-addressed to this app) when a+ * watch open request arrives while this app has no live conduit+ * registration. This receiver launches the main activity as a new task, so+ * the button works with no phone process running first; on this app the+ * launched main activity still applies its key gate before showing mail.+ * A request that arrives while the app's sync is registered is handled by+ * that sync's message listener instead and never reaches this receiver.+ */+class OpenOnPhoneReceiver : BroadcastReceiver() {+ override fun onReceive(+ context: Context,+ intent: Intent,+ ) {+ OpenOnPhoneHandler.handle(+ intent.action,+ intent.getStringExtra(OpenOnPhoneContract.EXTRA_APP_ID),+ ) {+ OpenOnPhoneLauncher.launch(+ context.applicationContext,+ com.vayunmathur.securemail.MainActivity::class.java,+ intent.getStringExtra(OpenOnPhoneContract.EXTRA_ENTITY_ID).orEmpty(),+ )+ }+ }+}