Skip to content

bug: process lifecycle hooks for hardware wallets never fire #1845

Open

Description

@jvsena42

What happened?

App.observeAppForeground() never receives a lifecycle event, so the hardware-wallet hooks it drives never run:

  • HwWalletRepo.onAppBackgrounded() → JadeRepo.onAppBackgrounded(), which releases an open Jade Bluetooth link 30 s after the app goes to the background.
  • HwWalletRepo.onAppForegrounded() → JadeRepo / TrezorRepo.onAppForegrounded(), which cancels that pending release and auto-reconnects a known Bluetooth device when the app comes back.

The observer is attached to ProcessLifecycleOwner (App.kt:70-80). ProcessLifecycleOwner only follows activities once ProcessLifecycleInitializer has attached it, and that initializer runs from androidx.startup's InitializationProvider. AndroidManifest.xml:231-235 removes that provider (tools:node="remove", there since d17f43255). Nothing calls AppInitializer instead, so the registry stays at INITIALIZED, and ON_START and ON_STOP never fire.

This is the only ProcessLifecycleOwner user on master. It came up in review of #1838, which uses a started-activity counter in App.CurrentActivity (hasStartedActivity) for the same reason.

Expected behavior

Backgrounding the app releases an idle Jade Bluetooth link after 30 s. Returning to the app cancels that release and auto-reconnects a known Bluetooth Jade or Trezor.

Steps to Reproduce

  1. Pair a Jade over Bluetooth and leave it connected.
  2. Send Bitkit to the background for more than 30 s.
  3. The log never shows Releasing the Jade bluetooth link while the app is in the background, and the link stays open.
  4. Disconnect the device, then return to the app. The log never shows Attempting Jade bluetooth auto-reconnect after app foregrounded (or the Trezor equivalent).

Logs / Screenshots / Recordings

Not captured. Found by reading the code and checking the lifecycle-process 2.10.0 sources and the merged devDebug manifest, which has no InitializationProvider and no ProcessLifecycleInitializer. Not yet confirmed on a device with a hardware wallet.

Bitkit Version

master 816f08ed7

Device / OS

All. Comes from the manifest, not the device.

Reproducibility

Always

Additional context

Two possible fixes:

  • Keep the provider and remove only the initializers the app doesn't want (for example androidx.work.WorkManagerInitializer as a tools:node="remove" meta-data entry), so ProcessLifecycleInitializer runs again. Check first why the whole provider was removed.
  • Drive these hooks from App.CurrentActivity.hasStartedActivity once fix: exit instead of releasing a detached node #1838 merges. That has no 700 ms debounce for configuration changes.

Activity

  1. self-assigned this
    on Nov 10, 2026
  2. added theissue type on Nov 10, 2026
  3. added this to the 3.2.0 milestone on Nov 10, 2026
  4. ovitrif commented on Nov 10, 2026

    @ovitrif
    Collaborator

    Triage: in 3.2.0 at 📋 To do. The Jade and Trezor background release and auto-reconnect it describes are on master and ship in 3.2.0, so a fix belongs in this release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions