Skip to content

External companion app for remote control (using broadcast intents) #452

@Daksh777

Description

@Daksh777

Hi! I really enjoy using Simple Time Tracker and wanted to share an idea I am thinking to work on.

I want to build a separate Android app (a companion app) that lets you control Simple Time Tracker from a web browser on your computer. The companion app would sit between your browser and Simple Time Tracker, passing commands back and forth using the broadcast intent API that the app already supports.

I am opening this issue to share the idea, ask a few questions about the existing API, and make sure I am not missing anything before I start building.

Related issues and PRs

PR #373 adds a small web server directly inside Simple Time Tracker. That is a great approach but it requires changes to the app itself and the INTERNET permission. As discussed in the PR, the concern is not that local HTTP is inherently unsafe, but that adding INTERNET permission to the main app changes its trust surface for everyone, including F-Droid users who would get the permission in the manifest even though the server code is play-flavor only. You noted in the PR discussion that a separate plugin app would be the cleaner workaround:

"There is one workaround... Is to have a separate app, like a plugin, that would be installed separately and would have internet permission... time tracker pass data to plugin app, plugin app calls web api."

That is exactly what I am trying to build here. The main app stays exactly as it is. Users who want the web interface install the companion app separately and explicitly opt in. Users who do not want it, including F-Droid users, are completely unaffected.

How it would work

The companion app would do two things:

  1. Receive commands from the web browser and send the matching broadcast intent to Simple Time Tracker
  2. Listen for the events that Simple Time Tracker already broadcasts (EVENT_STARTED_ACTIVITY, EVENT_STOPPED_ACTIVITY, EVENT_COMPLETED_GOAL) and forward those to the browser so the web UI stays up to date.

The web dashboard would let you start and stop activities, add past records, edit comments, and see what is currently running, etc.

There are a few options for getting commands from the browser to the companion app running on the phone. I am still deciding between them, but here is what I am considering:

  • Option 1: Direct local HTTP server in the companion app. The companion app runs a small server on the local network. The browser sends requests to it directly over Wi-Fi. This is the same model as PR feat: Add REST API and Web UI for remote time tracking #373, but the INTERNET permission lives in the companion app instead of the main app, so the main app's privacy guarantee is preserved. The downside is it only works when the phone and computer are on the same network.

  • Option 2: Self-hosted relay server. A small server you run yourself (on a home computer or a cheap VPS) acts as the go-between. The companion app and the browser both connect to it. This works over the internet, and your data only passes through infrastructure you control.

  • Option 3: Firebase Cloud Messaging (or a similar push service). The companion app listens for push messages from Firebase, and the web dashboard sends commands through Firebase. This makes setup easier since you do not need to run your own server. However, it does mean that the names of your activities and whatever commands you send pass through Google's servers. This has the same kind of privacy concern that was raised in the PR feat: Add REST API and Web UI for remote time tracking #373 discussion, so I would only offer this as a clearly optional mode for users who are comfortable with it, not as the default.

I plan to support Option 1 and Option 2 from the start. Option 3 would be opt-in only, clearly labelled, and off by default.

Some things I want to ask:

  1. Is there any way to query the list of all configured activities via a broadcast intent? Right now I can only learn about activities by listening to events as they happen. A way to ask what activities exist would make the web UI much better from the start. I noticed the internal WearCommunicationAPI already has queryActivities() for the Wear OS integration, but that is not accessible from outside the app via broadcast.

  2. Is there a way to query what is currently running? Similar to above, I can track state by listening to start and stop events, but a direct query would be more reliable, especially on app restart or reconnect. Again, queryCurrentActivities() exists internally for Wear OS but is not exposed externally.

  3. Would you be open to adding two optional query intents, something like ACTION_QUERY_ACTIVITIES and ACTION_QUERY_RUNNING, that respond with a broadcast containing the answer? If yes, I am happy to submit a small PR for that. One clean way to handle this would be to use a signature-level permission for the response broadcast, which you also mentioned in the PR discussion as a way two apps signed with the same key can share data safely.

Happy to hear any concerns or suggestions. Thanks for building such a reliable app.

@av1m I would also really appreciate your inputs and help into this if @Razeeman approves this instead of 373!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions