Skip to content

feat(android): add configurable network access setting#144

Open
lucletoffe wants to merge 2 commits intoActivityWatch:masterfrom
lucletoffe:feature/configurable-host
Open

feat(android): add configurable network access setting#144
lucletoffe wants to merge 2 commits intoActivityWatch:masterfrom
lucletoffe:feature/configurable-host

Conversation

@lucletoffe
Copy link

@lucletoffe lucletoffe commented Feb 24, 2026

Summary

Adds a user-facing "Allow network access" toggle so the embedded server can optionally bind to 0.0.0.0 instead of 127.0.0.1, letting other devices on the local network connect to the ActivityWatch API.

Off by default. Enabling shows a security warning dialog.

Changes

Settings UI:

  • New SettingsActivity with a Material switch, accessible from the action bar Settings button (which previously showed a "not yet implemented" snackbar)
  • Security warning dialog on enable, explaining the API has no authentication
  • Toast prompting the user to restart the app for the change to take effect

Plumbing:

  • AWPreferences: new isNetworkAccessEnabled / setNetworkAccessEnabled methods
  • RustInterface: startServer() and startServerTask() now accept a host parameter
  • MainActivity: reads the preference on startup, passes "0.0.0.0" or "127.0.0.1" to the server
  • strings.xml: setting labels and warning text
  • AndroidManifest.xml: registered SettingsActivity

aw-server-rust submodule:

Security

The toggle is opt-in with a clear warning dialog. The warning mentions:

  • The ActivityWatch API has no authentication
  • Anyone on the same network can read and modify activity data
  • Only recommended on trusted networks (e.g., a VPN like Tailscale)

Notes

  • The setting requires an app restart to take effect (the server starts once in onCreate). I kept it simple rather than adding server restart logic.
  • CI will fail until the aw-server-rust PR is merged and the submodule pointer is updated to a commit that exists upstream. Happy to rebase once that's in.
  • Screenshots pending — I don't have an Android build environment set up yet, will add them once I can build the APK.

Closes #121, relates to #107


This is my first PR on the project. If there's anything I should do differently (commit structure, code style, approach), let me know — happy to adjust.


Important

Adds a user-configurable network access setting to allow the embedded server to bind to all network interfaces, with a security warning and requiring app restart.

  • Behavior:
    • Adds a toggle in SettingsActivity to allow network access, binding the server to 0.0.0.0 instead of 127.0.0.1.
    • Displays a security warning dialog when enabling network access.
    • Requires app restart for changes to take effect.
  • Settings and Preferences:
    • AWPreferences: Adds isNetworkAccessEnabled and setNetworkAccessEnabled methods.
    • MainActivity: Reads network access preference and starts server with appropriate host.
  • Server Interface:
    • RustInterface: Updates startServer() and startServerTask() to accept a host parameter.
  • UI and Resources:
    • Adds SettingsActivity to AndroidManifest.xml.
    • Updates strings.xml with new labels and warning messages.
    • Creates activity_settings.xml layout for settings UI.
  • Submodule Update:
    • Updates aw-server-rust submodule to include JNI changes for host parameter.

This description was created by Ellipsis for c68cd3d. You can customize this summary. It will automatically update as commits are pushed.

Add a Settings screen with a toggle to allow network access to the
embedded ActivityWatch server. When enabled, the server binds to
0.0.0.0 instead of 127.0.0.1, allowing other devices on the local
network to connect.

The setting is off by default. Enabling it shows a security warning
dialog explaining the risks (no authentication on the API, data
exposed to the network). The change takes effect on app restart.

This also wires up the previously-unimplemented Settings action bar
button to open the new Settings screen.

The aw-server-rust submodule is updated to accept a host parameter
in the JNI startServer() call instead of using a hardcoded address.

Closes ActivityWatch#121, closes ActivityWatch#107
Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed everything up to c68cd3d in 10 seconds. Click for details.
  • Reviewed 222 lines of code in 8 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.

Workflow ID: wflow_KwTYz1tLqtlRe2VO

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@greptile-apps
Copy link

greptile-apps bot commented Feb 24, 2026

Greptile Summary

This PR adds a user-configurable "Allow network access" setting that enables the embedded ActivityWatch server to bind to 0.0.0.0 instead of 127.0.0.1, allowing devices on the local network to connect to the API.

Key changes:

  • Added new SettingsActivity with Material switch for network access toggle
  • Security warning dialog shown when enabling, clearly explaining lack of authentication
  • Preference stored in AWPreferences with secure default (disabled)
  • Server host parameter passed through RustInterface.startServerTask() to native code
  • Settings button in action bar now opens the new settings screen
  • Requires app restart for changes to take effect (documented in toast message)

Implementation quality:

  • Follows existing code patterns and Android conventions
  • Security-conscious design with opt-in behavior and prominent warnings
  • Clean separation of concerns between UI, preferences, and server initialization
  • WebView correctly continues using 127.0.0.1 for local connections while server binds to 0.0.0.0 when enabled

Confidence Score: 5/5

  • Safe to merge - well-implemented security feature with proper warnings and secure defaults
  • Clean implementation following Android best practices, secure by default with opt-in behavior, thorough security warnings, and proper separation of concerns. No logical errors or security vulnerabilities found.
  • No files require special attention

Important Files Changed

Filename Overview
mobile/src/main/java/net/activitywatch/android/AWPreferences.kt Added network access preference methods with secure defaults
mobile/src/main/java/net/activitywatch/android/MainActivity.kt Reads preference and passes host to server, opens SettingsActivity from action bar
mobile/src/main/java/net/activitywatch/android/RustInterface.kt Added host parameter to startServer methods with localhost default
mobile/src/main/java/net/activitywatch/android/SettingsActivity.kt New settings screen with network access toggle and security warning dialog

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User clicks Settings button] --> B[SettingsActivity opens]
    B --> C{Network access<br/>switch toggled?}
    C -->|Enable| D[Show security warning dialog]
    C -->|Disable| E[Save preference: false]
    D -->|User clicks Enable| F[Save preference: true]
    D -->|User cancels| G[Revert switch to off]
    F --> H[Show restart notice toast]
    E --> H
    H --> I[User restarts app]
    I --> J[MainActivity.onCreate]
    J --> K{Check preference:<br/>isNetworkAccessEnabled?}
    K -->|true| L[host = 0.0.0.0]
    K -->|false| M[host = 127.0.0.1]
    L --> N[RustInterface.startServerTask]
    M --> N
    N --> O[Native startServer called<br/>with host parameter]
    O --> P{Binding address}
    P -->|0.0.0.0| Q[Server accepts<br/>external connections]
    P -->|127.0.0.1| R[Server localhost only]
Loading

Last reviewed commit: c68cd3d

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

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.

Option to change host address

1 participant