wearlink: declare watch package visible to conduit clients
- Commit
8b553f32e77af78e2214f2fc531eb72b34fec3f5- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-04 20:12 UTC (1 day ago)
- Parents
425530a
Every WearLinkClientNode reported "Watch app not installed; conduit unavailable" on real devices even with com.vayunmathur.watch installed, so no phone<->watch sync flowed. Root cause: isWatchInstalled() probes the Watch package with getPackageInfo, which under Android 11+ package visibility throws NameNotFoundException unless the calling app can see that package, and no consumer manifest declared it visible. The same invisibility also blocks the explicit-component bindService to the conduit service on API 30+. Fix: declare <queries><package android:name="com.vayunmathur.watch"/> in the :library:wearlink manifest. Manifest merger injects it into every consuming app, which is the standard library-manifest pattern; the package form (rather than an intent form) covers both the getPackageInfo probe and the explicit bind, declares no permission, and keeps the Stage C rule that this library declares no Bluetooth permissions. With the Watch app absent the probe still throws and the node still reports NotInstalled; with it present the probe succeeds, the bind proceeds, and registration (e.g. contacts, appId contacts from the first path segment of /contacts/snapshot/manifest) follows. Checked statically and left unchanged: ConduitProtocol.SERVICE_CLASS matches the actual com.vayunmathur.watch.service.ConduitService in both watch/ and watch-wear/ (.service.ConduitService, action com.vayunmathur.watch.action.CONDUIT in both manifests); the only other PackageManager probe in the conduit path is the host-side ConduitHost.checkSignatures, a name-explicit signature comparison (not a discovery API) guarded by the signature permission, so it needs no visibility declaration; SigningTrust only ever queries the caller's own package. Verified: :library:wearlink:lint and :library:wearlink:testDebugUnitTest green; :contacts:assembleRelease succeeds and its merged release manifest contains <package android:name="com.vayunmathur.watch" /> inside <queries>, unioned with contacts' own messaging-app entries.
Diff
library/wearlink/src/main/AndroidManifest.xml
diff --git a/library/wearlink/src/main/AndroidManifest.xml b/library/wearlink/src/main/AndroidManifest.xmlindex 536f531174..01ae8f4a2a 100644--- a/library/wearlink/src/main/AndroidManifest.xml+++ b/library/wearlink/src/main/AndroidManifest.xml@@ -5,4 +5,17 @@ (:watch, :watch:wear) declare BLUETOOTH_CONNECT and own the real RFCOMM WearLinkNode. Declaring the permissions in this library would inject them into every consuming app. -->++ <!-- Package visibility for the conduit client: WearLinkClientNode+ probes com.vayunmathur.watch with getPackageInfo and binds its+ ConduitService by explicit component. Under Android 11+ package+ visibility both fail unless the calling app can see the Watch+ package, so every consuming app must declare it visible. This+ <queries> entry lives in the library manifest so manifest merger+ injects it into every consumer; a <package> entry (rather than+ an <intent> one) covers both the probe and the explicit bind,+ and it declares no permission. -->+ <queries>+ <package android:name="com.vayunmathur.watch" />+ </queries> </manifest>