Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix file attachment crash #8908

Merged
merged 2 commits into from
Jan 13, 2025
Merged

Conversation

toshanmugaraj
Copy link
Contributor

@toshanmugaraj toshanmugaraj commented Sep 17, 2024

Type of change

  • Feature
  • [x ] Bugfix
  • Technical
  • Other :

Content

Exception is handled when there is issue on granting permission.

Motivation and context

Steps to reproduce

Having Work / Personal MDM workspace container.
Restriction is there for file sharing from Work to Personal container.
Install and open the element android in the Work container.
Try to attach any file in the Personal workspace.
The app crashes when trying to grant permission

Closes #8907

Screenshots / GIFs

Tests

Tested devices

  • [x ] Physical
  • Emulator
  • OS version(s):

Checklist

@CLAassistant
Copy link

CLAassistant commented Sep 25, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Thanks. Can you sign the CLA please so that I may be able to merge this PR?

context.grantUriPermission(context.applicationContext.packageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION)
} catch (e: SecurityException) {
// Handle the exception, e.g., log it or notify the user
Timber.w("Picker", "Failed to grant URI permission for $uri: ${e.message}")
Copy link
Member

Choose a reason for hiding this comment

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

If the permission is not granted, I guess the issue will appear later, when the app will try to access the file? What will happen in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use MDM, and having two containers, Personal space and Work space. Space is restricted with certain policies for accessing file in between.

Even though the explicit call grantUriPermission fails, the intent with flag Intent.FLAG_GRANT_READ_URI_PERMISSION succeed.

This ability to share files using intents with FLAG_GRANT_READ_URI_PERMISSION while grantUriPermission fails is likely a result of MDM policies that enforce strict separation between work and personal profiles. These policies are designed to protect user data while still allowing some level of interaction through standard Android intent mechanisms

Copy link
Member

Choose a reason for hiding this comment

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

OK, thanks for the clarification!

@bmarty bmarty added the Z-NextRelease For issues and PRs which should be included in the NextRelease. label Jan 13, 2025
@bmarty bmarty changed the title File atachment crash Fix file attachment crash Jan 13, 2025
@bmarty bmarty merged commit d97f69b into element-hq:develop Jan 13, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-NextRelease For issues and PRs which should be included in the NextRelease.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

File attachment crash due to MDM permission
4 participants