Skip to content

Modernization and CameraX Migration#2

Open
dandinu wants to merge 21 commits intoDanielBarnett714:masterfrom
dandinu:master
Open

Modernization and CameraX Migration#2
dandinu wants to merge 21 commits intoDanielBarnett714:masterfrom
dandinu:master

Conversation

@dandinu
Copy link
Copy Markdown

@dandinu dandinu commented Nov 26, 2025

Overview

This PR modernizes the Bloodhound codebase from its original 2017 implementation to work with modern Android versions, with a focus on migrating from the deprecated Camera API to CameraX.

Major Changes

🎥 CameraX Migration (Primary Focus)

  • Replaced deprecated android.hardware.Camera API with CameraX

    • Eliminated the hacky 1x1 pixel SurfaceView overlay workaround
    • Implemented proper lifecycle-aware camera management via ServiceCameraLifecycleOwner
    • Created CameraXCaptureManager for camera operations
    • Improved battery efficiency and capture reliability
    • Better compatibility with Android 12+
  • Technical Implementation

    • Added CameraX dependencies (camera-core, camera-camera2, camera-lifecycle)
    • Implemented custom LifecycleOwner for service context (CameraX requires lifecycle support)
    • Refactored photo capture sequence: back camera → front camera → 60s delay → repeat
    • Removed all Camera, SurfaceView, SurfaceHolder, and WindowManager code from BloodhoundService

📱 Android SDK Updates

  • Upgraded from SDK 25 (Android 7.1) → SDK 34 (Android 14)
  • Updated minSdkVersion from 22 → 24 (Android 7.0+)
  • Migrated from Support Library to AndroidX
  • Updated all core dependencies:
    • appcompat → 1.6.1
    • material → 1.10.0
    • recyclerview → 1.3.2
    • constraintlayout → 2.1.4

🔧 Build System Modernization

  • Updated Gradle from 3.3 → 8.8
  • Migrated to Gradle 8.x declarative syntax
  • Updated Android Gradle Plugin to 8.2.0
  • Fixed deprecated API usage throughout codebase
  • Updated wrapper to use Gradle 8.8 distribution

🛠️ Code Quality & Compatibility

  • Fixed Android 12+ compatibility issues (foreground service restrictions, permissions)
  • Replaced deprecated android.support.test imports with androidx.test
  • Updated test dependencies (JUnit, Espresso)
  • Fixed namespace declaration in build.gradle
  • Resolved compilation errors from API changes

📚 Documentation

  • Updated README.md with:

    • Modern build instructions
    • CameraX migration notes
    • Detailed troubleshooting section for camera issues
    • ADB commands for debugging
    • Storage architecture documentation
    • Technology stack updates
  • Created comprehensive CLAUDE.md for AI assistant guidance

Testing Recommendations

Manual Testing Required

  1. Camera Capture Sequence

    • Long-press paw icon → "Start Full Tracking"
    • Verify photos are captured in Pictures/ directory
    • Check ADB logs: adb logcat | grep CameraXCaptureManager
  2. Nextcloud Integration

    • Verify photo uploads to Pictures
    • Test remote activation via check file
  3. Permissions

    • Test all permission flows on Android 12+ devices
    • Verify battery optimization exclusion

Automated Testing

./gradlew test                    # Unit tests
./gradlew connectedAndroidTest    # Instrumented tests
./gradlew lint                    # Code quality checks

Breaking Changes

None - this PR maintains backward compatibility with existing functionality while modernizing the implementation.

Known Limitations (Unchanged)

  • Nextcloud credentials still stored in plaintext (noted in README as temporary limitation)
  • Background service restrictions on Android 12+ may affect reliability
  • SMS restrictions on newer Android versions

Migration Benefits

  • Better Performance: CameraX eliminates preview surface overhead
  • Modern API: Uses Google's recommended camera framework
  • Reliability: Proper lifecycle management prevents resource leaks
  • Maintainability: Cleaner codebase without deprecated APIs
  • Future-Proof: Compatible with Android 14+ and beyond

Files Changed

  • New Files:

    • ServiceCameraLifecycleOwner.java
    • CameraXCaptureManager.java
    • CLAUDE.md
  • Modified Files:

    • build.gradle - Dependency updates, CameraX integration
    • build.gradle - Gradle plugin updates
    • gradle-wrapper.properties - Gradle 8.8
    • gradle.properties - AndroidX migration flags
    • BloodhoundService.java - CameraX refactor
    • AndroidManifest.xml - Updated permissions
    • README.md - Comprehensive documentation updates
    • Test files updated to androidx imports

Acknowledgments

This modernization effort preserves the original 2017 design and intent while making the codebase compatible with current Android standards and best practices.

dandinu and others added 18 commits November 26, 2025 22:09
…d adjust exported attributes for activities and receivers
- Created `fragment_dashboard.xml` for the dashboard layout including tracking status, Nextcloud status, quick stats, and recent activity sections.
- Created `fragment_history.xml` for the history layout with filter chips and a RecyclerView for displaying tracking history.
- Added `item_history_event.xml` and `item_tracking_event.xml` for individual event item layouts in the history and tracking sections respectively.
- Introduced a bottom navigation menu in `bottom_nav_menu.xml` for easy navigation between Dashboard, History, and Settings.
- Defined navigation graph in `nav_graph.xml` to manage fragment transitions.
- Updated color resources in `colors.xml` to align with Material Design 3 dark theme.
- Expanded string resources in `strings.xml` for new UI elements and navigation.
- Established new styles in `themes.xml` for the application theme based on Material Design 3.
- Created `preferences_root.xml` for app settings, including tracking and Nextcloud preferences.
New features in this release:
- Photo browsing feature with developer tools access
- Screenshot capture feature with MediaProjection support
- Real-time tracking duration display
- Screenshot capture toggle in preferences

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Introduced DataBrowserActivity to browse all captured data types (photos, locations, recordings).
- Implemented CaptureAdapter to manage the display of various data types in a unified timeline.
- Created CaptureItem class to represent different data types with appropriate metadata.
- Added layout files for DataBrowserActivity and item views for locations and recordings.
- Updated AndroidManifest.xml to declare the new DataBrowserActivity.
- Modified SettingsFragment to link to the new Data Browser instead of the old Photo Browser.
- Added drawable resources for icons used in the Data Browser.
- Enhanced string resources for better user experience in the Data Browser.
- Updated file paths for sharing recordings.
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.

1 participant