Skip to content

core: change Android tmp dir, make it configurable #2605

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

Merged
merged 1 commit into from
Jul 7, 2025

Conversation

julianoes
Copy link
Collaborator

@julianoes julianoes commented Jul 4, 2025

When Android tries to access the default /tmp temporary directory it crashes due to missing permissions.

As a workaround, let's try to use /data/local/tmp instead, and if that doesn't work, make it configurable within JNI for the user.

Android apps can now optionally override the temp path from JNI like:


extern "C" char* mavsdk_temp_path;
mavsdk_temp_path = strdup("/data/data/com.example.app/cache");

Hopefully fixes mavlink/MAVSDK-Java#206.

When Android tries to access the default `/tmp` temporary directory it
crashes due to missing permissions.

As a workaround, let's try to use `/data/local/tmp` instead, and if that
doesn't work, make it configurable within JNI for the user.
Copy link

sonarqubecloud bot commented Jul 4, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
C Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Copy link
Collaborator

@JonasVautherin JonasVautherin left a comment

Choose a reason for hiding this comment

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

Are you sure that /data/local/tmp works at all? On newer versions of Android I would bet that it doesn't. Security has been tightened a lot, now we need to explicitly ask permission to the user in order to access files outside the app storage.

Without asking permission, it's possible to use the app storage, but the path depends on the app, so it should be configurable.

The title says "make it configurable". Does it do that? I don't see how it can be configured 🤔 😅

@julianoes
Copy link
Collaborator Author

@JonasVautherin should be configurable as mentioned in the PR description ⬆️, at link time.

@julianoes julianoes merged commit 6f094a0 into main Jul 7, 2025
40 of 41 checks passed
@julianoes julianoes deleted the pr-android-temp-dir branch July 7, 2025 21:04
@julianoes
Copy link
Collaborator Author

Going to merge it and then try it out.

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.

Crash "path /tmp is not a directory" on mavsdk-server 3.0.0
2 participants