Skip to content

Conversation

@Kaleb-Dimitrio
Copy link

Summary

Fixed multiple artifacts failure due to inability adjusting to different Android versions and undefined variables.

Changes Made

1. notificationHistory.py

  • Problem: Unreachable code after continue statement
  • Problem: package_map variable undefined causing NameError
  • Solution: Removed unreachable code and properly initialized package_map from protobuf string_pool
  • Impact: Artifact now successfully parses notification history protobuf files

2. deviceHealthServices_Battery.py (Turbo Battery & Bluetooth)

  • Problem: time_offset variable undefined causing NameError
  • Solution: Replaced with 'UTC' string literal (consistent with ALEAPP v2 architecture)
  • Impact: Both Turbo Battery and Turbo Bluetooth artifacts now execute without errors

3. keepNotes.py

  • Problem: Missing FTS table text_search_note_content_content causing crash
  • Problem: Wrong column reference tree_entity.text (should be list_item.text)
  • Solution: Added schema validation with HasField() check and dynamic query building
  • Impact: Works with both FTS-enabled and non-FTS databases, graceful fallback to list_item.text

4. googleMessages.py

  • Problem: Missing columns file_size_bytes and local_cache_path in older DB versions
  • Solution: Dynamic query building with PRAGMA table_info validation
  • Impact: Compatible with all Google Messages database versions, returns "N/A" for missing columns

5. FacebookMessenger.py

  • Problem: Missing optional columns snippet and reactions in different Facebook Messenger DB versions
  • Solution: Schema introspection with PRAGMA table_info for messages and message_reactions tables
  • Impact: Handles msys_database format variations across Facebook Messenger versions gracefully

Technical Approach

All fixes follow a consistent pattern:

  1. Schema Introspection: Use PRAGMA table_info(table_name) to check available columns
  2. Conditional Query Building: Build dynamic SQL with f-strings based on column availability
  3. Graceful Degradation: Return "N/A" or NULL for missing data instead of crashing
  4. Backward Compatibility: Maintain full functionality for databases with complete schema

Testing

  • Tested with databases missing optional columns
  • Verified backward compatibility with complete databases
  • No functionality regression - all features preserved
  • Graceful error messages for skipped files

Impact

  • Robustness: Artifacts no longer crash on schema variations
  • Compatibility: Works across multiple Android and app versions
  • User Experience: Partial data extraction > complete failure
  • Maintainability: Consistent pattern across all fixed artifacts

Files Changed

  • scripts/artifacts/notificationHistory.py
  • scripts/artifacts/deviceHealthServices_Battery.py
  • scripts/artifacts/keepNotes.py
  • scripts/artifacts/googleMessages.py
  • scripts/artifacts/FacebookMessenger.py

- notificationHistory: Fix unreachable code and initialize package_map from string_pool
- deviceHealthServices_Battery: Replace undefined time_offset with 'UTC'
- keepNotes: Add FTS table validation and fallback to list_item.text
- googleMessages: Add schema validation for optional columns (file_size_bytes, local_cache_path)
- FacebookMessenger: Add schema validation for optional columns (snippet, reactions)

Fixes database compatibility issues across different Android versions.
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