-
-
Notifications
You must be signed in to change notification settings - Fork 71
feat: aw-sync android support #548
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: master
Are you sure you want to change the base?
Conversation
Phase 1: Library Preparation - Made CLI dependencies (clap, ctrlc) optional in Cargo.toml - Added jni dependency for Android target - Added android module to lib.rs with conditional compilation - Created android.rs with JNI bindings for sync operations: * syncPullAll - pull from all hosts * syncPull - pull from specific host * syncPush - push local data * syncBoth - full bidirectional sync * getSyncDir - get current sync directory path - Made main.rs conditional on 'cli' feature for Android compatibility Phase 2: Android Build Integration - Updated compile-android.sh to build aw-sync alongside aw-server - aw-sync built with --no-default-features to exclude CLI dependencies - Libraries generated for all Android architectures (arm64, x86_64, x86, arm) JNI functions return JSON responses with success/error status. All sync operations use the existing aw-sync Rust API. Sync directory configurable via AW_SYNC_DIR environment variable. Next: Android app integration (phases 4-5) in aw-android repo.
…i feature The SyncMode enum now only derives ValueEnum when the cli feature is enabled. This allows the library to compile without clap on Android.
- Remove unused imports (CString, CStr, get_server_port) - Add explicit Result<String, String> type annotations for closures - Fix hostname parameter to use reference (&hostname) - Explicitly type error messages as &str for JSON serialization - All compilation errors resolved
…ions for Android - Made env parameter mutable in syncPull JNI function - Made get_config_dir() conditional to not compile on Android - Made get_server_config_path() conditional to not compile on Android - These functions use appdirs which doesn't support Android - Android uses environment variables (AW_SYNC_DIR) instead
- Made get_server_port function conditional to not compile on Android - On Android, port is passed as parameter to JNI functions - This avoids dependency on config file reading which is not available on Android
- Added crate-type = ["cdylib", "rlib"] to [lib] section - cdylib is required to generate .so files for Android JNI - rlib allows the library to be used by other Rust code
…ctory structure - Updated JNI function signatures to accept hostname parameter - Parse hostname from JString in syncPullAll, syncPush, syncBoth - Set AW_HOSTNAME environment variable before sync operations - This fixes sync directory structure to use actual device name instead of 'localhost' Hostname is passed from Android Settings.Global.DEVICE_NAME or Build.MODEL
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.
Caution
Changes requested ❌
Reviewed everything up to 6d5086a in 2 minutes and 19 seconds. Click for details.
- Reviewed
392lines of code in9files - Skipped
0files when reviewing. - Skipped posting
3draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. aw-sync/Cargo.toml:27
- Draft comment:
Optional CLI dependencies are now gated under the 'cli' feature. Verify they are correctly included/excluded for Android builds. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
2. compile-android.sh:75
- Draft comment:
Appending to RUSTFLAGS using '+=' can be brittle. Consider quoting the output of the clang command to ensure proper handling across environments. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
3. compile-android.sh:100
- Draft comment:
Using '--no-default-features' for the aw-sync build excludes CLI dependencies intentionally. Confirm that this configuration doesn’t unintentionally remove functionality needed on Android. - Reason this comment was not posted:
Confidence changes required:50%<= threshold50%None
Workflow ID: wflow_N6yvymWn6it8tVF3
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
Greptile SummaryThis PR adds Android support to Key changes:
Minor issues:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Android as Android App
participant JNI as JNI Interface (android.rs)
participant Client as AwClient
participant Sync as Sync Operations
participant FS as File System (Sync Dir)
Note over Android,FS: Pull All Hosts Flow
Android->>JNI: syncPullAll(port, hostname)
JNI->>JNI: Convert JString to String
JNI->>Client: get_client(port)
Client-->>JNI: AwClient instance
JNI->>Sync: pull_all(client)
Sync->>FS: get_remotes()
FS-->>Sync: List of host directories
loop For each host
Sync->>FS: Read host's .db files
Sync->>Client: Import events from host
end
Sync-->>JNI: Success/Error
JNI->>Android: JSON response
Note over Android,FS: Push Flow
Android->>JNI: syncPush(port, hostname)
JNI->>JNI: Convert JString to String
JNI->>Client: get_client(port)
Client-->>JNI: AwClient instance
JNI->>Sync: push_with_hostname(client, hostname)
Sync->>FS: Create/update sync_dir/hostname/*
Sync->>Client: Export local buckets
Sync->>FS: Write events to .db files
Sync-->>JNI: Success/Error
JNI->>Android: JSON response
Note over Android,FS: Full Sync Flow
Android->>JNI: syncBoth(port, hostname)
JNI->>Sync: pull_all(client)
Sync-->>JNI: Pull complete
JNI->>Sync: push_with_hostname(client, hostname)
Sync-->>JNI: Push complete
JNI->>Android: JSON response
|
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.
Additional Comments (3)
-
aw-sync/src/android.rs, line 43 (link)style: Setting
AW_HOSTNAMEhas no effect - no code reads this environment variable. The sync operations use the hostname parameter passed directly to functions, not from environment. Consider removing theseset_varcalls insyncPullAll,syncPush, andsyncBoth. -
aw-sync/src/android.rs, line 12 (link)style: Panicking on string creation failure. Consider returning an error instead since JNI operations can fail.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
-
aw-sync/src/android.rs, line 59 (link)style: Unnecessary type annotation creates verbose code in multiple places.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
9 files reviewed, 3 comments
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #548 +/- ##
==========================================
- Coverage 70.81% 67.82% -3.00%
==========================================
Files 51 54 +3
Lines 2916 3136 +220
==========================================
+ Hits 2065 2127 +62
- Misses 851 1009 +158 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
c174a79 to
9567a1a
Compare
ErikBjare
left a comment
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.
Great job on this, this is really going to make things next-level
|
Super excited for this feature 💯 |
9567a1a to
9f42d3a
Compare
- Created push_with_hostname() function that accepts hostname parameter - Updated JNI functions to use push_with_hostname() with passed hostname - This ensures sync directory uses actual device name from Android - Fixes issue where 'localhost' was used despite passing device name The hostname is now passed directly from Android through JNI to the sync functions, bypassing the client's hostname entirely.
9f42d3a to
9c1bd01
Compare
|
This is ready to merge :) |
Important
Adds Android support to
aw-syncwith JNI bindings and updates the build process for Android targets.aw-sync/src/android.rsfor JNI bindings to support Android.syncPullAll,syncPull,syncPush,syncBoth, andgetSyncDirfor Android.compile-android.shto buildaw-syncfor Android without CLI features.Cargo.tomlto includejnidependency for Android and make CLI dependencies optional.push_with_hostname()insync_wrapper.rsandlib.rsfor hostname-specific sync operations.dirs.rsandutil.rsto conditionally compile Android-specific code.This description was created by
for 6d5086a. You can customize this summary. It will automatically update as commits are pushed.