Skip to content

Fix Android 14+ limited permission deselection not notifying Flutter - #1357

Merged
AlexV525 merged 3 commits into
mainfrom
copilot/fix-image-video-selection-bug
May 14, 2026
Merged

Fix Android 14+ limited permission deselection not notifying Flutter#1357
AlexV525 merged 3 commits into
mainfrom
copilot/fix-image-video-selection-bug

Conversation

Copilot AI commented Dec 6, 2025

Copy link
Copy Markdown
Contributor

On Android 14+ with limited photo access (READ_MEDIA_VISUAL_USER_SELECTED), deselecting photos via presentLimited() doesn't notify the Flutter layer, even though MediaStore updates correctly.

Changes

  • Added onLimitedSelectionChanged() callback to PermissionsListener: Default implementation ensures backward compatibility
  • Modified PermissionDelegate34.handlePermissionResult(): Invokes callback when CODE_REQUEST_LIMITED completes
  • Implemented callback in PhotoManagerPlugin: Sends change notification via existing notifyChannel to trigger Flutter listeners

Effect

Apps using PhotoManager.addChangeCallback() now receive notifications when users modify their limited photo selection:

PhotoManager.addChangeCallback((call) {
  if (call.method == 'change') {
    // Now triggered when presentLimited() completes with selection changes
    refreshAssetList();
  }
});

await PhotoManager.presentLimited();  // User deselects photos -> callback fires

Testing

Requires Android 14+ device with limited photo permission to verify deselection triggers Flutter callbacks.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug report] 受限权限时选择部分图片视频,只能增加不能反减</issue_title>
<issue_description>### Version

3.7.2

Platforms

Android

Device Model

Meizu 21

flutter info

部分选择相册时,反选不生效,从android日志都能看出cursor的反选是生效的,但flutter层还是只增不减

How to reproduce?

比如:先选两个图,再打开系统选择,只选择一个,flutter层依然保持两个

Logs

Example code (optional)

Contact

No response</issue_description>

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

@fluttercandies-dev **AI Summary:** 用户报告Android端选择图片/视频时,反选功能失效,导致只能增加选择,无法减少已选内容。即使底层数据正确,Flutter层也未正确反映反选操作。

Custom agent used: PR Agent
An Agent that helps to implement features and fixes based on issues.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

- Add onLimitedSelectionChanged() callback to PermissionsListener interface
- Call this callback when CODE_REQUEST_LIMITED permission request completes
- Implement callback in PhotoManagerPlugin to send update notification to Flutter
- Update CHANGELOG.md with fix description

Co-authored-by: AlexV525 <15884415+AlexV525@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix image and video selection issue in limited permissions Fix Android 14+ limited permission deselection not notifying Flutter Dec 6, 2025
Copilot AI requested a review from AlexV525 December 6, 2025 12:55
@AlexV525

Copy link
Copy Markdown
Member

@copilot Merge from latest and see if further changes are needed.

…eo-selection-bug

# Conflicts:
#	CHANGELOG.md

Co-authored-by: AlexV525 <15884415+AlexV525@users.noreply.github.com>

Copilot AI commented May 14, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Merge from latest and see if further changes are needed.

Merged latest origin/main into this branch and resolved the merge conflict in CHANGELOG.md in commit 908f006. I rechecked the diff against origin/main; no additional code changes were needed beyond the existing PR changes.

Copilot AI 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.

Pull request overview

Fixes Android 14+ limited photo permission flow so that deselecting items in the system picker via presentLimited() propagates a change notification to Flutter, allowing apps to refresh asset lists.

Changes:

  • Added a default onLimitedSelectionChanged() method to the PermissionsListener interface.
  • Invoked the new callback from PermissionDelegate34.handlePermissionResult() when CODE_REQUEST_LIMITED completes.
  • Implemented the callback in PhotoManagerPlugin to dispatch an "update" event through notifyChannel.onOuterChange.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
CHANGELOG.md Documents the fix under the Unreleased Fixes section.
android/.../permission/PermissionsListener.kt Adds onLimitedSelectionChanged() with a default no-op for backward compatibility.
android/.../permission/impl/PermissionDelegate34.kt Triggers the new callback after the limited-selection picker completes.
android/.../core/PhotoManagerPlugin.kt Sends a Flutter-side change notification when the limited selection changes.

@AlexV525
AlexV525 marked this pull request as ready for review May 14, 2026 10:23
@AlexV525
AlexV525 requested a review from CaiJingLong as a code owner May 14, 2026 10:23
@github-actions

Copy link
Copy Markdown

Download apk from here for 67612ad

@AlexV525
AlexV525 merged commit c7b0fb4 into main May 14, 2026
16 checks passed
@AlexV525
AlexV525 deleted the copilot/fix-image-video-selection-bug branch May 14, 2026 10:46
@AlexV525 AlexV525 linked an issue May 14, 2026 that may be closed by this pull request
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.

[Bug report] 受限权限时选择部分图片视频,只能增加不能反减 [Bug report] addChangeCallback is not working on Android 15

3 participants