Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / launcher / AGENTS.md
| 1 | # AGENTS.md — launcher/ (':launcher') |
| 2 | |
| 3 | > Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside `launcher/` + allowed shared modules. Do not root-scan. |
| 4 | |
| 5 | _Install: ./install launcher (dev by default). For a TV over Wi-Fi: `sh launcher/install-tv.sh <TV_IP>` builds, installs and offers to set it as the default home; `sh launcher/undo-tv.sh <TV_IP>` restores the stock home._ |
| 6 | - Gradle: :launcher / dir: launcher/ |
| 7 | - Package roots present: ui, data, domain, platform, sync + tv/{ui,data,domain,platform} |
| 8 | - Entry files: MainActivity.kt (sole launcher entry; routes watches to WearMainActivity, then UiMode-routed), Route.kt + Navigation.kt (phone), tv/TvRoute.kt + tv/TvNavigation.kt (TV), ui/WearMainActivity.kt (watch) |
| 9 | - Deps: :library:room + :library:wearlink + :library:log + Wear Compose (material + foundation) + androidx.tv.material (via common-conventions-tv) |
| 10 | - Metadata: metadata_data/launcher.md (present, mentions TV mode) |
| 11 | - Rust: no / screenshotTest: yes |
| 12 | |
| 13 | ## Overview |
| 14 | **Purpose:** Offline home-screen replacement — paged grid, hotseat, folders, searchable drawer, real widget hosting on phones; calm banner home with HDMI inputs and D-pad reorder on TVs; launcher-style app drawer on watches. One APK routes by form factor and UI mode. Layout in encrypted Room (phone) / DataStore order (TV) / JSON store (watch); no account, nothing uploaded. |
| 15 | **Key features:** |
| 16 | - Workspace grid with drag/drop/reorder/folder-merge, drop-bar targets, page-edge dwell, widget resize frames (`ui/components/` drag system + `domain/` placement math) |
| 17 | - App drawer with fast scroll + predictions; widget host incl. configurable providers (`platform/LauncherWidgetHost`) |
| 18 | - Icon cache, app-change monitor, privilege-gated surfaces; settings pages |
| 19 | - TV mode (`tv/`): 6-per-row 16:9 banner grid, bottom glass row (App Store/HDMI/Settings/Reorder), clock + network header, single-OK pick-up/drop reorder with focus-chase and slot glide, edit/add menus, HOME role — DataStore order, no Room/widget init |
| 20 | **Architecture / data-flow:** `ui/` home/drawer/folder/settings → `platform/LauncherViewModel` (+ `LauncherUiContract`) → `data/LauncherRepository` over Room; `domain/` is pure grid math (occupancy, placement, reorder, folders, hotseat, pagination) — the single biggest pure-logic area in any app, testable without Compose. `tv/ui/` → `tv/platform/TvHomeViewModel` (+ `TvUiContract`) → `tv/data/TvPrefs` (DataStore); `tv/domain/TvRowOrder` is pure row math. `MainActivity` routes by `UiModeManager`; neither mode initializes the other's stack. |
| 21 | **Entry points + reading order:** `Route` → `MainActivity.kt` (UiMode branch) → phone `Navigation.kt` → `ui/HomeWorkspace.kt` → `platform/LauncherViewModel.kt` → `domain/GridPlacer.kt` + `domain/ReconcileUseCase.kt`; TV `TvRoute` → `tv/TvNavigation.kt` → `tv/ui/TvHomeScreen.kt` → `tv/platform/TvHomeViewModel.kt` → `tv/domain/TvRowOrder.kt`. |
| 22 | ## One APK, three form factors (phone + TV + watch) |
| 23 | This module is the single Launcher APK for phones, TVs and watches: same |
| 24 | `applicationId = "com.vayunmathur.launcher"` and signing on all, as the |
| 25 | WearLink handshake requires. The manifest deliberately declares no |
| 26 | `android.hardware.type.watch` feature (required=true would block |
| 27 | phones/TVs; required=false is disallowed for this feature), plus |
| 28 | touchscreen not-required and |
| 29 | `com.google.android.wearable.standalone=false`; distribution is |
| 30 | sideload/F-Droid, not Play's watch channel, so the APK installs on |
| 31 | phones, TVs and watches alike. `platform/FormFactor.kt` |
| 32 | reads `PackageManager.FEATURE_WATCH` at runtime: `MainActivity` (the |
| 33 | sole launcher entry) forwards watches to `ui/WearMainActivity` before |
| 34 | any phone/TV state loads; phones/TVs get the UiMode-routed UI. There are two broadcast receivers: |
| 35 | the conduit sync-trigger receiver |
| 36 | (`sync/ConduitSyncTriggerReceiver`) starts the phone sync |
| 37 | (`sync/WearLauncherSync`) outside the phone path, and the open-on-phone |
| 38 | receiver (`sync/OpenOnPhoneReceiver`) launches the main activity; the watch |
| 39 | bridge (`sync/WearLinkBridge`) starts only from `ui/WearMainActivity`, so |
| 40 | neither runs on the wrong form factor. |
| 41 | |
| 42 | ## Watch experience (in this module) |
| 43 | - `ui/WearMainActivity` (`exported=false`, no |
| 44 | launcher/HOME filter of its own) routes `ui/WearRoute` over home |
| 45 | (synced favorites, watch-local recents, companion shortcuts) / |
| 46 | all-apps drawer with local filter / settings rows that open only |
| 47 | system intents resolving on the watch. |
| 48 | - On stock Wear OS this is not the system HOME: the watch home is a |
| 49 | privileged system component with no public `CATEGORY_HOME` election |
| 50 | or `ROLE_HOME` grant for third-party apps, so the watch experience |
| 51 | never claims HOME (phone/TV HOME in `MainActivity` is unchanged). |
| 52 | - Watch state persists in `data/WearLauncherStore` |
| 53 | (`wear-launcher-favorites.json` / `wear-launcher-recents.json`); |
| 54 | installed apps are enumerated by `platform/InstalledApps`, sections |
| 55 | are pure in `domain/WearLauncherModel`. |
| 56 | - Watch listing screenshots are the `group = "wear"` previews in |
| 57 | `src/screenshotTest/.../ui/WearMetadataPreviews.kt`, collected by |
| 58 | `:launcher:metadata` into `metadata_data/photos/launcher/wear/`; |
| 59 | phone shots use the `phone` bucket. |
| 60 | |
| 61 | ## Wear sync (Watch conduit client) |
| 62 | **Protocol:** shared wire types live in `:library:wearlink` at `com.vayunmathur.library.wearlink.launcher.WearLauncherProtocol`; the golden-JSON tests in this module pin the shared code's wire format. |
| 63 | - Favorites + watch-state sync: conduit data items (`/launcher/favorites`, `/launcher/watch-state`) |
| 64 | - Sync request: conduit message (`/launcher/request-sync`), watch -> phone only |
| 65 | - Only the phone hotseat (pinned row) syncs — not the workspace grid, folders or widgets. Recents are watch-local and never sync. |
| 66 | - **Transport: Watch conduit client** — phone side `sync/WearLauncherSync.kt` and watch side `sync/WearLinkBridge.kt` both use `WearLinkClientNode` (Messenger to the Watch app's `watch_conduit` service, appId `launcher`); this app owns no RFCOMM link and holds no Bluetooth permission for this channel, so neither entry activity prompts for Bluetooth. With the Watch app absent the node reports `NotInstalled`/`Unavailable` and the sync stays idle; favorites republish on conduit `Connected`. |
| 67 | - **Push triggers:** the publish also runs on the phone Watch app's scheduled sync-trigger intent (`sync/ConduitSyncTriggerReceiver`, exported only under the `CONDUIT` signature permission, invoking `WearLauncherSync.syncNow()` — no UI, no prompt). Data arriving while the receiving process is dead lands in the conduit host's persistent store and replays on registration. |
| 68 | - **Open on phone:** the watch request (`/<appId>/open-on-phone` conduit message; camera: `OPEN_ON_PHONE` op) is handled live by the sync message listener when this app is registered, and otherwise the phone conduit host broadcasts `OpenOnPhoneContract.ACTION` (package-addressed, `CONDUIT` signature permission) to `sync/OpenOnPhoneReceiver`, which launches the main activity as a new task — no phone process needs to be running first. |
| 69 | |
| 70 | **Gotchas:** |
| 71 | - Exempt from the raw-animation rule: built on `animateBounds`/`Animatable` — do NOT "migrate" its motion to library helpers. TV code under `tv/` keeps using `library.ui` helpers anyway — no regression just because the package is exempt. |
| 72 | - Reconcile (installed-apps vs stored layout) runs on package changes — launcher bugs after installs live in `ReconcileUseCase` + `LauncherAppsMonitor` |
| 73 | - Drag input math is in `domain/`, gesture plumbing in `ui/components/` — keep them separated |
| 74 | - TV Back order: edit menu → cancel hold (quiet restore) → disarm reorder → no-op. TV hint slot is always composed (`TvReorderHint`) — never conditionally compose hints in the `SpaceBetween` column or the grid jumps. |
| 75 | - One HOME filter carries MAIN+LAUNCHER+LEANBACK_LAUNCHER+HOME+DEFAULT together — split filters on one activity confuse resolver elections. |
| 76 | |
| 77 | ## Key files |
| 78 | ### Root — entry + navigation |
| 79 | - com/vayunmathur/launcher/MainActivity.kt |
| 80 | - com/vayunmathur/launcher/Navigation.kt |
| 81 | - com/vayunmathur/launcher/Route.kt |
| 82 | ### data/ — encrypted layout store |
| 83 | - com/vayunmathur/launcher/data/LauncherDatabase.kt |
| 84 | - com/vayunmathur/launcher/data/LauncherRepository.kt |
| 85 | - com/vayunmathur/launcher/data/LauncherItemEntity.kt |
| 86 | ### domain/ — pure grid math (no Android/Compose) |
| 87 | - com/vayunmathur/launcher/domain/ReconcileUseCase.kt |
| 88 | - com/vayunmathur/launcher/domain/GridPlacer.kt |
| 89 | - com/vayunmathur/launcher/domain/GridReorder.kt |
| 90 | - com/vayunmathur/launcher/domain/CellOccupancy.kt |
| 91 | - com/vayunmathur/launcher/domain/CellRect.kt |
| 92 | - com/vayunmathur/launcher/domain/ContainerRef.kt |
| 93 | - com/vayunmathur/launcher/domain/AutoPlacer.kt |
| 94 | - com/vayunmathur/launcher/domain/DropBarTargets.kt |
| 95 | - com/vayunmathur/launcher/domain/FolderMerge.kt |
| 96 | - com/vayunmathur/launcher/domain/FolderRules.kt |
| 97 | - com/vayunmathur/launcher/domain/GridPreview.kt |
| 98 | - com/vayunmathur/launcher/domain/HotseatArrange.kt |
| 99 | - com/vayunmathur/launcher/domain/LauncherItemType.kt |
| 100 | - com/vayunmathur/launcher/domain/LauncherTuning.kt |
| 101 | - com/vayunmathur/launcher/domain/PageCount.kt |
| 102 | - com/vayunmathur/launcher/domain/ReorderDwell.kt |
| 103 | - com/vayunmathur/launcher/domain/FastScroll.kt |
| 104 | - com/vayunmathur/launcher/domain/WidgetResize.kt |
| 105 | ### platform/ — ViewModel, monitor, widgets, bridge |
| 106 | - com/vayunmathur/launcher/platform/LauncherViewModel.kt |
| 107 | - com/vayunmathur/launcher/platform/LauncherUiContract.kt |
| 108 | - com/vayunmathur/launcher/platform/LauncherAppsMonitor.kt |
| 109 | - com/vayunmathur/launcher/platform/LauncherPredictions.kt |
| 110 | - com/vayunmathur/launcher/platform/LauncherWidgetHost.kt |
| 111 | - com/vayunmathur/launcher/platform/LauncherWidgets.kt |
| 112 | - com/vayunmathur/launcher/platform/IconCache.kt |
| 113 | - com/vayunmathur/launcher/platform/ActivityBridge.kt |
| 114 | - com/vayunmathur/launcher/platform/LauncherPrivilege.kt |
| 115 | - com/vayunmathur/launcher/platform/AppBackupAgent.kt — platform backup: SQLCipher DB via `SqlCipherDbCodec` plaintext round-trip (raw DB + `secure_prefs` excluded in `res/xml/data_extraction_rules.xml`); payload also carries `datastore_default`, `tvlauncher_config` and the watch JSON files |
| 116 | - com/vayunmathur/launcher/platform/FormFactor.kt — watch detection (`FEATURE_WATCH`) |
| 117 | - com/vayunmathur/launcher/platform/InstalledApps.kt — watch installed-app enumeration + settings targets |
| 118 | ### Watch experience (ui/ + data/ + domain/ + platform/ + sync/) |
| 119 | - com/vayunmathur/launcher/ui/WearMainActivity.kt — watch entry (exported=false) |
| 120 | - com/vayunmathur/launcher/ui/WearRoute.kt, WearLauncherScreen.kt, WearAllAppsScreen.kt, WearSettingsScreen.kt |
| 121 | - com/vayunmathur/launcher/data/WearLauncherStore.kt |
| 122 | - com/vayunmathur/launcher/domain/WearLauncherModel.kt |
| 123 | - com/vayunmathur/launcher/sync/WearLauncherSync.kt — phone conduit client node; favorites publish, watch-state receive, request-sync handling |
| 124 | - com/vayunmathur/launcher/sync/WearLinkBridge.kt — watch conduit client node; favorites receive into the store, watch-state publish |
| 125 | |
| 126 | ### tv/ — TV mode (UiMode-routed, DataStore order, no Room/widgets) |
| 127 | - com/vayunmathur/launcher/tv/TvRoute.kt |
| 128 | - com/vayunmathur/launcher/tv/TvNavigation.kt |
| 129 | - com/vayunmathur/launcher/tv/data/TvPrefs.kt |
| 130 | - com/vayunmathur/launcher/tv/domain/TvRowOrder.kt |
| 131 | - com/vayunmathur/launcher/tv/platform/TvHomeViewModel.kt |
| 132 | - com/vayunmathur/launcher/tv/platform/TvUiContract.kt |
| 133 | - com/vayunmathur/launcher/tv/platform/TvApps.kt |
| 134 | - com/vayunmathur/launcher/tv/platform/TvInputs.kt |
| 135 | - com/vayunmathur/launcher/tv/platform/TvHomeRole.kt |
| 136 | - com/vayunmathur/launcher/tv/platform/TvArtCache.kt |
| 137 | - com/vayunmathur/launcher/tv/ui/TvHomeScreen.kt |
| 138 | - com/vayunmathur/launcher/tv/ui/TvHomePage.kt |
| 139 | - com/vayunmathur/launcher/tv/ui/TvClockHeader.kt |
| 140 | - com/vayunmathur/launcher/tv/ui/TvAppGrid.kt |
| 141 | - com/vayunmathur/launcher/tv/ui/TvBottomRow.kt |
| 142 | - com/vayunmathur/launcher/tv/ui/TvEditMenu.kt |
| 143 | - com/vayunmathur/launcher/tv/ui/components/TvBannerTile.kt |
| 144 | - com/vayunmathur/launcher/tv/ui/components/TvReorderHint.kt |
| 145 | ### ui/ + ui/components/ — workspace, drawer, drag system |
| 146 | - com/vayunmathur/launcher/ui/HomeWorkspace.kt |
| 147 | - com/vayunmathur/launcher/ui/HomePage.kt |
| 148 | - com/vayunmathur/launcher/ui/HomeContent.kt |
| 149 | - com/vayunmathur/launcher/ui/WorkspacePage.kt |
| 150 | - com/vayunmathur/launcher/ui/WorkspaceGrid.kt |
| 151 | - com/vayunmathur/launcher/ui/HomeGestureRoot.kt |
| 152 | - com/vayunmathur/launcher/ui/HomeDropLogic.kt |
| 153 | - com/vayunmathur/launcher/ui/HomeLaunch.kt |
| 154 | - com/vayunmathur/launcher/ui/HomeEffects.kt |
| 155 | - com/vayunmathur/launcher/ui/HomeOverlays.kt |
| 156 | - com/vayunmathur/launcher/ui/HomePopups.kt |
| 157 | - com/vayunmathur/launcher/ui/HomeConstants.kt |
| 158 | - com/vayunmathur/launcher/ui/HomeDrawerSwipe.kt |
| 159 | - com/vayunmathur/launcher/ui/WorkspaceOptionsContent.kt |
| 160 | - com/vayunmathur/launcher/ui/HotseatBar.kt |
| 161 | - com/vayunmathur/launcher/ui/FolderContent.kt |
| 162 | - com/vayunmathur/launcher/ui/DrawerContent.kt |
| 163 | - com/vayunmathur/launcher/ui/DrawerCells.kt |
| 164 | - com/vayunmathur/launcher/ui/DrawerFastScroll.kt |
| 165 | - com/vayunmathur/launcher/ui/ItemMenuContent.kt |
| 166 | - com/vayunmathur/launcher/ui/dialogs/UninstallDialogContent.kt (stateless content of the `Route.UninstallDialog` destination) |
| 167 | - com/vayunmathur/launcher/ui/SettingsPage.kt |
| 168 | - com/vayunmathur/launcher/ui/SettingsContent.kt |
| 169 | - com/vayunmathur/launcher/ui/WidgetPickerContent.kt |
| 170 | - com/vayunmathur/launcher/ui/components/LauncherDragController.kt |
| 171 | - com/vayunmathur/launcher/ui/components/DragLayer.kt |
| 172 | - com/vayunmathur/launcher/ui/components/DragFeedback.kt |
| 173 | - com/vayunmathur/launcher/ui/components/DragSourceModifier.kt |
| 174 | - com/vayunmathur/launcher/ui/components/DropTargetModifier.kt |
| 175 | - com/vayunmathur/launcher/ui/components/DropBar.kt |
| 176 | - com/vayunmathur/launcher/ui/components/CellLayout.kt |
| 177 | - com/vayunmathur/launcher/ui/components/CellPlacement.kt |
| 178 | - com/vayunmathur/launcher/ui/components/LauncherDragInput.kt |
| 179 | - com/vayunmathur/launcher/ui/components/LauncherDragInputSection.kt |
| 180 | - com/vayunmathur/launcher/ui/components/LauncherAppIcon.kt |
| 181 | - com/vayunmathur/launcher/ui/components/LauncherItemIcon.kt |
| 182 | - com/vayunmathur/launcher/ui/components/LauncherPopup.kt |
| 183 | - com/vayunmathur/launcher/ui/components/LauncherPopupSurface.kt |
| 184 | - com/vayunmathur/launcher/ui/components/MergeRing.kt |
| 185 | - com/vayunmathur/launcher/ui/components/ReorderPreview.kt |
| 186 | - com/vayunmathur/launcher/ui/components/PageIndicator.kt |
| 187 | - com/vayunmathur/launcher/ui/components/PageEdgeDwell.kt |
| 188 | - com/vayunmathur/launcher/ui/components/FastScrollStrip.kt |
| 189 | - com/vayunmathur/launcher/ui/components/HostedWidget.kt |
| 190 | - com/vayunmathur/launcher/ui/components/MissingWidget.kt |
| 191 | - com/vayunmathur/launcher/ui/components/WidgetResizeFrame.kt |
| 192 | - com/vayunmathur/launcher/ui/components/AppWindowBounds.kt |
| 193 | |
| 194 | ## Verify (this module only) |
| 195 | ``` |
| 196 | ./gradlew :launcher:compileDevKotlin |
| 197 | ./gradlew :launcher:lint |
| 198 | ./gradlew :launcher:checkMetadata |
| 199 | ``` |