deltalab-android icon indicating copy to clipboard operation
deltalab-android copied to clipboard

Implement foreground service for location sharing to comply with Google Play requirements

Open Copilot opened this issue 3 months ago • 9 comments

Implement foreground notification for location sharing - COMPLETED

  • [x] Review current location sharing implementation
  • [x] Remove ACCESS_BACKGROUND_LOCATION permission request
  • [x] Update LocationBackgroundService to show foreground notification
  • [x] Add location notification channel to NotificationCenter
  • [x] Update strings for location notification
  • [x] Add FOREGROUND_SERVICE_LOCATION permission for Android 14+
  • [x] Update DcLocationManager to start service as foreground service
  • [x] Fix all code review feedback
  • [x] Add FLAG_IMMUTABLE to IntentUtils
  • [x] Ensure thread-safe foreground service initialization
  • [x] Fix service initialization order
  • [x] Ensure foreground requirements met even on error
  • [x] Fix PermissionsBuilder method chaining compilation error
  • [x] Fix foreground service for Android 14+ using ServiceCompat.startForeground with foregroundServiceType
  • [x] Add NETWORK_PROVIDER fallback for better location coverage
  • [x] Use LocationManagerCompat with LocationRequestCompat for proper location updates on modern Android
  • [x] Fix LocationListenerCompat compilation error
  • [x] Code review passed
  • [x] Ready for testing and deployment

Summary of Changes

This PR restores location sharing functionality by implementing a foreground service with notification instead of requesting background location access, as per Google's current requirements.

Key Changes:

  1. Removed ACCESS_BACKGROUND_LOCATION permission request (Android Q+)
  2. Added FOREGROUND_SERVICE_LOCATION permission (Android 14+)
  3. Updated LocationBackgroundService to display a persistent foreground notification
  4. Added notification channel CH_LOCATION for location sharing with low importance
  5. Updated DcLocationManager to start the service using startForegroundService()
  6. Simplified permission rationale message (removed mention of background access)
  7. Added notification strings for location sharing
  8. Implemented thread-safe foreground service lifecycle with AtomicBoolean
  9. Fixed service binding checks to use OR logic
  10. Added proper cleanup with stopForeground() in onDestroy()
  11. Added FLAG_IMMUTABLE() helper to IntentUtils
  12. Fixed PermissionsBuilder method chaining (request() and execute() must be separate calls)
  13. Fixed Android 14+ foreground service using ServiceCompat.startForeground() with FOREGROUND_SERVICE_TYPE_LOCATION
  14. Added NETWORK_PROVIDER as fallback for better location coverage when GPS is unavailable
  15. Migrated to LocationManagerCompat and LocationRequestCompat for better compatibility with modern Android
  16. Added provider availability check before requesting location updates
  17. Changed listener to implement LocationListenerCompat for compatibility with LocationManagerCompat API

Fixes ArcaneChat/android#70

Original prompt

This section details on the original issue you should resolve

<issue_title>allow to share location again</issue_title> <issue_description>in the past it was possible to share location via "location streaming" option in chat, but google now recommends to have permanent foreground notification while the location is being streamed instead of use the "background location access", implement this so location data is accessed properly</issue_description>

Comments on the Issue (you are @copilot in this section)

  • Fixes ArcaneChat/android#70

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar Nov 24 '25 20:11 Copilot