Disable bind mounts for data and obb if FUSE BPF is available

FUSE BPF aims at achieving comparable performance to bind-mounts, with
the flexibility of FUSE.
Disable data and obb bind-mounts in favor of the FUSE filesystem if the
system implements the feature.

Bug: 202785178
Test: mount | grep obb
Signed-off-by: Alessio Balsini <balsini@google.com>
Change-Id: Ia8b289b84542125831a857b559bb6f93afbee494
diff --git a/model/EmulatedVolume.cpp b/model/EmulatedVolume.cpp
index b686437..7c8a4e0 100644
--- a/model/EmulatedVolume.cpp
+++ b/model/EmulatedVolume.cpp
@@ -49,6 +49,7 @@
     mRawPath = rawPath;
     mLabel = "emulated";
     mFuseMounted = false;
+    mFuseBpfEnabled = base::GetBoolProperty(kFuseBpfEnabled, false);
     mUseSdcardFs = IsSdcardfsUsed();
     mAppDataIsolationEnabled = base::GetBoolProperty(kVoldAppDataIsolationEnabled, false);
 }
@@ -60,6 +61,7 @@
     mRawPath = rawPath;
     mLabel = fsUuid;
     mFuseMounted = false;
+    mFuseBpfEnabled = base::GetBoolProperty(kFuseBpfEnabled, false);
     mUseSdcardFs = IsSdcardfsUsed();
     mAppDataIsolationEnabled = base::GetBoolProperty(kVoldAppDataIsolationEnabled, false);
 }
@@ -359,10 +361,12 @@
             }
         }
 
-        // Only do the bind-mounts when we know for sure the FUSE daemon can resolve the path.
-        res = mountFuseBindMounts();
-        if (res != OK) {
-            return res;
+        if (!mFuseBpfEnabled) {
+            // Only do the bind-mounts when we know for sure the FUSE daemon can resolve the path.
+            res = mountFuseBindMounts();
+            if (res != OK) {
+                return res;
+            }
         }
 
         ConfigureReadAheadForFuse(GetFuseMountPathForUser(user_id, label), 256u);
@@ -416,9 +420,11 @@
     if (mFuseMounted) {
         std::string label = getLabel();
 
-        // Ignoring unmount return status because we do want to try to unmount
-        // the rest cleanly.
-        unmountFuseBindMounts();
+        if (!mFuseBpfEnabled) {
+            // Ignoring unmount return status because we do want to try to
+            // unmount the rest cleanly.
+            unmountFuseBindMounts();
+        }
 
         if (UnmountUserFuse(userId, getInternalPath(), label) != OK) {
             PLOG(INFO) << "UnmountUserFuse failed on emulated fuse volume";
diff --git a/model/EmulatedVolume.h b/model/EmulatedVolume.h
index 1d2385d..0f39fbd 100644
--- a/model/EmulatedVolume.h
+++ b/model/EmulatedVolume.h
@@ -64,6 +64,9 @@
     /* Whether we mounted FUSE for this volume */
     bool mFuseMounted;
 
+    /* Whether the FUSE BPF feature is enabled */
+    bool mFuseBpfEnabled;
+
     /* Whether to use sdcardfs for this volume */
     bool mUseSdcardFs;