ActivityWatch / ActivityWatch/aw-android

BackgroundService not starting when Usage Access is granted during onboarding (requires re-launch)

Offen
#170 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Kotlin
Sterne
265
Forks
57
Ø Merge
2 T. 21 Std.
Gemergte PRs (30 T.)
19

Beschreibung

## Summary

When a user grants the Usage Access permission **during** the onboarding flow (via the Permissions screen), the `BackgroundService` and `aw-server-rust` do not start after FINISH is tapped. The user sees the home screen but no tracking is active.

## Steps to Reproduce

1. Fresh install of aw-android
2. Launch app → OnboardingActivity → Permissions screen
3. Grant Usage Access permission (either via the system settings dialog or programmatically)
4. Tap FINISH
5. App returns to home screen

**Expected**: BackgroundService starts, aw-server-rust comes up on 127.0.0.1:5600, sync scheduler starts.

**Actual**: Process gets frozen/backgrounded. No BackgroundService, no aw-server-rust, no sync scheduler. Logcat shows:
```
ActivityManager: freezing net.activitywatch.android.debug
```

## Workaround

Re-launching the app after granting usage access works correctly. On second launch, `MainActivity` detects that usage access is now granted and starts BackgroundService normally.

## Root Cause (Suspected)

In `MainActivity`, the check `if (firstTime || !isUsageAllowed())` runs at activity creation. When usage access is granted _during_ the onboarding flow (after `MainActivity` has already started `OnboardingActivity`), the `OnboardingActivity.FINISH` callback doesn't re-check permissions and doesn't start the service — it just finishes.

Suggested fix: in `OnboardingActivity`'s FINISH callback (or the activity result handler in `MainActivity`), call `startService(BackgroundService)` explicitly if usage access is now granted.

## Environment

- Tested via Android emulator (Pixel 6, android-34, x86_64) on aw-android built from PR #139
- Debug APK, installed via `adb install`

## Related

- Discovered during [aw-android sync dogfood](https://github.com/ErikBjare/bob/issues/aw-android-sync-dogfood)

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.