Skip to content

fix(location): open map with approximate or one-time location permission - #6786

Open
rapterjet2004 wants to merge 1 commit into
masterfrom
issue-6781-fix-location-permissions
Open

rapterjet2004 wants to merge 1 commit into
masterfrom
issue-6781-fix-location-permissions

Conversation

@rapterjet2004

Copy link
Copy Markdown
Contributor

Share location only opened the map when precise location was granted. The chat never requested the runtime permission, so "Ask every time" could never be granted, and both the chat check and the location picker required ACCESS_FINE_LOCATION.

Now the permission is requested from the chat (fine and coarse, so the user can choose on API 31+) and either grant is accepted. The location services check uses LocationManagerCompat.isLocationEnabled, and getLastKnownLocation is guarded against SecurityException.

Assisted-by: Claude Code:claude-opus-5-5

🖼️ Screenshots

Screenshot 2026-09-28 at 2 26 29 PM

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔖 Capability is checked or not needed
  • 🔙 Backport requests are created or not needed: /backport to stable-xx.x
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Share location only opened the map when precise location was granted.
The chat never requested the runtime permission, so "Ask every time"
could never be granted, and both the chat check and the location picker
required ACCESS_FINE_LOCATION.

Now the permission is requested from the chat (fine and coarse, so the
user can choose on API 31+) and either grant is accepted. The location
services check uses LocationManagerCompat.isLocationEnabled, and
getLastKnownLocation is guarded against SecurityException.

Assisted-by: Claude Code:claude-opus-5-5

Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
@rapterjet2004 rapterjet2004 added the 3. to review Waiting for reviews label Sep 28, 2026
@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

ChatActivity now checks whether location services are enabled and requests fine and coarse location permissions when needed. It opens the location picker if either permission is granted. The picker also accepts either permission, and its last-known-location lookup catches SecurityException, logs a warning, and returns null.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🟡 Moderate · up to bd29a

Users who grant approximate or one-time location can now open the location-sharing map. Users who deny location permission, or who have device location turned off, still cannot open the map to pick a place by hand, which the linked issue asks for. Address these cases or explicitly accept them before merging.

Security Architecture Review

Security architecture risk: 🔵 Low · up to bd29a

Approximate or one-time location permission can now open the picker. The reviewed flow still requires a location grant and a separate action to share coordinates. No introduced security vulnerability was established, but permission-revocation behavior remains uncertain.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The identified added reachability is a coarse-only or newly granted user opening the local picker, not an automatic location send or a new cross-service entrypoint. A later explicit share can transmit selected coordinates to the chat service and, for an unnamed selection, to the geocoder.

Trust Boundaries and Controls

  • observed — The app checks the OS location grant before picker launch and again before the picker’s initial location registration. Provider calls are guarded against permission failures; the callback does not itself share location.

Resilience and Maintainability Implications

  • inferred — The picker removes location updates on stop but does not visibly recheck permission or clear cached position on resume. The listener lifecycle was not changed by this PR; whether an active listener receives callbacks after revocation remains unverified.

Hardening Proposals

  • proposed — Verify revocation and one-time-permission behavior across stop and resume; if cached device position can outlive the grant, recheck permission and clear that position before using it. This is a hardening proposal, not an established PR-introduced finding.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The change meets the approximate, one-time, and coarse-permission cases in [#6781]. ChatActivity requests fine and coarse permissions, and LocationPickerScreen accepts any granted permission. Howe… Update the no-grant path for [#6781] so that LocationPickerActivity opens after the permission request is denied or not granted. Keep location updates and last-known-location access optional, so the picker remains usable without location …
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: allowing the location map to open with approximate or one-time location permission.
Description check ✅ Passed The description explains the issue and implementation, includes a screenshot, identifies AI assistance, and provides the checklist. The TODO section is missing, and most checklist items remain uncheck…
Out of Scope Changes check ✅ Passed The changes in ChatActivity, LocationPickerScreen, and PlatformPermissionUtilImpl all support [#6781]. They update location-service checks, permission requests, permission acceptance, and safe l…
Full details: Linked Issues check

Explanation

The change meets the approximate, one-time, and coarse-permission cases in [#6781]. ChatActivity requests fine and coarse permissions, and LocationPickerScreen accepts any granted permission. However, [#6781] also requires the map to open when location permission is not granted. The permission-result handler opens the picker only when at least one permission is granted. It shows a dialog or snackbar after denial. The map therefore remains closed in the no-permission case.

Resolution

Update the no-grant path for [#6781] so that LocationPickerActivity opens after the permission request is denied or not granted. Keep location updates and last-known-location access optional, so the picker remains usable without location permission.

  • Fix all pre-merge checks with AI

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 471577c4-f450-4006-9dfe-e91c2cb432d5

📥 Commits

Reviewing files that changed from the base of the PR and between f704b95 and bd29afe.

📒 Files selected for processing (3)
  • app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt
  • app/src/main/java/com/nextcloud/talk/location/components/LocationPickerScreen.kt
  • app/src/main/java/com/nextcloud/talk/utils/permissions/PlatformPermissionUtilImpl.kt

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

} else if (requestCode == REQUEST_LOCATION_PERMISSION) {
if (grantResults.any { it == PackageManager.PERMISSION_GRANTED }) {
openLocationPicker()
} else if (!shouldShowRequestPermissionRationale(Manifest.permission.ACCESS_FINE_LOCATION)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Open the picker after the user denies location permission.

If the user selects “Don’t allow,” neither permission is granted. This branch shows denial UI and never calls openLocationPicker(). The linked issue requires manual map selection without location permission. Open the picker after denial and treat the permission as necessary only for the optional current-position feature. Android also recommends allowing users to continue without granting a permission when the feature can work without it. (developer.android.com)

val isGpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)

if (!isGpsEnabled) {
if (!LocationManagerCompat.isLocationEnabled(locationManager)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Open the picker when location services are disabled.

If the user disables device location services, this branch shows a settings dialog instead of opening the picker. The user cannot select a location manually, although the map does not require a device location fix. Open the picker in this case. Keep the settings action available for users who want their current position. LocationManagerCompat.isLocationEnabled reports whether device location is enabled. (developer.android.com)

@github-actions

Copy link
Copy Markdown
Contributor

Codacy

Lint

TypemasterPR
Warnings138138
Errors1818

SpotBugs

CategoryBaseNew
Bad practice77
Correctness1111
Dodgy code4545
Internationalization33
Malicious code vulnerability33
Performance88
Security1111
Total8888

@github-actions

Copy link
Copy Markdown
Contributor

📱 QA build

Download app-qa-debug.apk
QR code Open the QR code for this download
Commit bd29afe
Version 6786
Available until 7 days after this build

The QA build installs alongside a released Nextcloud app, so you can keep
using your existing install while testing.

Downloading the file requires a GitHub account, so open this link on the
device you want to test on, or transfer the APK to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews AI assisted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Location permission is too greedy

1 participant