Modern Apps git

← Modern-Apps.git

appstore: merge appstore-wear into the single appstore APK

Commit
11730ed12758cd62ac0a2d2cd817b25dca8a1666
Author
Vayun Mathur <[email protected]>
When
2026-12-04 18:21 UTC (1 day ago)
Parents
b01c0de
Owner directive: singular apps that detect when they are on a watch
and adapt, instead of a separate *-wear APK per companion. This
follows the merged clock pilot (adec0c398 + 31a81d3c5) and applies
the same recipe to appstore and its appstore/wear module.

The merged :appstore APK keeps applicationId
com.vayunmathur.appstore and the convention signing on phone, TV
and watch, as the WearLink handshake requires; neither identity
changed and no signature-verification or trust code was touched
(the wear slice only: data/security, data/installer verification,
FDroid/Accrescent/Play trust paths are byte-identical). Runtime
detection is PackageManager.FEATURE_WATCH
(platform/FormFactor, with a pure-core unit test): MainActivity,
the sole phone/TV launcher entry, forwards watches to
ui/WearMainActivity before any phone state (catalog Room database,
UpdateCheckWorker scheduling, NetworkClient/ImageLoader setup) is
touched, and phones/TVs keep the existing store UI. The phone/TV
InstallStatusReceiver and the watch InstallResultReceiver each
early-return on the wrong form factor.

Manifest shape, mirroring clock: no android.hardware.type.watch
uses-feature is declared (required=true would block phones,
required=false is disallowed for this feature; distribution is
sideload/F-Droid, not Play watch channel), plus leanback and
touchscreen not-required, WAKE_LOCK, and
com.google.android.wearable.standalone=false. WearMainActivity is
declared exported=false with no launcher filter (entered only via
MainActivity routing), keeping its Material NoActionBar theme and
empty taskAffinity; InstallResultReceiver is exported=false.

All appstore-wear sources move into appstore closed package roots
(wear/data -> data, wear/platform -> platform, wear/sync -> sync,
wear/ui -> ui), package and R references retarget to
com.vayunmathur.appstore, and wear strings merge as
res/values/wear_strings.xml (duplicate app_name dropped; the wear
ic_launcher_background color is dropped because the phone app
inherits it). The wear WearSyncProtocolTest copy is dropped
because :appstore already pins the same golden JSON in
domain/WearSyncProtocolTest. Watch screenshot previews become
ui/WearMetadataPreviews with group="wear", so :appstore:metadata
renders them into metadata_data/photos/appstore/wear/. The
appstore/wear module, its settings include
(include(":appstore:wear")), and its AGENTS.md are deleted.
appstore/build.gradle.kts gains the Wear Compose material/
foundation and :library:log dependencies the moved watch code
needs. Root and appstore AGENTS.md describe the merged state.

Verified fresh on devvm21958 in this worktree:
./gradlew :appstore:lint :appstore:lintVitalRelease
:appstore:testDevUnitTest green in one invocation (BUILD
SUCCESSFUL, 527 unit tests, 0 failures/errors/skipped, including
the new FormFactorTest and the existing domain
WearSyncProtocolTest). No failures needed a pre-existing-on-base
comparison. Only a real watch can confirm install, FEATURE_WATCH
routing, and the Wear OS install-prompt surface.

Diff

AGENTS.md
diff --git a/AGENTS.md b/AGENTS.mdindex 89c95faa7b..f3662d18eb 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -49,7 +49,7 @@ Monorepo: ~100 Gradle modules + Rust workspace. Do scoped work only. ### Apps (Gradle key → dir) Reference: `backup/` satisfies every rule; `notes/` second + `intents/` demo. `camera` + `games/voxels` hand-commit screenshots. Full canonical index (Gradle key → dir + group + notes): `.llms/repo-map.md`.-`clock`, `notes`, `calendar`, `launcher`, `todo`, `maps`, `camera`, `findfamily` and `contacts` are single merged APKs for phone and watch (watch experience inside the phone app's module; the remaining `*-wear` modules are separate companion APKs with the phone app's applicationId/signing).+`clock`, `notes`, `calendar`, `launcher`, `todo`, `maps`, `camera`, `findfamily`, `contacts` and `appstore` are single merged APKs for phone and watch (watch experience inside the phone app's module; the remaining `*-wear` modules are separate companion APKs with the phone app's applicationId/signing). `appstore→appstore/` `astronomy→astronomy/` `auto→auto/,auto/protocol/` `backup→backup/` `calculator→calculator/` `calendar→calendar/` `camera→camera/` `cast→cast/,cast/protocol/,cast/tv/` `clock→clock/` `code→code/` `communicate→communicate/` `contacts→contacts/` `education→education/` `email→email/` `emergency→emergency/` `euicc→euicc/` `everysync→everysync/` `files→files/` `findfamily→findfamily/` `findfamily-ios→apple/FindFamily/` (SwiftPM/xtool, not Gradle) `flashcards→flashcards/` `fooddelivery→fooddelivery/` `health→health/` `keyboard→keyboard/` `launcher→launcher/` `logviewer→logviewer/` `maps→maps/` `measure→measure/` `music→music/` `networklocation→networklocation/` `news→news/` `notes→notes/` `office→office/` `openassistant→openassistant/` `passwords→passwords/` `pdf→pdf/` `photos→photos/` `parentalcontrols→parentalcontrols/` `screentime→screentime/` `setupwizard→setupwizard/` `share→share/` `speech→speech/` `taxi→taxi/` `things→things/` `todo→todo/` `translate→translate/` `travel→travel/` `tuner→tuner/` `updater→updater/` `vpn→vpn/` `weather→weather/` `watch→watch/,watch-wear/` `web→web/` `youpipe→youpipe/,youpipe/extractor/` `games-hub→games/hub/` `games-arrows→games/arrows/` `games-chess→games/chess/` `games-logicgate→games/logicgate/` `games-minesweeper→games/minesweeper/` `games-nonogram→games/nonogram/` `games-pipes→games/pipes/` `games-solitaire→games/solitaire/` `games-sudoku→games/sudoku/` `games-unblockjam→games/unblockjam/` `games-voxels→games/voxels/` `games-wordmaker→games/wordmaker/` Slash == colon for Gradle (`games/voxels` == `games:voxels`). 
appstore/AGENTS.md
diff --git a/appstore/AGENTS.md b/appstore/AGENTS.mdindex 4a4b271fd1..d6bd8b839f 100644--- a/appstore/AGENTS.md+++ b/appstore/AGENTS.md@@ -4,9 +4,9 @@  _Install: ./install appstore (dev by default)._ - Gradle: :appstore / dir: appstore/-- Package roots present: ui, data, domain, platform, intents-- Entry files: MainActivity.kt, Route.kt (home/library/search/sources/trust/updates tabs + Detail/Browse/Screenshots/UninstallDialog pushed routes)-- Deps: :library:room, :library:network, :library:work, :library:image+- Package roots present: ui, data, domain, platform, intents, sync+- Entry files: MainActivity.kt (sole phone/TV launcher; routes watches to WearMainActivity), Route.kt (home/library/search/sources/trust/updates tabs + Detail/Browse/Screenshots/UninstallDialog pushed routes), ui/WearMainActivity.kt+- Deps: :library:room, :library:network, :library:work, :library:image, :library:tv, :library:wearlink, :library:log, Wear Compose (material + foundation) - Metadata: metadata_data/appstore.md (present) - Rust: yes / screenshotTest: yes @@ -21,6 +21,37 @@ _Install: ./install appstore (dev by default)._ **Architecture / data-flow:** `ui/` home/search/detail/library/updates/sources/trust (+ `ui/dialogs/` stateless dialog contents for the `Route.UninstallDialog` / TV `UninstallDialog` routes) → `platform/AppStoreViewModel` (+ per-area `*Ops`, `AppStoreUiContract`) → `data/` providers per source (`*Repository`, Play/F-Droid/Accrescent clients) + `data/installer/` + `data/security/`; `domain/SearchRanking` is pure ranking. The F-Droid provider additionally downloads the same repo's signed `index-v1.jar` (`FDroidAllowedSigners` in `data/FDroidVerification.kt`, verified against the descriptor's pinned fingerprint and streamed, not loaded whole) and drops every F-Droid app whose advertised version signer is not one of that package's `allowedAPKSigningKeys` before any row is written — index-v2 alone cannot tell a developer key from an F-Droid-generated per-app key. That gate is F-Droid-only; the other F-Droid-format repos keep their own trust rules. **Repo addresses:** our own F-Droid-format repos are consumed from the static R2 bucket — `DefaultRepos.MODERN_APPS` = `https://static.maproj.org/fdroid/repo`, `DefaultRepos.PROPRIETARY` = `https://static.maproj.org/proprietary/repo` (same signed indexes/APKs the server publishes on every build; signing fingerprint pinned as before). The legacy origin addresses (`maproj.org/fdroid/repo`, `maproj.org/proprietary/repo`) keep serving external F-Droid clients and are named only as `LEGACY_*_ORIGIN_URL` constants: stored repo records and cached rows are keyed by URL, so `CatalogRepository.ensureDefaultRepos` prunes rows written under the old addresses and the next sync re-imports under the static ones (no double-added repos). **Entry points + reading order:** `MainActivity.kt` → `Route.kt` → `ui/AppRoot.kt` → `ui/HomePage.kt` → `platform/AppStoreViewModel.kt` → `data/CatalogRepository.kt` → `data/installer/InstallCoordinator.kt` → `data/security/InstallVerifier.kt`.+## One APK, three form factors (phone + TV + watch)+This module is the single App Store APK for phones, TVs and watches: same+`applicationId = "com.vayunmathur.appstore"` and signing on all three, as the+WearLink handshake requires. The manifest deliberately declares no+`android.hardware.type.watch` feature (required=true would block+phones; required=false is disallowed for this feature), plus+leanback/touchscreen not-required and+`com.google.android.wearable.standalone=false`; distribution is+sideload/F-Droid, not Play's watch channel, so the APK installs on+phones, TVs and watches alike. `platform/FormFactor.kt`+reads `PackageManager.FEATURE_WATCH` at runtime: `MainActivity` (the+sole phone/TV launcher entry) forwards watches to `ui/WearMainActivity`+before any phone state loads; phones/TVs get the store UI (TV via+`ui/tv/TvMainActivity`). Form-factor receivers gate the same way —+`data/installer/InstallStatusReceiver` (phone/TV) and+`platform/InstallResultReceiver` (watch) each early-return on the wrong+form factor.++## Wear sync (Watch conduit / WearLink)+**Protocol:** shared wire types live in `:library:wearlink` at `com.vayunmathur.library.wearlink.appstore.WearSyncProtocol`; the golden-JSON test in `domain/WearSyncProtocolTest` pins the shared code's wire format.+- Catalog + watch-state sync: WearLink data items (`/appstore/catalog`, `/appstore/watch-state`)+- Offers / install requests / results: WearLink messages; APK bytes: WearLink stream (`/appstore/apk/<package>`), verified size+SHA-256 against the preceding offer before PackageInstaller ever sees them+- Transport: :library:wearlink (RFCOMM, no Play services); delivery is app-lifecycle-bound — no system listener wakes a dead process+- Phone side `sync/WearSyncManager` (capability discovery, catalog publish, APK streaming) and watch side `sync/WearLinkBridge` both live in this APK; `FormFactor` picks the side at runtime.++## Watch experience (in this module)+- `ui/WearMainActivity` (a `WearShellActivity`, `exported=false`, entered only via `MainActivity`'s watch routing) is the whole watch store: one scrolling catalog/install list reading only the watch's persisted state, so it works standalone with whatever has already been downloaded.+- Watch state persists in `data/WearStore` (`wear-catalog.json` / `wear-phases.json`, verified APKs under `wear-apks/`); `platform/WearInstaller` hands a verified APK to PackageInstaller and `platform/InstallResultReceiver` forwards the system prompt and reports the verdict.+- A normal Wear OS app **cannot silently install**: verified APKs wait in app-private storage until the wearer taps Install and confirms the system PackageInstaller prompt. No state may claim otherwise.+- Watch listing screenshots are the `group = "wear"` previews in `src/screenshotTest/.../ui/WearMetadataPreviews.kt`, collected by `:appstore:metadata` into `metadata_data/photos/appstore/wear/`; phone shots use the `phone` bucket.+ **Gotchas:** - Signature verification is the product — never shortcut it for UX; trust-profile changes need adversarial review - Anonymous Play auth sessions are fragile by nature; isolate Play failures from other sources@@ -75,7 +106,11 @@ _Install: ./install appstore (dev by default)._ - com/vayunmathur/appstore/intents/AppStoreAssistantBackend.kt — backend seam over `CatalogRepository.searchLocal`/`updatesFor` + the provider-side caps ### domain/ — pure ranking (no Android) - com/vayunmathur/appstore/domain/SearchRanking.kt+### sync/ — wear sync (both sides)+- com/vayunmathur/appstore/sync/WearSyncManager.kt — phone side: catalog publish, APK offer/stream, install requests+- com/vayunmathur/appstore/sync/WearLinkBridge.kt — watch side: catalog/offer/stream receive, watch-state publish, install results ### platform/ — ViewModel + per-area ops+- com/vayunmathur/appstore/platform/FormFactor.kt — watch detection (`FEATURE_WATCH`) - com/vayunmathur/appstore/platform/AppStoreViewModel.kt - com/vayunmathur/appstore/platform/AppStoreUiContract.kt - com/vayunmathur/appstore/platform/AppStoreHomeOps.kt@@ -100,6 +135,11 @@ _Install: ./install appstore (dev by default)._ - com/vayunmathur/appstore/ui/TrustPage.kt - com/vayunmathur/appstore/ui/dialogs/UninstallDialog.kt — `Route.UninstallDialog` content - com/vayunmathur/appstore/ui/dialogs/TvUninstallDialog.kt — TV `UninstallDialog` content+### Watch experience (ui/ + platform/ + data/)+- com/vayunmathur/appstore/ui/WearMainActivity.kt — watch entry (WearShellActivity, `exported=false`)+- com/vayunmathur/appstore/platform/WearInstaller.kt — verified-APK PackageInstaller handoff (user confirmation required)+- com/vayunmathur/appstore/platform/InstallResultReceiver.kt — watch PackageInstaller verdicts (gated to watches)+- com/vayunmathur/appstore/data/WearStore.kt — watch catalog/phases/APK store  ## Verify (this module only) ```
appstore/build.gradle.kts
diff --git a/appstore/build.gradle.kts b/appstore/build.gradle.ktsindex 1934c94ffa..12a1eb63e1 100644--- a/appstore/build.gradle.kts+++ b/appstore/build.gradle.kts@@ -142,7 +142,16 @@ dependencies {     implementation(libs.androidx.datastore.preferences)     implementation(project(":library:image"))     implementation(project(":library:tv"))+    // Both sides of the Wear OS sync live in this one APK (same+    // applicationId and signing, as the WearLink handshake requires):+    // sync/WearSyncManager publishes the phone catalog, sync/WearLinkBridge+    // receives it on a watch. FormFactor picks the side at runtime.     implementation(project(":library:wearlink"))+    // Watch experience (ui/Wear*): Wear Compose + the repo log facade the+    // watch platform/sync code writes through.+    implementation(libs.androidx.wear.compose.material)+    implementation(libs.androidx.wear.compose.foundation)+    implementation(project(":library:log"))     // APK source-stamp verification. The stamp is a second signing identity that     // survives Play App Signing re-signing, so it can be pinned per package where the     // APK signing key (held by Google) cannot be.@@ -150,9 +159,9 @@ dependencies {     // HttpURLConnection-based PlayHttpClient/AnonymousAuthRepository/PlayDownloader – no okhttp     implementation(libs.kotlinx.serialization.json)     implementation(libs.auroraoss.gplayapi)-    // Phone side of the Wear OS sync (sync/WearSyncManager): capability-    // discovery, catalog publish and APK streaming to :appstore:wear, which-    // shares this app's applicationId and signing certificate.+    // Wear OS sync (sync/WearSyncManager + sync/WearLinkBridge): capability+    // discovery, catalog publish and APK streaming between this APK's phone+    // and watch experiences (same applicationId and signing certificate).      // --- Accrescent app source -------------------------------------------------------     // gRPC (appstore-api.accrescent.app) over grpc-okhttp, with protobuf-lite messages and
appstore/src/main/AndroidManifest.xml
diff --git a/appstore/src/main/AndroidManifest.xml b/appstore/src/main/AndroidManifest.xmlindex 9fe82f1a03..a1d546716e 100644--- a/appstore/src/main/AndroidManifest.xml+++ b/appstore/src/main/AndroidManifest.xml@@ -37,6 +37,20 @@     <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />     <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" /> +    <!-- Watch-local install sessions wake the watch CPU when they fire. -->+    <uses-permission android:name="android.permission.WAKE_LOCK" />++    <!-- Single APK for phone, TV and watch. Deliberately NO+         android.hardware.type.watch uses-feature here: required="true"+         would block every phone install, and required="false" is+         disallowed for this feature (lint InvalidWearFeatureAttribute;+         Google's packaging model does not support one APK for Wear and+         non-Wear via Play). This app does not distribute through Play's+         watch channel — it is sideloaded / F-Droid-installed, where no+         feature declaration is needed to install on a watch — so the+         APK carries no watch feature filter at all and+         FormFactor.isWatch (PackageManager.FEATURE_WATCH, still+         reported by watch hardware at runtime) routes the experience. -->     <!-- Leanback is supported, not required: one APK serves phones and TVs. Without these,       a TV launcher never lists the app; with required="true" phones would lose it. -->     <uses-feature@@ -56,6 +70,11 @@         android:supportsRtl="true"         android:theme="@style/Theme.General"> +        <!-- Watch experience is paired with the phone app, not standalone. -->+        <meta-data+            android:name="com.google.android.wearable.standalone"+            android:value="false" />+         <provider             android:name="androidx.core.content.FileProvider"             android:authorities="${applicationId}.fileprovider"@@ -140,6 +159,19 @@             android:permission="com.vayunmathur.appstore.permissions.ACCESS_APPSTORE"             android:theme="@android:style/Theme.NoDisplay" /> +        <!-- Watch experience: entered only via MainActivity's watch routing+             (no launcher filter of its own), plus its install-result receiver.+             All are inert on a phone/TV: InstallResultReceiver gates on the+             watch feature, and the rest are reached only from watch state. -->+        <activity+            android:name=".ui.WearMainActivity"+            android:exported="false"+            android:taskAffinity=""+            android:theme="@android:style/Theme.Material.NoActionBar" />+        <receiver+            android:name=".platform.InstallResultReceiver"+            android:exported="false" />+         <receiver             android:name=".data.installer.InstallStatusReceiver"             android:exported="false">
appstore/src/main/java/com/vayunmathur/appstore/MainActivity.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/MainActivity.kt b/appstore/src/main/java/com/vayunmathur/appstore/MainActivity.ktindex 7c40eb78bd..57b0796d71 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/MainActivity.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/MainActivity.kt@@ -21,6 +21,7 @@ import com.vayunmathur.appstore.ui.AppRoot import com.vayunmathur.appstore.platform.refreshInstalled  import android.content.Intent+import android.os.Bundle import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable@@ -32,6 +33,8 @@ import com.vayunmathur.appstore.data.ExternalLinks import com.vayunmathur.appstore.data.UpdateCheckWorker import com.vayunmathur.appstore.platform.AppStoreViewModel import com.vayunmathur.appstore.platform.AppStoreViewModelFactory+import com.vayunmathur.appstore.platform.FormFactor+import com.vayunmathur.appstore.ui.WearMainActivity import com.vayunmathur.library.image.fetchers.HttpImageFetcher import com.vayunmathur.library.image.ImageLoader import com.vayunmathur.library.network.NetworkClient@@ -39,9 +42,27 @@ import com.vayunmathur.library.network.TrustBundle import com.vayunmathur.library.ui.MaActivity import com.vayunmathur.library.util.OfflineAware -/** Entry activity that wires the store UI, navigation and catalog startup. */+/**+ * Sole phone/TV launcher entry of the single merged App Store APK. On a watch+ * (the `android.hardware.type.watch` system feature, see [FormFactor]) it hands+ * off to [WearMainActivity] and finishes before any phone state (catalog Room+ * database, update-check scheduling, network/image setup) is touched; on a+ * phone or TV it wires the store UI, navigation and catalog startup.+ */ class MainActivity : MaActivity() { +    /** True on a watch, where this activity only forwards to [WearMainActivity]. */+    private var routedToWear = false++    override fun onCreate(savedInstanceState: Bundle?) {+        routedToWear = FormFactor.isWatch(this)+        super.onCreate(savedInstanceState)+        if (routedToWear) {+            startActivity(Intent(this, WearMainActivity::class.java))+            finish()+        }+    }+     private var factoryState by mutableStateOf<AppStoreViewModelFactory?>(null)      /** Package named by a `market://` or listing URL we were launched with. */@@ -50,6 +71,7 @@ class MainActivity : MaActivity() {     private var vmRef: AppStoreViewModel? = null      override fun onCreateBeforeContent() {+        if (routedToWear) return         // STANDARD includes GTS R1-R4 (needed for Play Store -> play.google.com / android.clients.google.com)         // + ISRG X1/X2 (F-Droid) + DigiCert G2/G3 (GitHub). Covers all appstore hosts without full system ~140 roots.         com.vayunmathur.library.wearlink.WearLinkPermissions.requestIfNeeded(this)@@ -69,6 +91,9 @@ class MainActivity : MaActivity() {      @Composable     override fun Content() {+        // On a watch this activity is finishing towards WearMainActivity;+        // compose nothing (and touch no phone state) in the meantime.+        if (routedToWear) return         OfflineAware {             val factory = factoryState             if (factory == null) {
appstore/src/main/java/com/vayunmathur/appstore/data/WearStore.kt
diff --git a/appstore/wear/src/main/java/com/vayunmathur/appstore/wear/data/WearStore.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/WearStore.ktsimilarity index 98%rename from appstore/wear/src/main/java/com/vayunmathur/appstore/wear/data/WearStore.ktrename to appstore/src/main/java/com/vayunmathur/appstore/data/WearStore.ktindex e4b2522239..f8b0858563 100644--- a/appstore/wear/src/main/java/com/vayunmathur/appstore/wear/data/WearStore.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/WearStore.kt@@ -1,4 +1,4 @@-package com.vayunmathur.appstore.wear.data+package com.vayunmathur.appstore.data  import android.content.Context import com.vayunmathur.library.wearlink.appstore.ApkOffer@@ -10,7 +10,7 @@ import com.vayunmathur.library.wearlink.appstore.WatchState import com.vayunmathur.library.wearlink.appstore.WearCatalog import com.vayunmathur.library.wearlink.appstore.WearCatalogApp import com.vayunmathur.library.wearlink.appstore.WearSyncProtocol-import com.vayunmathur.appstore.wear.sync.WearLinkBridge+import com.vayunmathur.appstore.sync.WearLinkBridge import com.vayunmathur.library.log.Log import java.io.File import kotlinx.coroutines.flow.MutableStateFlow
appstore/src/main/java/com/vayunmathur/appstore/data/installer/InstallStatusReceiver.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/installer/InstallStatusReceiver.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/installer/InstallStatusReceiver.ktindex 01f9aa89b4..99f339c2a7 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/installer/InstallStatusReceiver.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/installer/InstallStatusReceiver.kt@@ -47,6 +47,9 @@ class InstallStatusReceiver : BroadcastReceiver() {     }      override fun onReceive(context: Context, intent: Intent) {+        // Phone/TV experience only: on a watch InstallResultReceiver owns+        // PackageInstaller verdicts.+        if (com.vayunmathur.appstore.platform.FormFactor.isWatch(context)) return         val status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, UNKNOWN_STATUS)         val message = intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE)         val pkg = intent.getStringExtra(PackageInstaller.EXTRA_PACKAGE_NAME)
appstore/src/main/java/com/vayunmathur/appstore/platform/FormFactor.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/platform/FormFactor.kt b/appstore/src/main/java/com/vayunmathur/appstore/platform/FormFactor.ktnew file mode 100644index 0000000000..4ae3b6c403--- /dev/null+++ b/appstore/src/main/java/com/vayunmathur/appstore/platform/FormFactor.kt@@ -0,0 +1,25 @@+package com.vayunmathur.appstore.platform++import android.content.Context+import android.content.pm.PackageManager++/**+ * Runtime form-factor detection for the single merged App Store APK.+ *+ * One APK ships to phones, TVs and watches (same applicationId and signing, as+ * the WearLink handshake requires). [PackageManager.FEATURE_WATCH] is the+ * canonical watch signal: Wear OS devices report the `android.hardware.type.watch`+ * system feature, phones and TVs do not. The manifest deliberately+ * declares no such uses-feature (required=true would block phones,+ * required=false is disallowed for this feature), so the same APK+ * installs on all three; this runtime check is what routes the experience.+ */+object FormFactor {++    /** True when this device reports the watch system feature. */+    fun isWatch(context: Context): Boolean =+        isWatch(context.packageManager.hasSystemFeature(PackageManager.FEATURE_WATCH))++    /** Pure core of [isWatch], split out so unit tests need no Android runtime. */+    fun isWatch(hasWatchSystemFeature: Boolean): Boolean = hasWatchSystemFeature+}
appstore/src/main/java/com/vayunmathur/appstore/platform/InstallResultReceiver.kt
diff --git a/appstore/wear/src/main/java/com/vayunmathur/appstore/wear/platform/InstallResultReceiver.kt b/appstore/src/main/java/com/vayunmathur/appstore/platform/InstallResultReceiver.ktsimilarity index 91%rename from appstore/wear/src/main/java/com/vayunmathur/appstore/wear/platform/InstallResultReceiver.ktrename to appstore/src/main/java/com/vayunmathur/appstore/platform/InstallResultReceiver.ktindex 3357677bdf..032dddd3f9 100644--- a/appstore/wear/src/main/java/com/vayunmathur/appstore/wear/platform/InstallResultReceiver.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/platform/InstallResultReceiver.kt@@ -1,11 +1,11 @@-package com.vayunmathur.appstore.wear.platform+package com.vayunmathur.appstore.platform  import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.content.pm.PackageInstaller import android.os.Build-import com.vayunmathur.appstore.wear.data.WearStore+import com.vayunmathur.appstore.data.WearStore import com.vayunmathur.library.wearlink.appstore.InstallResult import com.vayunmathur.library.wearlink.appstore.WatchAppEvent import com.vayunmathur.library.log.Log@@ -28,6 +28,8 @@ class InstallResultReceiver : BroadcastReceiver() {     }      override fun onReceive(context: Context, intent: Intent) {+        // Watch experience only: watch install sessions exist only there.+        if (!FormFactor.isWatch(context)) return         val status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, UNKNOWN_STATUS)         val message = intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE).orEmpty()         val packageName = intent.getStringExtra(EXTRA_PACKAGE)@@ -73,6 +75,6 @@ class InstallResultReceiver : BroadcastReceiver() {     }      private fun report(context: Context, result: InstallResult) {-        com.vayunmathur.appstore.wear.sync.WearLinkBridge.reportResult(context, result)+        com.vayunmathur.appstore.sync.WearLinkBridge.reportResult(context, result)     } }
appstore/src/main/java/com/vayunmathur/appstore/platform/WearInstaller.kt
diff --git a/appstore/wear/src/main/java/com/vayunmathur/appstore/wear/platform/WearInstaller.kt b/appstore/src/main/java/com/vayunmathur/appstore/platform/WearInstaller.ktsimilarity index 96%rename from appstore/wear/src/main/java/com/vayunmathur/appstore/wear/platform/WearInstaller.ktrename to appstore/src/main/java/com/vayunmathur/appstore/platform/WearInstaller.ktindex 3d2ca63f92..6532ce393d 100644--- a/appstore/wear/src/main/java/com/vayunmathur/appstore/wear/platform/WearInstaller.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/platform/WearInstaller.kt@@ -1,10 +1,10 @@-package com.vayunmathur.appstore.wear.platform+package com.vayunmathur.appstore.platform  import android.app.PendingIntent import android.content.Context import android.content.Intent import android.content.pm.PackageInstaller-import com.vayunmathur.appstore.wear.data.WearStore+import com.vayunmathur.appstore.data.WearStore import com.vayunmathur.library.wearlink.appstore.WatchAppEvent import com.vayunmathur.library.log.Log import java.io.File
appstore/src/main/java/com/vayunmathur/appstore/sync/WearLinkBridge.kt
diff --git a/appstore/wear/src/main/java/com/vayunmathur/appstore/wear/sync/WearLinkBridge.kt b/appstore/src/main/java/com/vayunmathur/appstore/sync/WearLinkBridge.ktsimilarity index 98%rename from appstore/wear/src/main/java/com/vayunmathur/appstore/wear/sync/WearLinkBridge.ktrename to appstore/src/main/java/com/vayunmathur/appstore/sync/WearLinkBridge.ktindex 5dc79846be..843c3c7cc0 100644--- a/appstore/wear/src/main/java/com/vayunmathur/appstore/wear/sync/WearLinkBridge.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/sync/WearLinkBridge.kt@@ -1,14 +1,14 @@-package com.vayunmathur.appstore.wear.sync+package com.vayunmathur.appstore.sync  import android.content.Context import android.content.Intent-import com.vayunmathur.appstore.wear.data.WearStore+import com.vayunmathur.appstore.data.WearStore import com.vayunmathur.library.wearlink.appstore.ApkOffer import com.vayunmathur.library.wearlink.appstore.InstallResult import com.vayunmathur.library.wearlink.appstore.WatchAppEvent import com.vayunmathur.library.wearlink.appstore.WearCatalog import com.vayunmathur.library.wearlink.appstore.WearSyncProtocol-import com.vayunmathur.appstore.wear.ui.WearMainActivity+import com.vayunmathur.appstore.ui.WearMainActivity import com.vayunmathur.library.log.Log import com.vayunmathur.library.wearlink.StreamSink import com.vayunmathur.library.wearlink.StreamHeader
appstore/src/main/java/com/vayunmathur/appstore/ui/WearMainActivity.kt
diff --git a/appstore/wear/src/main/java/com/vayunmathur/appstore/wear/ui/WearMainActivity.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/WearMainActivity.ktsimilarity index 93%rename from appstore/wear/src/main/java/com/vayunmathur/appstore/wear/ui/WearMainActivity.ktrename to appstore/src/main/java/com/vayunmathur/appstore/ui/WearMainActivity.ktindex 539cae55fb..be386ffdaa 100644--- a/appstore/wear/src/main/java/com/vayunmathur/appstore/wear/ui/WearMainActivity.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/WearMainActivity.kt@@ -1,4 +1,4 @@-package com.vayunmathur.appstore.wear.ui+package com.vayunmathur.appstore.ui  import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding@@ -16,10 +16,10 @@ import androidx.wear.compose.material.Chip import androidx.wear.compose.material.ChipDefaults import androidx.wear.compose.material.MaterialTheme import androidx.wear.compose.material.Text-import com.vayunmathur.appstore.wear.R-import com.vayunmathur.appstore.wear.data.WearStore+import com.vayunmathur.appstore.R+import com.vayunmathur.appstore.data.WearStore import com.vayunmathur.library.wearlink.appstore.WatchAppPhase-import com.vayunmathur.appstore.wear.platform.WearInstaller+import com.vayunmathur.appstore.platform.WearInstaller import com.vayunmathur.library.wearlink.WearShellActivity  /**@@ -33,7 +33,7 @@ import com.vayunmathur.library.wearlink.WearShellActivity class WearMainActivity : WearShellActivity<Unit, WearStore>(Unit) {      override fun createStore() = WearStore.get(this).also {-        com.vayunmathur.appstore.wear.sync.WearLinkBridge.get(this)+        com.vayunmathur.appstore.sync.WearLinkBridge.get(this)         it.publishWatchState()     } @@ -75,8 +75,8 @@ fun WearStoreScreen(store: WearStore) {  */ @Composable internal fun WearStoreContent(-    rows: List<com.vayunmathur.appstore.wear.data.WearRow>,-    onInstall: (com.vayunmathur.appstore.wear.data.WearRow) -> Unit,+    rows: List<com.vayunmathur.appstore.data.WearRow>,+    onInstall: (com.vayunmathur.appstore.data.WearRow) -> Unit, ) {     val listState = rememberScalingLazyListState() 
appstore/src/main/res/values/wear_strings.xml
diff --git a/appstore/wear/src/main/res/values/strings.xml b/appstore/src/main/res/values/wear_strings.xmlsimilarity index 95%rename from appstore/wear/src/main/res/values/strings.xmlrename to appstore/src/main/res/values/wear_strings.xmlindex f85188581c..6c5e5a6cff 100644--- a/appstore/wear/src/main/res/values/strings.xml+++ b/appstore/src/main/res/values/wear_strings.xml@@ -1,6 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <resources>-    <string name="app_name">App Store</string>     <string name="wear_empty">Nothing here yet. Send an app from the App Store on your phone.</string>     <string name="wear_install">Install</string>     <string name="wear_retry_install">Try install again</string>
appstore/src/screenshotTest/kotlin/com/vayunmathur/appstore/ui/WearMetadataPreviews.kt
diff --git a/appstore/wear/src/screenshotTest/kotlin/com/vayunmathur/appstore/wear/ui/MetadataPreviews.kt b/appstore/src/screenshotTest/kotlin/com/vayunmathur/appstore/ui/WearMetadataPreviews.ktsimilarity index 80%rename from appstore/wear/src/screenshotTest/kotlin/com/vayunmathur/appstore/wear/ui/MetadataPreviews.ktrename to appstore/src/screenshotTest/kotlin/com/vayunmathur/appstore/ui/WearMetadataPreviews.ktindex ce36d95ceb..86d0e13b59 100644--- a/appstore/wear/src/screenshotTest/kotlin/com/vayunmathur/appstore/wear/ui/MetadataPreviews.kt+++ b/appstore/src/screenshotTest/kotlin/com/vayunmathur/appstore/ui/WearMetadataPreviews.kt@@ -1,4 +1,4 @@-package com.vayunmathur.appstore.wear.ui+package com.vayunmathur.appstore.ui  import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box@@ -10,7 +10,7 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.tooling.preview.Preview import androidx.wear.compose.material.MaterialTheme import com.android.tools.screenshot.PreviewTest-import com.vayunmathur.appstore.wear.data.WearRow+import com.vayunmathur.appstore.data.WearRow import com.vayunmathur.library.wearlink.appstore.WatchAppPhase import com.vayunmathur.library.wearlink.appstore.WearCatalogApp @@ -18,11 +18,12 @@ import com.vayunmathur.library.wearlink.appstore.WearCatalogApp private const val ROUND = "spec:width=227dp,height=227dp,dpi=320"  /**- * Store listing images for `:appstore:wear` — the module's only top-level screen- * (one catalog/install list by design; see WearMainActivity).- * `./gradlew :appstore:wear:metadata` copies renders into `metadata_data/photos/appstore-wear/wear/`.+ * Watch listing images for the single `:appstore` APK — the watch experience's+ * only top-level screen (one catalog/install list by design; see WearMainActivity).+ * `./gradlew :appstore:metadata` copies these `group = "wear"` renders into+ * `metadata_data/photos/appstore/wear/`; phone shots use the `phone` bucket.  */-class MetadataPreviews {+class WearMetadataPreviews {      @PreviewTest     @Preview(name = "1-store-round", device = ROUND, group = "wear")
appstore/src/test/java/com/vayunmathur/appstore/platform/FormFactorTest.kt
diff --git a/appstore/src/test/java/com/vayunmathur/appstore/platform/FormFactorTest.kt b/appstore/src/test/java/com/vayunmathur/appstore/platform/FormFactorTest.ktnew file mode 100644index 0000000000..f1021de3f9--- /dev/null+++ b/appstore/src/test/java/com/vayunmathur/appstore/platform/FormFactorTest.kt@@ -0,0 +1,19 @@+package com.vayunmathur.appstore.platform++import kotlin.test.Test+import kotlin.test.assertFalse+import kotlin.test.assertTrue++/** The watch system feature is the single-APK routing signal. */+class FormFactorTest {++    @Test+    fun watchFeatureMeansWatch() {+        assertTrue(FormFactor.isWatch(hasWatchSystemFeature = true))+    }++    @Test+    fun noWatchFeatureMeansPhone() {+        assertFalse(FormFactor.isWatch(hasWatchSystemFeature = false))+    }+}
appstore/wear/AGENTS.md
diff --git a/appstore/wear/AGENTS.md b/appstore/wear/AGENTS.mddeleted file mode 100644index a78fc812e8..0000000000--- a/appstore/wear/AGENTS.md+++ /dev/null@@ -1,42 +0,0 @@-# AGENTS.md — appstore/wear/ (':appstore:wear')--> Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside-> `appstore/wear/` + the rest of `appstore/` (the phone side of the same feature).--- Gradle: :appstore:wear / dir: appstore/wear/ (convention: `common-conventions-wear`)-- Package roots present: ui, data, domain, platform, service-- Entry file: ui/WearMainActivity.kt--## Why this module exists (read before changing identity)-Wear OS companion of the phone App Store (`:appstore`). This module-deliberately uses `applicationId = "com.vayunmathur.appstore"` (the phone-app's) with the shared dev/release signing from the convention plugins:-WearLink's handshake token requires the same signing certificate on both-sides, so changing either breaks phone<->watch sync. Bootstrap is a-one-time ADB sideload of this APK onto the watch.--## Protocol-The wire protocol lives in `:library:wearlink` at-`com.vayunmathur.library.wearlink.appstore.WearSyncProtocol` (shared by-`:appstore` and `:appstore:wear`; neither app module depends on the other).-Each side's `WearSyncProtocolTest` pins the same golden JSON against-that shared code.--- Catalog + watch-state sync: WearLink data items (`/appstore/catalog`, `/appstore/watch-state`)-- Offers / install requests / results: WearLink messages-- APK bytes: WearLink stream (`/appstore/apk/<package>`), verified size+SHA-256-  against the preceding offer before PackageInstaller ever sees them-- Transport: :library:wearlink (RFCOMM, no Play services); delivery is-  app-lifecycle-bound — no system listener wakes a dead process--## Install honesty-A normal Wear OS app **cannot silently install**. Verified APKs wait in-app-private storage until the wearer taps Install and confirms the system-PackageInstaller prompt. No state may claim otherwise.--## Verify (this module only)-```-./gradlew :appstore:wear:assembleDev-./gradlew :appstore:wear:testDebugUnitTest-./gradlew :appstore:wear:lint-```
appstore/wear/build.gradle.kts
diff --git a/appstore/wear/build.gradle.kts b/appstore/wear/build.gradle.ktsdeleted file mode 100644index efdc22f282..0000000000--- a/appstore/wear/build.gradle.kts+++ /dev/null@@ -1,32 +0,0 @@-plugins {-    id("common-conventions-wear")-    id("common-conventions-preview-metadata")-}--launcherIcon {-    symbol = "store"-}--android {-    // The Wearable Data Layer only connects apps that share a package name and-    // signing certificate, so this module MUST ship as the phone app's package:-    // same applicationId (below) and the same signing config the convention-    // plugins already apply to both (debug key for dev, release key for-    // release). The convention plugin derives this module's namespace from its-    // Gradle path (:appstore:wear -> com.vayunmathur.appstore.wear).-    defaultConfig {-        applicationId = "com.vayunmathur.appstore"-        // The wear convention plugin pins 30, but :library:log (which it also-        // wires in) requires 31. Wear OS devices on API 30 lose out; the-        // alternative is dropping the repo logging facade, which is worse.-        minSdk = 31-    }-}--dependencies {-    // Watch side of the Wear OS sync (protocol in :library:wearlink).-    implementation(libs.kotlinx.coroutines.android)-    implementation(project(":library:wearlink"))-    testImplementation(libs.kotlin.test)-    testImplementation(libs.kotlin.test.junit)-}
appstore/wear/src/main/AndroidManifest.xml
diff --git a/appstore/wear/src/main/AndroidManifest.xml b/appstore/wear/src/main/AndroidManifest.xmldeleted file mode 100644index 32a3593ec6..0000000000--- a/appstore/wear/src/main/AndroidManifest.xml+++ /dev/null@@ -1,49 +0,0 @@-<?xml version="1.0" encoding="utf-8"?>-<manifest xmlns:android="http://schemas.android.com/apk/res/android">--    <!-- Wear OS form factor. Declaring the watch hardware makes this build-         installable on Wear OS; the touchscreen is not required there. -->-    <uses-feature-        android:name="android.hardware.type.watch"-        android:required="true" />-    <uses-feature-        android:name="android.hardware.touchscreen"-        android:required="false" />--    <!-- PackageInstaller asks the wearer to confirm every install; this-         permission is the phone-API equivalent gate for requesting one. -->-    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />-    <uses-permission android:name="android.permission.WAKE_LOCK" />--    <application-        android:allowBackup="false"-        android:icon="@mipmap/ic_launcher"-        android:label="@string/app_name"-        android:roundIcon="@mipmap/ic_launcher"-        android:supportsRtl="true"-        android:theme="@android:style/Theme.Material.NoActionBar">--        <!-- Paired with the phone app, not a standalone watch app. -->-        <meta-data-            android:name="com.google.android.wearable.standalone"-            android:value="false" />--        <activity-            android:name=".ui.WearMainActivity"-            android:exported="true"-            android:taskAffinity="">-            <intent-filter>-                <action android:name="android.intent.action.MAIN" />-                <category android:name="android.intent.category.LAUNCHER" />-            </intent-filter>-        </activity>--        <!-- WearLink (RFCOMM) delivery is bound to the app process: the-             node starts with the activity above. No system listener service-             (that was a Play-services mechanism) wakes a dead process. -->--        <receiver-            android:name=".platform.InstallResultReceiver"-            android:exported="false" />-    </application>-</manifest>
appstore/wear/src/main/res/values/colors.xml
diff --git a/appstore/wear/src/main/res/values/colors.xml b/appstore/wear/src/main/res/values/colors.xmldeleted file mode 100644index aaf92ba664..0000000000--- a/appstore/wear/src/main/res/values/colors.xml+++ /dev/null@@ -1,7 +0,0 @@-<?xml version="1.0" encoding="utf-8"?>-<!-- Referenced by the generated adaptive launcher icon. Phone apps inherit-     this from :library; the wear convention does not, so the wear store-     declares its own. -->-<resources>-    <color name="ic_launcher_background">#FFFFFF</color>-</resources>
appstore/wear/src/test/java/com/vayunmathur/appstore/wear/domain/WearSyncProtocolTest.kt
diff --git a/appstore/wear/src/test/java/com/vayunmathur/appstore/wear/domain/WearSyncProtocolTest.kt b/appstore/wear/src/test/java/com/vayunmathur/appstore/wear/domain/WearSyncProtocolTest.ktdeleted file mode 100644index 0416814149..0000000000--- a/appstore/wear/src/test/java/com/vayunmathur/appstore/wear/domain/WearSyncProtocolTest.kt+++ /dev/null@@ -1,140 +0,0 @@-package com.vayunmathur.appstore.wear.domain--import com.vayunmathur.library.wearlink.appstore.ApkHash-import com.vayunmathur.library.wearlink.appstore.ApkOffer-import com.vayunmathur.library.wearlink.appstore.InstallResult-import com.vayunmathur.library.wearlink.appstore.PhoneWearEvent-import com.vayunmathur.library.wearlink.appstore.PhoneWearMachine-import com.vayunmathur.library.wearlink.appstore.PhoneWearState-import com.vayunmathur.library.wearlink.appstore.WatchAppEntry-import com.vayunmathur.library.wearlink.appstore.WatchAppEvent-import com.vayunmathur.library.wearlink.appstore.WatchAppMachine-import com.vayunmathur.library.wearlink.appstore.WatchAppPhase-import com.vayunmathur.library.wearlink.appstore.WearCatalog-import com.vayunmathur.library.wearlink.appstore.WearCatalogApp-import com.vayunmathur.library.wearlink.appstore.WearSyncProtocol-import com.vayunmathur.library.wearlink.appstore.watchSendEligibility-import java.io.File-import kotlin.test.Test-import kotlin.test.assertEquals-import kotlin.test.assertFalse-import kotlin.test.assertNull-import kotlin.test.assertTrue-import kotlinx.serialization.encodeToString--class WearSyncProtocolTest {--    @Test-    fun `golden wire json is stable across both apps`() {-        // The wear module pins these exact strings in its own copy of this test:-        // a one-sided protocol edit breaks one side or the other, never silently both.-        val catalog = WearCatalog(listOf(WearCatalogApp("com.example.a", "A", "1.0", 7L, 123L)))-        assertEquals(-            """{"apps":[{"packageName":"com.example.a","name":"A","versionName":"1.0","versionCode":7,"sizeBytes":123}]}""",-            WearSyncProtocol.json.encodeToString(catalog),-        )-        val offer = ApkOffer("com.example.a", "A", 7L, 123L, "ab12")-        assertEquals(-            """{"packageName":"com.example.a","name":"A","versionCode":7,"sizeBytes":123,"sha256":"ab12"}""",-            WearSyncProtocol.json.encodeToString(offer),-        )-        assertEquals("/appstore/apk/com.example.a", WearSyncProtocol.apkChannelPath("com.example.a"))-        assertEquals("com.example.a", WearSyncProtocol.packageFromChannelPath("/appstore/apk/com.example.a"))-        assertNull(WearSyncProtocol.packageFromChannelPath("/appstore/catalog"))-    }--    @Test-    fun `phone machine walks send to installed and never fakes a step`() {-        var state = PhoneWearState.NOT_DOWNLOADED-        state = PhoneWearMachine.reduce(state, PhoneWearEvent.SendStarted)-        assertEquals(PhoneWearState.SENDING, state)-        // Install cannot be requested before the bytes are on the watch.-        assertEquals(-            PhoneWearState.SENDING,-            PhoneWearMachine.reduce(state, PhoneWearEvent.InstallRequested),-        )-        state = PhoneWearMachine.reduce(state, PhoneWearEvent.SendFinished(true))-        assertEquals(PhoneWearState.ON_WATCH, state)-        state = PhoneWearMachine.reduce(state, PhoneWearEvent.InstallRequested)-        assertEquals(PhoneWearState.INSTALL_REQUESTED, state)-        state = PhoneWearMachine.reduce(-            state,-            PhoneWearEvent.ResultReceived(InstallResult("com.example.a", 7L, installed = false, "user cancelled")),-        )-        assertEquals(PhoneWearState.FAILED, state)-    }--    @Test-    fun `reconcile trusts the watch snapshot except during a live send`() {-        val entry = WatchAppEntry("com.example.a", downloadedVersionCode = 7L, installedVersionCode = 7L)-        assertEquals(-            PhoneWearState.INSTALLED,-            PhoneWearMachine.reduce(-                PhoneWearState.ON_WATCH,-                PhoneWearEvent.Reconciled(entry, catalogVersionCode = 7L),-            ),-        )-        assertEquals(-            PhoneWearState.SENDING,-            PhoneWearMachine.reduce(-                PhoneWearState.SENDING,-                PhoneWearEvent.Reconciled(entry, catalogVersionCode = 7L),-            ),-        )-        assertEquals(-            PhoneWearState.FAILED,-            PhoneWearMachine.reduce(PhoneWearState.SENDING, PhoneWearEvent.WatchGone),-        )-        // No capability / no watch: nothing about the app breaks or changes.-        assertEquals(-            PhoneWearState.ON_WATCH,-            PhoneWearMachine.reduce(PhoneWearState.ON_WATCH, PhoneWearEvent.WatchGone),-        )-    }--    @Test-    fun `watch machine requires verified bytes and an explicit install tap`() {-        var phase = WatchAppPhase.LISTED-        phase = WatchAppMachine.reduce(phase, WatchAppEvent.ReceiveStarted)-        assertEquals(WatchAppPhase.RECEIVING, phase)-        phase = WatchAppMachine.reduce(phase, WatchAppEvent.ReceiveFinished(verified = false))-        assertEquals(WatchAppPhase.REJECTED, phase)-        phase = WatchAppMachine.reduce(phase, WatchAppEvent.ReceiveStarted)-        phase = WatchAppMachine.reduce(phase, WatchAppEvent.ReceiveFinished(verified = true))-        assertEquals(WatchAppPhase.READY_TO_INSTALL, phase)-        // No tap, no install: RECEIVING/READY states never advance on their own.-        phase = WatchAppMachine.reduce(phase, WatchAppEvent.InstallTapped)-        assertEquals(WatchAppPhase.INSTALLING, phase)-        phase = WatchAppMachine.reduce(phase, WatchAppEvent.InstallFinished(installed = true))-        assertEquals(WatchAppPhase.INSTALLED, phase)-    }--    @Test-    fun `hash mismatch and truncation are rejected`() {-        val dir = java.nio.file.Files.createTempDirectory("wear-sync").toFile()-        try {-            val file = File(dir, "a.apk").apply { writeBytes("hello watch".toByteArray()) }-            val good = ApkOffer(-                "com.example.a", "A", 1L, file.length(),-                ApkHash.sha256Hex(file),-            )-            assertTrue(ApkHash.verify(file, good))-            assertFalse(ApkHash.verify(file, good.copy(sha256 = "00".repeat(32))))-            assertFalse(ApkHash.verify(file, good.copy(sizeBytes = file.length() + 1)))-        } finally {-            dir.deleteRecursively()-        }-    }--    @Test-    fun `eligibility is a technical gate only`() {-        assertNull(watchSendEligibility("https://x/a.apk", splitCount = 0, sizeBytes = 10L))-        assertTrue(watchSendEligibility(null, 0, 10L) != null)-        assertTrue(watchSendEligibility("https://x/a.apk", splitCount = 2, sizeBytes = 10L) != null)-        assertTrue(-            watchSendEligibility(-                "https://x/a.apk", 0, WearSyncProtocol.MAX_APK_BYTES + 1,-            ) != null,-        )-    }-}
settings.gradle.kts
diff --git a/settings.gradle.kts b/settings.gradle.ktsindex 5a50142905..01148362dc 100644--- a/settings.gradle.kts+++ b/settings.gradle.kts@@ -145,7 +145,6 @@ include(":speech") include(":vpn") include(":web") include(":appstore")-include(":appstore:wear") include(":library:locationprovider") include(":library:aosp-stubs") include(":library:tv")