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

Wrapping Context.openFileInput/openFileOutput #1842

Open
romtsn opened this issue Dec 13, 2021 · 1 comment
Open

Wrapping Context.openFileInput/openFileOutput #1842

romtsn opened this issue Dec 13, 2021 · 1 comment
Labels
enhancement New feature or request performance Performance API issues Platform: Android

Comments

@romtsn
Copy link
Member

romtsn commented Dec 13, 2021

At the moment we can't simply wrap those with SentryFileInputStream.Factory.create(openFileInput(filename), filename), because the filename has to be made up using Context.getFilesDir() or be the absolute file path, and in this case it's just a simple name. Android doesn't allow to create an instance of FIOS with just a simple name.

In other words, we'd need to change the code to SentryFileInputStream.Factory.create(openFileInput(filename), new File(context.getFilesDir(), filename)).

There are 3 options we can go with about that:

  • Disable instrumentation for Context.openFileInput/Context.openFileOutput
  • Use reflection and retrieve the path from the delegate. This is usually an absolute path, hence, creating a new File/FIOS will work and Android won't complain.
  • Create a subclass of SentryFileInputStream in the sentry-android-core module that will make up the filename properly using Context. A problem is that we need to access Context.
@romtsn
Copy link
Member Author

romtsn commented Dec 13, 2021

Let's go with option 1 first, and then ship a new version of the java SDK, meanwhile start implementing option 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request performance Performance API issues Platform: Android
Projects
Status: Backlog
Development

No branches or pull requests

1 participant