chore(android): port widget triple to Java JNI shims, drop configure activity (#83)#128
Open
hyperpolymath wants to merge 2 commits into
Open
chore(android): port widget triple to Java JNI shims, drop configure activity (#83)#128hyperpolymath wants to merge 2 commits into
hyperpolymath wants to merge 2 commits into
Conversation
…activity (#83) Sub-PR #7 of the Android Kotlin->Rust/Gossamer migration (epic #83, RFC PR #97, sub-issue #113). Replace the home-screen widget Kotlin with thin hand-written Java shims that JNI into the Rust core (crates/neurophone-android) via NativeLib.getState() / NativeLib.query(...): - NeurophoneAppWidget.kt -> NeurophoneAppWidget.java (AppWidgetProvider) - NeurophoneWidgetActions.kt -> NeurophoneWidgetActions.java (BroadcastReceiver) The widget is now stateless: it reads live salience/description straight from the Rust core on each render instead of caching in SharedPreferences. OWNER DECISION: NeurophoneWidgetConfigureActivity.kt is DROPPED, not ported. It had no manifest <activity> entry; its only registration was android:configure in res/xml/neurophone_widget_info.xml, now removed along with the reconfigurable|configuration_optional widgetFeatures and the widget_configure_* strings. The widget works with no configure step. Knock-on (Kotlin callers of removed widget API, kept compiling): - NeurophoneService.kt: publishState(...) -> requestRefresh(...) - BootReceiver.kt: dropped widget-prefs KEY_RUNNING read (now a core concern); conservatively no-ops on boot pending core autostart flag. Hand-written Java is permitted under android/ via .hypatia-baseline.json. All new files carry SPDX-License-Identifier: MPL-2.0. TODO(#83 rebase) markers flag the NativeLib interop and JSON-schema seams that sub-PRs #3/#4/#5 (parallel, not yet merged) will finalise. https://claude.ai/code/session_01Gu1JFCZHuBtBhAWPr4sMQw
hyperpolymath
added a commit
that referenced
this pull request
Jun 2, 2026
…ce build (#129) ## `main`'s Rust workspace does not compile — this fixes it `crates/esn` and `crates/lsm` fail to build on `main`. A dependabot bump set `rand = "0.10"` in the workspace `Cargo.toml`, but **`ndarray-rand 0.16` bundles `rand 0.9`** — so two incompatible `rand` crates end up in the tree and the `Normal`/`Bernoulli` distributions and `Rng` trait no longer line up (`E0277`), plus `random()`/`sample()` appear "moved" (`E0599`). **This went undetected because `rust-ci` dies at startup (0 jobs)** — the estate `rust-ci-reusable` is broken (separate, upstream issue in `hyperpolymath/standards`), so nothing actually compiled the workspace in CI. ### Fix Revert `rand` → `0.9` and `rand_distr` → `0.5` (the line `ndarray-rand 0.16` expects). No source changes needed; the committed `Cargo.lock` already resolves rand 0.9, so only `Cargo.toml` drifted. ### Verified locally - `cargo build --workspace` → Finished - `cargo test --workspace` → all green (esn/lsm/bridge/sensors/core/claude-client + proptests + lifecycle/concurrency), 0 failures. This unblocks every open gossamer sub-PR draft (#121–#128), whose workspace verification was failing on this exact pre-existing break. **Recommend merging first.** (`rust-ci` itself will stay red until the `standards` reusable is fixed — tracked separately.) https://claude.ai/code/session_01Gu1JFCZHuBtBhAWPr4sMQw --- _Generated by [Claude Code](https://claude.ai/code/session_01Gu1JFCZHuBtBhAWPr4sMQw)_ Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sub-PR #7 — port the widget triple
Part of the Android Kotlin→Rust/Gossamer migration (epic #83, RFC PR #97, sub-issue #113).
Replaces the home-screen widget Kotlin with thin hand-written Java shims that JNI into the Rust core (
crates/neurophone-android) viaNativeLib.getState()/NativeLib.query(...). The widget is now stateless: every render reads livesalience/descriptionstraight from the Rust core instead of caching in SharedPreferences.Files changed
Ported (Kotlin → Java):
NeurophoneAppWidget.kt→NeurophoneAppWidget.java—AppWidgetProvidershim. Reads core state viaNativeLib.getState()(JSON, parsed defensively) andisRunning(); toggle/refresh/ask actions preserved. Addspublic static requestRefresh(Context)for non-widget callers.NeurophoneWidgetActions.kt→NeurophoneWidgetActions.java—BroadcastReceivershim. The oldPUBLISH_STATE(extras + SharedPreferences) path is gone; receiver now doesFORCE_REFRESH(re-render from core) andACTION_QUERY(one-shotNativeLib.query(...)then refresh).Dropped (owner decision):
NeurophoneWidgetConfigureActivity.kt— deleted, not ported. It had no manifest<activity>entry; its only registration wasandroid:configure=...inres/xml/neurophone_widget_info.xml, now removed along withandroid:widgetFeatures="reconfigurable|configuration_optional"and thewidget_configure_*strings. The widget works with no configure step.Knock-on edits (Kotlin callers of the removed widget API, kept compiling):
NeurophoneService.kt—publishState(...)call sites →requestRefresh(...)(core is now source of truth).BootReceiver.kt— dropped the removedNeurophoneAppWidget.prefs/KEY_RUNNINGread (a core concern now); conservatively no-ops on boot pending a core-persisted autostart flag.AndroidManifest.xml,neurophone_widget_info.xml,strings.xml— configure-activity removal + explanatory comments.Dropped configure-activity note
NeurophoneWidgetConfigureActivityis intentionally not ported per owner decision. No manifest registration existed to remove; theandroid:configurehook in the widget-info XML was the sole binding and has been removed. The single optional question it asked (local_only) is left for the core/UI to own post-migration.What I verified
SPDX-License-Identifier: MPL-2.0; hand-written Java is permitted only underandroid/via the existing.hypatia-baseline.jsonandroid/**carve-out.publishState,prefs,KEY_RUNNING,NeurophoneWidgetConfigureActivity,KEY_LOCAL_ONLY) — remaining hits are comments/docstrings only.widget_state,widget_salience,widget_salience_value,widget_toggle,widget_refresh,widget_query) exist inwidget_neurophone.xml.cargo build --workspace/cargo test --workspacecurrently fail on a pre-existing breakage inesnandlsm(arand/ndarray-randAPI mismatch:no method named random/sample,impl Rng: ndarray_rand::rand::Rngunsatisfied). Reproduced on a cleanorigin/mainwith all PR changes stashed, so it is not introduced here. This PR touches no Rust (android-only diff) and does not regress the workspace.neurophone-androiditself only fails transitively throughesn/lsm.TODOs / risks
TODO(#83 rebase)markers flag the seams that depend on parallel sub-PRs chore(deps): update rand_distr requirement from 0.4 to 0.5 #3/chore(deps): update thiserror requirement from 1.0 to 2.0 #4/chore(deps): update ndarray requirement from 0.15 to 0.17 #5 (not yet merged):NativeLibis still the pre-migration Kotlinobject, so the Java shims useNativeLib.INSTANCE.…; drop.INSTANCEif chore(deps): update rand_distr requirement from 0.4 to 0.5 #3/chore(deps): update thiserror requirement from 1.0 to 2.0 #4/chore(deps): update ndarray requirement from 0.15 to 0.17 #5 republish it as a Java facade.getState()JSON schema (salience,descriptionkeys) is the agreed contract but should be confirmed/tightened on rebase. JNI calls are wrapped intry { } catch (Throwable)so the widget never crashes the launcher against the current stub crate (UnsatisfiedLinkError).BootReceiverautostart and the service's per-tick salience push need the core-side persisted run/state APIs from chore(deps): update rand_distr requirement from 0.4 to 0.5 #3/chore(deps): update thiserror requirement from 1.0 to 2.0 #4/chore(deps): update ndarray requirement from 0.15 to 0.17 #5.Open questions
local_onlypreference be re-surfaced somewhere (settings screen / core config), or is it gone for good?NativeLibshape (Kotlinobjectvs Java facade) so the.INSTANCEinterop can be cleaned up on rebase.https://claude.ai/code/session_01Gu1JFCZHuBtBhAWPr4sMQw
Generated by Claude Code