Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conduit state service #67

Merged
merged 22 commits into from
Nov 27, 2024
Merged

Conduit state service #67

merged 22 commits into from
Nov 27, 2024

Conversation

efryntov
Copy link
Collaborator

No description provided.

Previously, we relied on client ping to decide whether to send an intent to an activity or show a notification if no activity was in the foreground. This worked because activities would unbind when backgrounded. With components like the 'Conduit state service' staying bound, pings can succeed even if all activities are backgrounded. To address this, we now use a method relying on ActivityManager.getRunningAppProcesses to reliably check if the app is in the foreground.
- Move trusted packages to dedicated TrustedPackages class
- Introduce StateUpdate record for JSON serialization
- Add CompositeDisposable to manage all subscriptions
- Remove redundant methods
- Remove unnecessary super calls in lifecycle methods
…ularity

- Centralize package verification logic in `PackageHelper`.
- Add multi-signature support and debug mode for runtime flexibility.
- Update `ConduitStateService` to use `PackageHelper` methods.

Note: A similar class exists in the Psiphon Android project:
https://github.com/Psiphon-Inc/psiphon-android/blob/0be68eb0db96a1b6aa8fb014a39ee933b6f46419/app/src/main/java/com/psiphon3/PackageHelper.java.
Both classes independently verify packages based on signatures and are designed to verify each other.
Add schema version and simplify reporting the running state as a boolean
…clients

Replace silent return with SecurityException when untrusted client attempts to register. This helps clients distinguish trust failures from other binding issues.
Add functionality to load and store runtime-trusted app signatures from server application params, replacing debug-only signature validation. Signatures are stored on disk and loaded at service startup.
Move runtime trusted signatures config initialization from ConduitService to ConduitStateService and rename methods to better reflect their purpose
- Replace clientSubscriptions map with clients map using IBinder as key
- Consolidate state update broadcasting into single subscription
- Add synchronization for client map access using clientsLock

The previous implementation used IConduitStateCallback objects directly as map keys, but since these are AIDL-generated proxy objects, they don't implement equals() properly. This meant identical clients appeared different to the map, leading to duplicate registrations. Using IBinder.asBinder() as the key ensures proper client identity tracking since Binder objects implement equals() correctly.
Changes the client registration mechanism in ConduitService to use IBinder as the key for tracking registered clients instead of using the AIDL interfaces directly. This fixes an issue where clients were being registered multiple times due to AIDL-generated callback interfaces lacking proper equals/hashCode implementations.
- Fix using wrong key (callback vs binder) for client removal in unregisterClient
- Remove unnecessary iterator usage since locks protect modifications
- Add state caching to avoid RxJava subscription for new clients
- Make client error handling and logging consistent across services
@efryntov efryntov marked this pull request as ready for review November 26, 2024 23:28
@efryntov efryntov merged commit 8c61677 into main Nov 27, 2024
2 checks passed
@tmgrask tmgrask deleted the efryntov/conduit-state-service branch December 4, 2024 17:49
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