Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
translate ▾

Modern-Apps.git / launcher / AGENTS.md

AGENTS.md13.5 KiBRenderedCodeRaw
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)
23This module is the single Launcher APK for phones, TVs and watches: same
24`applicationId = "com.vayunmathur.launcher"` and signing on all, as the
25WearLink handshake requires. The manifest deliberately declares no
26`android.hardware.type.watch` feature (required=true would block
27phones/TVs; required=false is disallowed for this feature), plus
28touchscreen not-required and
29`com.google.android.wearable.standalone=false`; distribution is
30sideload/F-Droid, not Play's watch channel, so the APK installs on
31phones, TVs and watches alike. `platform/FormFactor.kt`
32reads `PackageManager.FEATURE_WATCH` at runtime: `MainActivity` (the
33sole launcher entry) forwards watches to `ui/WearMainActivity` before
34any phone/TV state loads; phones/TVs get the UiMode-routed UI. There
35are no broadcast receivers in this module; the phone sync
36(`sync/WearLauncherSync`) starts only from the phone path and the watch
37bridge (`sync/WearLinkBridge`) only from `ui/WearMainActivity`, so
38neither runs on the wrong form factor.
39
40## Watch experience (in this module)
41- `ui/WearMainActivity` (`exported=false`, no
42 launcher/HOME filter of its own) routes `ui/WearRoute` over home
43 (synced favorites, watch-local recents, companion shortcuts) /
44 all-apps drawer with local filter / settings rows that open only
45 system intents resolving on the watch.
46- On stock Wear OS this is not the system HOME: the watch home is a
47 privileged system component with no public `CATEGORY_HOME` election
48 or `ROLE_HOME` grant for third-party apps, so the watch experience
49 never claims HOME (phone/TV HOME in `MainActivity` is unchanged).
50- Watch state persists in `data/WearLauncherStore`
51 (`wear-launcher-favorites.json` / `wear-launcher-recents.json`);
52 installed apps are enumerated by `platform/InstalledApps`, sections
53 are pure in `domain/WearLauncherModel`.
54- Watch listing screenshots are the `group = "wear"` previews in
55 `src/screenshotTest/.../ui/WearMetadataPreviews.kt`, collected by
56 `:launcher:metadata` into `metadata_data/photos/launcher/wear/`;
57 phone shots use the `phone` bucket.
58
59## Wear sync (Watch conduit client)
60**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.
61- Favorites + watch-state sync: conduit data items (`/launcher/favorites`, `/launcher/watch-state`)
62- Sync request: conduit message (`/launcher/request-sync`), watch -> phone only
63- Only the phone hotseat (pinned row) syncs — not the workspace grid, folders or widgets. Recents are watch-local and never sync.
64- **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`.
65
66**Gotchas:**
67- 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.
68- Reconcile (installed-apps vs stored layout) runs on package changes — launcher bugs after installs live in `ReconcileUseCase` + `LauncherAppsMonitor`
69- Drag input math is in `domain/`, gesture plumbing in `ui/components/` — keep them separated
70- 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.
71- One HOME filter carries MAIN+LAUNCHER+LEANBACK_LAUNCHER+HOME+DEFAULT together — split filters on one activity confuse resolver elections.
72
73## Key files
74### Root — entry + navigation
75- com/vayunmathur/launcher/MainActivity.kt
76- com/vayunmathur/launcher/Navigation.kt
77- com/vayunmathur/launcher/Route.kt
78### data/ — encrypted layout store
79- com/vayunmathur/launcher/data/LauncherDatabase.kt
80- com/vayunmathur/launcher/data/LauncherRepository.kt
81- com/vayunmathur/launcher/data/LauncherItemEntity.kt
82### domain/ — pure grid math (no Android/Compose)
83- com/vayunmathur/launcher/domain/ReconcileUseCase.kt
84- com/vayunmathur/launcher/domain/GridPlacer.kt
85- com/vayunmathur/launcher/domain/GridReorder.kt
86- com/vayunmathur/launcher/domain/CellOccupancy.kt
87- com/vayunmathur/launcher/domain/CellRect.kt
88- com/vayunmathur/launcher/domain/ContainerRef.kt
89- com/vayunmathur/launcher/domain/AutoPlacer.kt
90- com/vayunmathur/launcher/domain/DropBarTargets.kt
91- com/vayunmathur/launcher/domain/FolderMerge.kt
92- com/vayunmathur/launcher/domain/FolderRules.kt
93- com/vayunmathur/launcher/domain/GridPreview.kt
94- com/vayunmathur/launcher/domain/HotseatArrange.kt
95- com/vayunmathur/launcher/domain/LauncherItemType.kt
96- com/vayunmathur/launcher/domain/LauncherTuning.kt
97- com/vayunmathur/launcher/domain/PageCount.kt
98- com/vayunmathur/launcher/domain/ReorderDwell.kt
99- com/vayunmathur/launcher/domain/FastScroll.kt
100- com/vayunmathur/launcher/domain/WidgetResize.kt
101### platform/ — ViewModel, monitor, widgets, bridge
102- com/vayunmathur/launcher/platform/LauncherViewModel.kt
103- com/vayunmathur/launcher/platform/LauncherUiContract.kt
104- com/vayunmathur/launcher/platform/LauncherAppsMonitor.kt
105- com/vayunmathur/launcher/platform/LauncherPredictions.kt
106- com/vayunmathur/launcher/platform/LauncherWidgetHost.kt
107- com/vayunmathur/launcher/platform/LauncherWidgets.kt
108- com/vayunmathur/launcher/platform/IconCache.kt
109- com/vayunmathur/launcher/platform/ActivityBridge.kt
110- com/vayunmathur/launcher/platform/LauncherPrivilege.kt
111- 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
112- com/vayunmathur/launcher/platform/FormFactor.kt — watch detection (`FEATURE_WATCH`)
113- com/vayunmathur/launcher/platform/InstalledApps.kt — watch installed-app enumeration + settings targets
114### Watch experience (ui/ + data/ + domain/ + platform/ + sync/)
115- com/vayunmathur/launcher/ui/WearMainActivity.kt — watch entry (exported=false)
116- com/vayunmathur/launcher/ui/WearRoute.kt, WearLauncherScreen.kt, WearAllAppsScreen.kt, WearSettingsScreen.kt
117- com/vayunmathur/launcher/data/WearLauncherStore.kt
118- com/vayunmathur/launcher/domain/WearLauncherModel.kt
119- com/vayunmathur/launcher/sync/WearLauncherSync.kt — phone conduit client node; favorites publish, watch-state receive, request-sync handling
120- com/vayunmathur/launcher/sync/WearLinkBridge.kt — watch conduit client node; favorites receive into the store, watch-state publish
121- com/vayunmathur/launcher/sync/WearSyncRequest.kt — `requestWearSync` helper (watch asks phone for fresh favorites)
122
123### tv/ — TV mode (UiMode-routed, DataStore order, no Room/widgets)
124- com/vayunmathur/launcher/tv/TvRoute.kt
125- com/vayunmathur/launcher/tv/TvNavigation.kt
126- com/vayunmathur/launcher/tv/data/TvPrefs.kt
127- com/vayunmathur/launcher/tv/domain/TvRowOrder.kt
128- com/vayunmathur/launcher/tv/platform/TvHomeViewModel.kt
129- com/vayunmathur/launcher/tv/platform/TvUiContract.kt
130- com/vayunmathur/launcher/tv/platform/TvApps.kt
131- com/vayunmathur/launcher/tv/platform/TvInputs.kt
132- com/vayunmathur/launcher/tv/platform/TvHomeRole.kt
133- com/vayunmathur/launcher/tv/platform/TvArtCache.kt
134- com/vayunmathur/launcher/tv/ui/TvHomeScreen.kt
135- com/vayunmathur/launcher/tv/ui/TvHomePage.kt
136- com/vayunmathur/launcher/tv/ui/TvClockHeader.kt
137- com/vayunmathur/launcher/tv/ui/TvAppGrid.kt
138- com/vayunmathur/launcher/tv/ui/TvBottomRow.kt
139- com/vayunmathur/launcher/tv/ui/TvEditMenu.kt
140- com/vayunmathur/launcher/tv/ui/components/TvBannerTile.kt
141- com/vayunmathur/launcher/tv/ui/components/TvReorderHint.kt
142### ui/ + ui/components/ — workspace, drawer, drag system
143- com/vayunmathur/launcher/ui/HomeWorkspace.kt
144- com/vayunmathur/launcher/ui/HomePage.kt
145- com/vayunmathur/launcher/ui/HomeContent.kt
146- com/vayunmathur/launcher/ui/WorkspacePage.kt
147- com/vayunmathur/launcher/ui/WorkspaceGrid.kt
148- com/vayunmathur/launcher/ui/HomeGestureRoot.kt
149- com/vayunmathur/launcher/ui/HomeDropLogic.kt
150- com/vayunmathur/launcher/ui/HomeLaunch.kt
151- com/vayunmathur/launcher/ui/HomeEffects.kt
152- com/vayunmathur/launcher/ui/HomeOverlays.kt
153- com/vayunmathur/launcher/ui/HomePopups.kt
154- com/vayunmathur/launcher/ui/HomeConstants.kt
155- com/vayunmathur/launcher/ui/HomeDrawerSwipe.kt
156- com/vayunmathur/launcher/ui/WorkspaceOptionsContent.kt
157- com/vayunmathur/launcher/ui/HotseatBar.kt
158- com/vayunmathur/launcher/ui/FolderContent.kt
159- com/vayunmathur/launcher/ui/DrawerContent.kt
160- com/vayunmathur/launcher/ui/DrawerCells.kt
161- com/vayunmathur/launcher/ui/DrawerFastScroll.kt
162- com/vayunmathur/launcher/ui/ItemMenuContent.kt
163- com/vayunmathur/launcher/ui/dialogs/UninstallDialogContent.kt (stateless content of the `Route.UninstallDialog` destination)
164- com/vayunmathur/launcher/ui/SettingsPage.kt
165- com/vayunmathur/launcher/ui/SettingsContent.kt
166- com/vayunmathur/launcher/ui/WidgetPickerContent.kt
167- com/vayunmathur/launcher/ui/components/LauncherDragController.kt
168- com/vayunmathur/launcher/ui/components/DragLayer.kt
169- com/vayunmathur/launcher/ui/components/DragFeedback.kt
170- com/vayunmathur/launcher/ui/components/DragSourceModifier.kt
171- com/vayunmathur/launcher/ui/components/DropTargetModifier.kt
172- com/vayunmathur/launcher/ui/components/DropBar.kt
173- com/vayunmathur/launcher/ui/components/CellLayout.kt
174- com/vayunmathur/launcher/ui/components/CellPlacement.kt
175- com/vayunmathur/launcher/ui/components/LauncherDragInput.kt
176- com/vayunmathur/launcher/ui/components/LauncherDragInputSection.kt
177- com/vayunmathur/launcher/ui/components/LauncherAppIcon.kt
178- com/vayunmathur/launcher/ui/components/LauncherItemIcon.kt
179- com/vayunmathur/launcher/ui/components/LauncherPopup.kt
180- com/vayunmathur/launcher/ui/components/LauncherPopupSurface.kt
181- com/vayunmathur/launcher/ui/components/MergeRing.kt
182- com/vayunmathur/launcher/ui/components/ReorderPreview.kt
183- com/vayunmathur/launcher/ui/components/PageIndicator.kt
184- com/vayunmathur/launcher/ui/components/PageEdgeDwell.kt
185- com/vayunmathur/launcher/ui/components/FastScrollStrip.kt
186- com/vayunmathur/launcher/ui/components/HostedWidget.kt
187- com/vayunmathur/launcher/ui/components/MissingWidget.kt
188- com/vayunmathur/launcher/ui/components/WidgetResizeFrame.kt
189- com/vayunmathur/launcher/ui/components/AppWindowBounds.kt
190
191## Verify (this module only)
192```
193./gradlew :launcher:compileDevKotlin
194./gradlew :launcher:lint
195./gradlew :launcher:checkMetadata
196```