Skip to content

chore(android): port widget triple to Java JNI shims, drop configure activity (#83)#128

Open
hyperpolymath wants to merge 2 commits into
mainfrom
chore/gossamer-widgets
Open

chore(android): port widget triple to Java JNI shims, drop configure activity (#83)#128
hyperpolymath wants to merge 2 commits into
mainfrom
chore/gossamer-widgets

Conversation

@hyperpolymath
Copy link
Copy Markdown
Owner

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) via NativeLib.getState() / NativeLib.query(...). The widget is now stateless: every render reads live salience / description straight from the Rust core instead of caching in SharedPreferences.

Files changed

Ported (Kotlin → Java):

  • NeurophoneAppWidget.ktNeurophoneAppWidget.javaAppWidgetProvider shim. Reads core state via NativeLib.getState() (JSON, parsed defensively) and isRunning(); toggle/refresh/ask actions preserved. Adds public static requestRefresh(Context) for non-widget callers.
  • NeurophoneWidgetActions.ktNeurophoneWidgetActions.javaBroadcastReceiver shim. The old PUBLISH_STATE (extras + SharedPreferences) path is gone; receiver now does FORCE_REFRESH (re-render from core) and ACTION_QUERY (one-shot NativeLib.query(...) then refresh).

Dropped (owner decision):

  • NeurophoneWidgetConfigureActivity.ktdeleted, 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 android:widgetFeatures="reconfigurable|configuration_optional" and the widget_configure_* strings. The widget works with no configure step.

Knock-on edits (Kotlin callers of the removed widget API, kept compiling):

  • NeurophoneService.ktpublishState(...) call sites → requestRefresh(...) (core is now source of truth).
  • BootReceiver.kt — dropped the removed NeurophoneAppWidget.prefs/KEY_RUNNING read (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

NeurophoneWidgetConfigureActivity is intentionally not ported per owner decision. No manifest registration existed to remove; the android:configure hook 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

  • All new Java files carry SPDX-License-Identifier: MPL-2.0; hand-written Java is permitted only under android/ via the existing .hypatia-baseline.json android/** carve-out.
  • No live code references any removed symbol (publishState, prefs, KEY_RUNNING, NeurophoneWidgetConfigureActivity, KEY_LOCAL_ONLY) — remaining hits are comments/docstrings only.
  • All referenced widget layout IDs (widget_state, widget_salience, widget_salience_value, widget_toggle, widget_refresh, widget_query) exist in widget_neurophone.xml.
  • XML well-formedness checked for the manifest, widget-info, and strings.
  • Rust workspace: cargo build --workspace / cargo test --workspace currently fail on a pre-existing breakage in esn and lsm (a rand / ndarray-rand API mismatch: no method named random/sample, impl Rng: ndarray_rand::rand::Rng unsatisfied). Reproduced on a clean origin/main with 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-android itself only fails transitively through esn/lsm.

TODOs / risks

Open questions

  • Should the dropped configure activity's local_only preference be re-surfaced somewhere (settings screen / core config), or is it gone for good?
  • Confirm the final NativeLib shape (Kotlin object vs Java facade) so the .INSTANCE interop can be cleaned up on rebase.

Marked DRAFT: depends on parallel sub-PRs #3/#4/#5 (base off main, structure assumed, TODO(#83 rebase) markers).

https://claude.ai/code/session_01Gu1JFCZHuBtBhAWPr4sMQw


Generated by Claude Code

…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>
@hyperpolymath hyperpolymath marked this pull request as ready for review June 3, 2026 21:07
@hyperpolymath hyperpolymath enabled auto-merge (squash) June 3, 2026 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants