summaryrefslogtreecommitdiff
path: root/jni/com_android_providers_media_FuseDaemon.cpp
diff options
context:
space:
mode:
authorAlessio Balsini <balsini@google.com>2022-05-12 17:23:21 +0100
committerAlessio Balsini <balsini@google.com>2022-05-13 11:56:36 +0100
commit48ca90a8ba83d795f7845dab2300acda8a0c4c2b (patch)
treed19b59d790bad033abe523c2bdb3e48e83efed42 /jni/com_android_providers_media_FuseDaemon.cpp
parent82bb048fa3bbfbc6da2603e6b092c6f9ffc9fa06 (diff)
downloadMediaProvider-48ca90a8ba83d795f7845dab2300acda8a0c4c2b.tar.gz
MediaProvider to report if FUSE passthrough is enabled
Relying on the persist.sys.fuse.passthrough.enable system property to check if FUSE passthrough is enabled is not a reliable solution, as shown by mixed builds with GSI. The problem arises when an underlying system not supporting FUSE passthrough (e.g., Android R) runs with an Android S+ GSI which wants to use FUSE passthrough, thus has persist.sys.fuse.passthrough.enable set to true. Android works fine as MediaProvider (FuseDaemon) catches the exception that the kernel does not support FUSE passthrough, but the Android S+ tests assume that FUSE passthrough is enabled because of the system property. This change extends the MediaProvider hidden API with a call to test if the FUSE passthrough feature is being used or not by the FUSE daemon. Bug: 207733510 Test: android.scopedstorage.cts.device.ScopedStorageDeviceTest Signed-off-by: Alessio Balsini <balsini@google.com> Change-Id: Ie31be07d97a1f9ad4402f7f44490c924e883a0a9
Diffstat (limited to 'jni/com_android_providers_media_FuseDaemon.cpp')
-rw-r--r--jni/com_android_providers_media_FuseDaemon.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/jni/com_android_providers_media_FuseDaemon.cpp b/jni/com_android_providers_media_FuseDaemon.cpp
index 78b193949..0215fa8e9 100644
--- a/jni/com_android_providers_media_FuseDaemon.cpp
+++ b/jni/com_android_providers_media_FuseDaemon.cpp
@@ -131,6 +131,15 @@ jboolean com_android_providers_media_FuseDaemon_should_open_with_fuse(JNIEnv* en
return JNI_FALSE;
}
+jboolean com_android_providers_media_FuseDaemon_uses_fuse_passthrough(JNIEnv* env, jobject self,
+ jlong java_daemon) {
+ fuse::FuseDaemon* const daemon = reinterpret_cast<fuse::FuseDaemon*>(java_daemon);
+ if (daemon) {
+ return daemon->UsesFusePassthrough();
+ }
+ return JNI_FALSE;
+}
+
void com_android_providers_media_FuseDaemon_invalidate_fuse_dentry_cache(JNIEnv* env, jobject self,
jlong java_daemon,
jstring java_path) {
@@ -182,6 +191,8 @@ const JNINativeMethod methods[] = {
reinterpret_cast<void*>(com_android_providers_media_FuseDaemon_delete)},
{"native_should_open_with_fuse", "(JLjava/lang/String;ZI)Z",
reinterpret_cast<void*>(com_android_providers_media_FuseDaemon_should_open_with_fuse)},
+ {"native_uses_fuse_passthrough", "(J)Z",
+ reinterpret_cast<void*>(com_android_providers_media_FuseDaemon_uses_fuse_passthrough)},
{"native_is_fuse_thread", "()Z",
reinterpret_cast<void*>(com_android_providers_media_FuseDaemon_is_fuse_thread)},
{"native_is_started", "(J)Z",