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

File atachment crash #8908

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

toshanmugaraj
Copy link

@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

(#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
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

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.

4 participants