-
Notifications
You must be signed in to change notification settings - Fork 565
feat: add product flavors and TorProvider abstraction #508
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
base: main
Are you sure you want to change the base?
feat: add product flavors and TorProvider abstraction #508
Conversation
Introduces build flavors to separate Tor functionality from the standard build, reducing APK size for users who don't need Tor. - Creates `standard` and `tor` product flavors. - The `standard` flavor is the default, lightweight build. - The `tor` flavor includes the Arti (Tor) dependency and is identified by the `.tor` application ID suffix. - Adds a `TorProvider` interface and a `TorProviderFactory` to abstract Tor implementation details between flavors. Prepares architecture for optional Tor support to reduce APK size from 142MB to ~4-5MB for standard builds Related to permissionlesstech#454
This commit refactors the Tor integration by introducing a `TorProvider` interface and creating separate implementations for 'tor' and 'standard' product flavors. - The original `TorManager` singleton has been moved into `RealTorProvider` for the 'tor' flavor. - A no-op `StandardTorProvider` is introduced for the 'standard' flavor, which reports Tor as unavailable. - A `TorProviderFactory` is used to create the appropriate provider at runtime based on the build variant.
Replaced direct calls to the static `TorManager` with an instance obtained from `TorProviderFactory`. This change allows for different Tor implementations based on build flavors, improving modularity and abstracting the Tor provider logic. Updated `BitchatApplication`, `ChatHeader`, `OkHttpProvider`, and `AboutSheet` to use the new factory pattern for accessing Tor functionalities.
- Split ProGuard rules: base, standard-specific, tor-specific - Move Arti/Guardian Project rules to proguard-tor.pro - Update CI/CD workflow to build both flavors - Add separate artifact uploads for each flavor - Add descriptive release notes template CI now builds both standard (~4-5MB) and tor (~140MB) APKs." resolves permissionlesstech#454
Extracts the repeated network connection reset logic into a new private function `resetNetworkConnections()`.
This change also replaces direct `_statusFlow.value = ...` assignments with the safer `_statusFlow.update { ... }` function to prevent race conditions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
82171ce to
a65f028
Compare
Optimizes CI workflow: - Parallel matrix builds (4 runners instead of sequential) - Conditional tor lint only when app/src/tor/ changes in PRs - Merged test+lint jobs to reduce setup overhead Reduces CI time by ~50% (8-11 min vs 18-26 min)
a65f028 to
1a89ac2
Compare
SummaryThis PR introduces product flavors to support optional Tor integration and optimizes the CI pipeline for efficiency. It addresses APK size concerns (#454 ) while maintaining feature parity across builds. Key Achievements
APK Size Results (from CI artifacts)
Size reduction: Standard release is 94% smaller than tor release (3.53 MB vs 60 MB) Relation to #507 This PR serves as a temporary workaround for #507 by providing two distribution options:
The TorProvider abstraction is designed to support Phase 2: Dynamic Feature Modules, which will allow:
Files Changed Core Architecture:
UI Updates:
Build Configuration:
CI/CD:
Testing ✅ CI passes with optimized workflow✅ APK sizes verified from CI artifacts✅ Both flavors build successfully✅ Standard flavor correctly disables Tor UI elements✅ Tor flavor maintains full functionality Screenshot:
|
|
@moehamade could you help me understand how this solves #507 ? we do not want to release a version without tor on play store, and maybe even not on github. tor should be a must when dealing with nostr relays, especially when location channels are used. |
|
I already finished the feature but I didn't update the PR. I thought we're not doing that anymore... I managed to compile rust library and place it under Android project. I now have working Android app with Fresh Arti library directly compiled from source. What I did in this PR was simply provide the necessary abstractions so I can create a Java Native Interface (JNI) so I can easily bridge it with the custom library since It's written in Rust. And the product flavors was just a quick way for us to release without Tor. But as it is no it doesn't solve our issue. But this requires a discussion and there is no direct way to contact you, I included 2 compiled .so files for each architecture (Arm and x86_64 ). So in order to reduce size by half, should I only include the Arm library? or will people require support for emulators as well? We could provide both libraries for debug builds and only Arm for release since people wouldn't be able to chat on emulators anyway. The other stuff we should discuss is what features do we really need from the Arti library? Do we need support to access .onion sites? because such stuff will still increase the size of the compiled library, and I should know what features we want and what features I can safely remove to reduce app size. Let me know. |
|
@moehamade appreciate it! let's talk directly on signal if you don't mind. could you send me your signal username here or to bitchat-dev at pm .me? |
I think we should be good with releasing only the arm library, yes
this sounds like a great plan
this is very considerate of you, thank you. we should compare what the actual file size differences are for these options. I've been thinking about file-transfers using onion services before, it could be a really cool way for direct phone to phone connections in the future. |


Introduces build flavors to separate Tor functionality from the standard build, reducing APK size for users who don't need Tor.
standardandtorproduct flavors.standardflavor is the default, lightweight build.torflavor includes the Arti (Tor) dependency and is identified by the.torapplication ID suffix.TorProviderinterface and aTorProviderFactoryto abstract Tor implementation details between flavors.Prepares architecture for optional Tor support to reduce APK size from 142MB to ~4-5MB for standard builds
Closes #454
Description
Checklist