Skip to content

Conversation

@mdmohsin7
Copy link
Member

No description provided.

@mdmohsin7 mdmohsin7 marked this pull request as draft December 25, 2025 11:13
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces changes to improve battery life related to the background location service. It correctly prevents the foreground service from starting if the user has disabled location tracking in settings. However, it also disables wake and Wi-Fi locks for the foreground task. While this is intended to save battery, a critical concern has been raised that it may render the background location tracking feature unreliable, as the operating system may put the device to sleep, preventing the service from running as scheduled. The recommendation is to revert the lock changes to ensure the feature's core functionality is not compromised.

Comment on lines +132 to +133
allowWakeLock: false,
allowWifiLock: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Disabling allowWakeLock and allowWifiLock is a good step for battery optimization, but it might critically impact the reliability of background location tracking.

  • With allowWakeLock: false, the device's CPU may sleep when the screen is off. This can prevent the periodic task from running on schedule, or the device may go back to sleep before Geolocator.getCurrentPosition() can get a location fix. This would make background location tracking unreliable.

  • With allowWifiLock: false, the Wi-Fi radio may be turned off by the OS to save power. This can degrade location accuracy and increase the time needed to get a location, as it would have to rely solely on GPS or cellular networks.

Given that this foreground service is for periodic location tracking, these changes could cause the feature to fail silently in the background. It's recommended to keep these enabled to ensure the service functions as expected. If battery consumption is a major concern, perhaps the interval of the task could be increased, or this feature could be made more explicitly opt-in for users with a clear warning about battery usage.

Suggested change
allowWakeLock: false,
allowWifiLock: false,
allowWakeLock: true,
allowWifiLock: true

@mdmohsin7 mdmohsin7 marked this pull request as ready for review December 28, 2025 07:56
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.

2 participants