Remove PartitionMounter. am: af3713ec4c
am: cc16a4a49c

Change-Id: I3eec9dbf6c614429376f8ad89640fa42aa0bbc4e
diff --git a/VintfObject.cpp b/VintfObject.cpp
index 5231183..f39b933 100644
--- a/VintfObject.cpp
+++ b/VintfObject.cpp
@@ -82,12 +82,9 @@
 }
 
 VintfObject::VintfObject(std::unique_ptr<FileSystem>&& fileSystem,
-                         std::unique_ptr<details::PartitionMounter>&& partitionMounter,
                          std::unique_ptr<details::ObjectFactory<RuntimeInfo>>&& runtimeInfoFactory,
                          std::unique_ptr<details::PropertyFetcher>&& propertyFetcher)
     : mFileSystem(fileSystem ? std::move(fileSystem) : createDefaultFileSystem()),
-      mPartitionMounter(partitionMounter ? std::move(partitionMounter)
-                                         : std::make_unique<details::PartitionMounter>()),
       mRuntimeInfoFactory(runtimeInfoFactory
                               ? std::move(runtimeInfoFactory)
                               : std::make_unique<details::ObjectFactory<RuntimeInfo>>()),
@@ -460,19 +457,11 @@
 }
 
 template <typename T, typename GetFunction>
-static status_t getMissing(const std::string& msg, const std::shared_ptr<T>& pkg, bool mount,
-                           std::function<status_t(void)> mountFunction,
-                           std::shared_ptr<const T>* updated, GetFunction getFunction,
-                           std::string* error) {
+static status_t getMissing(const std::shared_ptr<T>& pkg, std::shared_ptr<const T>* updated,
+                           GetFunction getFunction) {
     if (pkg != nullptr) {
         *updated = pkg;
     } else {
-        if (mount) {
-            status_t mountStatus = mountFunction();
-            if (mountStatus != OK) {
-                appendLine(error, "warning: mount " + msg + " failed: " + strerror(-mountStatus));
-            }
-        }
         *updated = getFunction();
     }
     return OK;
@@ -502,8 +491,8 @@
 // Checks given compatibility info against info on the device. If no
 // compatability info is given then the device info will be checked against
 // itself.
-int32_t VintfObject::checkCompatibility(const std::vector<std::string>& xmls, bool mount,
-                                        std::string* error, CheckFlags::Type flags) {
+int32_t VintfObject::checkCompatibility(const std::vector<std::string>& xmls, std::string* error,
+                                        CheckFlags::Type flags) {
     status_t status;
     ParseStatus parseStatus;
     PackageInfo pkg; // All information from package.
@@ -532,45 +521,25 @@
     }
 
     // get missing info from device
-    // use functions instead of std::bind because std::bind doesn't work well with mock objects
-    auto mountSystem = [this] { return this->mPartitionMounter->mountSystem(); };
-    auto mountVendor = [this] { return this->mPartitionMounter->mountVendor(); };
     if ((status = getMissing(
-             "system", pkg.fwk.manifest, mount, mountSystem, &updated.fwk.manifest,
-             std::bind(&VintfObject::getFrameworkHalManifest, this, true /* skipCache */),
-             error)) != OK) {
-        return status;
-    }
-    if ((status =
-             getMissing("vendor", pkg.dev.manifest, mount, mountVendor, &updated.dev.manifest,
-                        std::bind(&VintfObject::getDeviceHalManifest, this, true /* skipCache */),
-                        error)) != OK) {
+             pkg.fwk.manifest, &updated.fwk.manifest,
+             std::bind(&VintfObject::getFrameworkHalManifest, this, true /* skipCache */))) != OK) {
         return status;
     }
     if ((status = getMissing(
-             "system", pkg.fwk.matrix, mount, mountSystem, &updated.fwk.matrix,
-             std::bind(&VintfObject::getFrameworkCompatibilityMatrix, this, true /* skipCache */),
-             error)) != OK) {
+             pkg.dev.manifest, &updated.dev.manifest,
+             std::bind(&VintfObject::getDeviceHalManifest, this, true /* skipCache */))) != OK) {
         return status;
     }
-    if ((status = getMissing(
-             "vendor", pkg.dev.matrix, mount, mountVendor, &updated.dev.matrix,
-             std::bind(&VintfObject::getDeviceCompatibilityMatrix, this, true /* skipCache */),
-             error)) != OK) {
+    if ((status = getMissing(pkg.fwk.matrix, &updated.fwk.matrix,
+                             std::bind(&VintfObject::getFrameworkCompatibilityMatrix, this,
+                                       true /* skipCache */))) != OK) {
         return status;
     }
-
-    if (mount) {
-        status_t umountStatus = mPartitionMounter->umountSystem();
-        if (umountStatus != OK) {
-            appendLine(error,
-                       std::string{"warning: umount system failed: "} + strerror(-umountStatus));
-        }
-        umountStatus = mPartitionMounter->umountVendor();
-        if (umountStatus != OK) {
-            appendLine(error,
-                       std::string{"warning: umount vendor failed: "} + strerror(-umountStatus));
-        }
+    if ((status = getMissing(pkg.dev.matrix, &updated.dev.matrix,
+                             std::bind(&VintfObject::getDeviceCompatibilityMatrix, this,
+                                       true /* skipCache */))) != OK) {
+        return status;
     }
 
     if (flags.isRuntimeInfoEnabled()) {
@@ -669,11 +638,6 @@
     return GetInstance()->checkCompatibility(xmls, error, flags);
 }
 
-int32_t VintfObject::checkCompatibility(const std::vector<std::string>& xmls, std::string* error,
-                                        CheckFlags::Type flags) {
-    return checkCompatibility(xmls, false /* mount */, error, flags);
-}
-
 bool VintfObject::IsHalDeprecated(const MatrixHal& oldMatrixHal,
                                   const CompatibilityMatrix& targetMatrix,
                                   const ListInstances& listInstances, std::string* error) {
@@ -827,10 +791,6 @@
     return mFileSystem;
 }
 
-const std::unique_ptr<PartitionMounter>& VintfObject::getPartitionMounter() {
-    return mPartitionMounter;
-}
-
 const std::unique_ptr<PropertyFetcher>& VintfObject::getPropertyFetcher() {
     return mPropertyFetcher;
 }
diff --git a/VintfObjectRecovery.cpp b/VintfObjectRecovery.cpp
index 3303980..9cfb5a9 100644
--- a/VintfObjectRecovery.cpp
+++ b/VintfObjectRecovery.cpp
@@ -16,11 +16,14 @@
 
 #include "VintfObjectRecovery.h"
 
-#include <fs_mgr.h>
 #include <sys/mount.h>
 #include <sys/stat.h>
 
+#include <set>
+
+#include <android-base/logging.h>
 #include <android-base/strings.h>
+#include <fs_mgr.h>
 
 #include "utils.h"
 
@@ -31,6 +34,7 @@
 using android::base::StartsWith;
 using FstabMgr = std::unique_ptr<struct fstab, decltype(&fs_mgr_free_fstab)>;
 
+static const char* const kMountImageRootDir = "/mnt";
 static const char* const kSystemImageRootDir = "/mnt/system";
 static const char* const kVendorImageRootDir = "/mnt/vendor";
 
@@ -39,9 +43,13 @@
 
     fstab_rec* rec = fs_mgr_get_entry_for_mount_point(fstab.get(), path);
     if (rec == nullptr) {
-        return UNKNOWN_ERROR;
+        LOG(WARNING) << "No mount point for " << path;
+        return NAME_NOT_FOUND;
     }
     int result = mount(rec->blk_device, mountPoint, rec->fs_type, rec->flags, rec->fs_options);
+    if (result != 0) {
+        PLOG(WARNING) << "Can't mount " << path;
+    }
     return result == 0 ? OK : -errno;
 }
 
@@ -49,30 +57,46 @@
     return FstabMgr{fs_mgr_read_fstab_default(), &fs_mgr_free_fstab};
 }
 
-class RecoveryPartitionMounter : public PartitionMounter {
+class RecoveryPartitionMounter {
    public:
     RecoveryPartitionMounter() : fstab_(defaultFstabMgr()) {}
-    status_t mountSystem() const override {
-        if (!fstab_) return UNKNOWN_ERROR;
-        if (fs_mgr_get_entry_for_mount_point(fstab_.get(), "/system") == nullptr) {
-            return mount("/", kSystemImageRootDir);
-        } else {
-            return mount("/system", kSystemImageRootDir);
+    ~RecoveryPartitionMounter() {
+        for (const auto& pair : mounted_) {
+            umount(pair.second.c_str());
         }
+        mounted_.clear();
     }
 
-    status_t mountVendor() const override { return mount("/vendor", kVendorImageRootDir); }
-
-    status_t umountSystem() const override { return umount(kSystemImageRootDir); }
-
-    status_t umountVendor() const override { return umount(kVendorImageRootDir); }
+    status_t mount(const std::string& path) {
+        if (path == "/system") {
+            if (!fstab_) return UNKNOWN_ERROR;
+            if (fs_mgr_get_entry_for_mount_point(fstab_.get(), "/system") == nullptr) {
+                return mount("/", kSystemImageRootDir);
+            } else {
+                return mount("/system", kSystemImageRootDir);
+            }
+        }
+        if (path == "/vendor") {
+            return mount(path, kVendorImageRootDir);
+        }
+        return BAD_VALUE;
+    }
 
    private:
     FstabMgr fstab_;
+    std::map<std::string, std::string> mounted_;
 
-    status_t mount(const char* path, const char* mountPoint) const {
+    status_t mount(const std::string& path, const std::string& mountPoint) {
+        if (mounted_.find(path) != mounted_.end()) {
+            return OK;
+        }
+
         if (!fstab_) return UNKNOWN_ERROR;
-        return mountAt(fstab_, path, mountPoint);
+        status_t status = mountAt(fstab_, path.c_str(), mountPoint.c_str());
+        if (status == OK) {
+            mounted_.emplace(path, mountPoint);
+        }
+        return status;
     }
 };
 
@@ -81,24 +105,57 @@
     RecoveryFileSystem() = default;
 
     status_t fetch(const std::string& path, std::string* fetched, std::string* error) const {
-        return getFileSystem(path).fetch(path, fetched, error);
+        const FileSystem* fs = nullptr;
+        status_t err = getFileSystem(path, &fs, error);
+        if (err != OK) return err;
+        return fs->fetch(path, fetched, error);
     }
 
     status_t listFiles(const std::string& path, std::vector<std::string>* out,
                        std::string* error) const {
-        return getFileSystem(path).listFiles(path, out, error);
+        const FileSystem* fs = nullptr;
+        status_t err = getFileSystem(path, &fs, error);
+        if (err != OK) return err;
+        return fs->listFiles(path, out, error);
     }
 
    private:
-    FileSystemUnderPath mSystemFileSystem{"/mnt/system"};
-    FileSystemUnderPath mMntFileSystem{"/mnt"};
+    FileSystemUnderPath mSystemFileSystem{kSystemImageRootDir};
+    FileSystemUnderPath mMntFileSystem{kMountImageRootDir};
+    std::unique_ptr<RecoveryPartitionMounter> mMounter =
+        std::make_unique<RecoveryPartitionMounter>();
 
-    const FileSystemUnderPath& getFileSystem(const std::string& path) const {
-        // /system files are under /mnt/system/system because system.img contains the root dir.
-        if (StartsWith(path, "/system")) {
-            return mSystemFileSystem;
+    status_t getFileSystem(const std::string& path, const FileSystem** fs,
+                           std::string* error) const {
+        auto partition = GetPartition(path);
+        if (partition.empty()) {
+            if (error) *error = "Cannot list or fetch relative path " + path;
+            return NAME_NOT_FOUND;
         }
-        return mMntFileSystem;
+        status_t err = mMounter->mount(partition);
+        if (err != OK) {
+            // in recovery, ignore mount errors and assume the file does not exist.
+            if (error) *error = "Cannot mount for path " + path + ": " + strerror(-err);
+            return NAME_NOT_FOUND;
+        }
+
+        // /system files are under /mnt/system/system because system.img contains the root dir.
+        if (partition == "/system") {
+            *fs = &mSystemFileSystem;
+        } else {
+            *fs = &mMntFileSystem;
+        }
+        return OK;
+    }
+
+    // /system -> /system
+    // /system/foo -> /system
+    static std::string GetPartition(const std::string& path) {
+        if (path.empty()) return "";
+        if (path[0] != '/') return "";
+        auto idx = path.find('/', 1);
+        if (idx == std::string::npos) return path;
+        return path.substr(0, idx);
     }
 };
 
@@ -108,12 +165,10 @@
 int32_t VintfObjectRecovery::CheckCompatibility(
         const std::vector<std::string> &xmls, std::string *error) {
     auto propertyFetcher = std::make_unique<details::PropertyFetcherImpl>();
-    auto mounter = std::make_unique<details::RecoveryPartitionMounter>();
     auto fileSystem = std::make_unique<details::RecoveryFileSystem>();
-    auto vintfObject = std::make_unique<VintfObject>(std::move(fileSystem), std::move(mounter),
-                                                     nullptr /* runtime info factory */,
-                                                     std::move(propertyFetcher));
-    return vintfObject->checkCompatibility(xmls, true /* mount */, error);
+    auto vintfObject = std::make_unique<VintfObject>(
+        std::move(fileSystem), nullptr /* runtime info factory */, std::move(propertyFetcher));
+    return vintfObject->checkCompatibility(xmls, error);
 }
 
 
diff --git a/check_vintf.cpp b/check_vintf.cpp
index 7e51e6c..48d0bb4 100644
--- a/check_vintf.cpp
+++ b/check_vintf.cpp
@@ -223,8 +223,7 @@
     auto hostPropertyFetcher = std::make_unique<PresetPropertyFetcher>();
     hostPropertyFetcher->setProperties(props);
     VintfObject vintfObject(std::make_unique<HostFileSystem>(rootdir),
-                            nullptr /* partition mounter */, nullptr /* runtime info factory */,
-                            std::move(hostPropertyFetcher));
+                            nullptr /* runtime info factory */, std::move(hostPropertyFetcher));
     return vintfObject.checkCompatibility({} /* packageInfo */, error,
                                           CheckFlags::DISABLE_RUNTIME_INFO);
 }
diff --git a/include/vintf/VintfObject.h b/include/vintf/VintfObject.h
index 67c33b6..e96a3b5 100644
--- a/include/vintf/VintfObject.h
+++ b/include/vintf/VintfObject.h
@@ -30,7 +30,6 @@
 namespace vintf {
 
 namespace details {
-class PartitionMounter;
 template <typename T>
 class ObjectFactory;
 class PropertyFetcher;
@@ -84,12 +83,10 @@
      * Dependencies can be injected via arguments. If nullptr is provided, the default behavior
      * is used.
      * - FileSystem fetch from "/" for target and fetch no files for host
-     * - PartitionMounter does nothing for both target and host
      * - ObjectFactory<RuntimeInfo> fetches default RuntimeInfo for target and nothing for host
      * - PropertyFetcher fetches properties for target and nothing for host
      */
     VintfObject(std::unique_ptr<FileSystem>&& = nullptr,
-                std::unique_ptr<details::PartitionMounter>&& = nullptr,
                 std::unique_ptr<details::ObjectFactory<RuntimeInfo>>&& = nullptr,
                 std::unique_ptr<details::PropertyFetcher>&& = nullptr);
 
@@ -193,7 +190,6 @@
 
    private:
     const std::unique_ptr<FileSystem> mFileSystem;
-    const std::unique_ptr<details::PartitionMounter> mPartitionMounter;
     const std::unique_ptr<details::ObjectFactory<RuntimeInfo>> mRuntimeInfoFactory;
     const std::unique_ptr<details::PropertyFetcher> mPropertyFetcher;
 
@@ -214,10 +210,7 @@
     friend class testing::VintfObjectTestBase;
     friend class testing::VintfObjectRuntimeInfoTest;
     friend class testing::VintfObjectCompatibleTest;
-    int32_t checkCompatibility(const std::vector<std::string>& xmls, bool mount, std::string* error,
-                               CheckFlags::Type flags = CheckFlags::ENABLE_ALL_CHECKS);
     const std::unique_ptr<FileSystem>& getFileSystem();
-    const std::unique_ptr<details::PartitionMounter>& getPartitionMounter();
     const std::unique_ptr<details::PropertyFetcher>& getPropertyFetcher();
     const std::unique_ptr<details::ObjectFactory<RuntimeInfo>>& getRuntimeInfoFactory();
 
diff --git a/include/vintf/VintfObjectRecovery.h b/include/vintf/VintfObjectRecovery.h
index c3288f1..9fad4d4 100644
--- a/include/vintf/VintfObjectRecovery.h
+++ b/include/vintf/VintfObjectRecovery.h
@@ -28,11 +28,12 @@
 // are unmounted afterwards.
 
 class VintfObjectRecovery {
-public:
+   public:
     /**
      * Check compatibility, given a set of manifests / matrices in packageInfo.
      * They will be checked against the manifests / matrices on the device.
      * Partitions (/system, /vendor) are mounted if necessary.
+     * Note: this is NOT thread-safe.
      *
      * @param packageInfo a list of XMLs of HalManifest /
      * CompatibilityMatrix objects.
@@ -41,10 +42,8 @@
      *         > 0 if incompatible
      *         < 0 if any error (mount partition fails, illformed XML, etc.)
      */
-    static int32_t CheckCompatibility(
-            const std::vector<std::string> &packageInfo,
-            std::string *error = nullptr);
-
+    static int32_t CheckCompatibility(const std::vector<std::string>& packageInfo,
+                                      std::string* error = nullptr);
 };
 
 } // namespace vintf
diff --git a/test/utils-fake.h b/test/utils-fake.h
index 653c3b9..9296f75 100644
--- a/test/utils-fake.h
+++ b/test/utils-fake.h
@@ -43,44 +43,6 @@
     FileSystemImpl mImpl;
 };
 
-class MockPartitionMounter : public PartitionMounter {
-   public:
-    MockPartitionMounter() {
-        ON_CALL(*this, mountSystem()).WillByDefault(Invoke([&] {
-            systemMounted_ = true;
-            return OK;
-        }));
-        ON_CALL(*this, umountSystem()).WillByDefault(Invoke([&] {
-            systemMounted_ = false;
-            return OK;
-        }));
-        ON_CALL(*this, mountVendor()).WillByDefault(Invoke([&] {
-            vendorMounted_ = true;
-            return OK;
-        }));
-        ON_CALL(*this, umountVendor()).WillByDefault(Invoke([&] {
-            vendorMounted_ = false;
-            return OK;
-        }));
-    }
-    MOCK_CONST_METHOD0(mountSystem, status_t());
-    MOCK_CONST_METHOD0(umountSystem, status_t());
-    MOCK_CONST_METHOD0(mountVendor, status_t());
-    MOCK_CONST_METHOD0(umountVendor, status_t());
-
-    bool systemMounted() const { return systemMounted_; }
-    bool vendorMounted() const { return vendorMounted_; }
-
-    void reset() {
-        systemMounted_ = false;
-        vendorMounted_ = false;
-    }
-
-   private:
-    bool systemMounted_;
-    bool vendorMounted_;
-};
-
 class MockRuntimeInfo : public RuntimeInfo {
    public:
     MockRuntimeInfo() {
diff --git a/test/vintf_object_tests.cpp b/test/vintf_object_tests.cpp
index 34cee2d..6563cb0 100644
--- a/test/vintf_object_tests.cpp
+++ b/test/vintf_object_tests.cpp
@@ -283,9 +283,6 @@
 
 class VintfObjectTestBase : public ::testing::Test {
    protected:
-    MockPartitionMounter& mounter() {
-        return static_cast<MockPartitionMounter&>(*vintfObject->getPartitionMounter());
-    }
     MockFileSystem& fetcher() {
         return static_cast<MockFileSystem&>(*vintfObject->getFileSystem());
     }
@@ -360,13 +357,11 @@
     virtual void SetUp() {
         vintfObject =
             std::make_unique<VintfObject>(std::make_unique<NiceMock<MockFileSystem>>(),
-                                          std::make_unique<NiceMock<MockPartitionMounter>>(),
                                           std::make_unique<NiceMock<MockRuntimeInfoFactory>>(
                                               std::make_shared<NiceMock<MockRuntimeInfo>>()),
                                           std::make_unique<NiceMock<MockPropertyFetcher>>());
     }
     virtual void TearDown() {
-        Mock::VerifyAndClear(&mounter());
         Mock::VerifyAndClear(&fetcher());
     }
 
@@ -430,6 +425,11 @@
             .WillRepeatedly(Return(::android::NAME_NOT_FOUND));
     }
 
+    // Access to private method.
+    int checkCompatibility(const std::vector<std::string>& xmls, std::string* error) {
+        return vintfObject->checkCompatibility(xmls, error);
+    }
+
     std::string productModel;
     std::unique_ptr<VintfObject> vintfObject;
 };
@@ -440,15 +440,9 @@
     virtual void SetUp() {
         VintfObjectTestBase::SetUp();
         setFakeProperties();
-        mounter().reset();
         setupMockFetcher(vendorManifestXml1, systemMatrixXml1, systemManifestXml1, vendorMatrixXml1,
                          productModel);
     }
-
-    // Access to private method for force mounting.
-    int checkCompatibility(const std::vector<std::string>& xmls, bool mount, std::string* error) {
-        return vintfObject->checkCompatibility(xmls, mount, error);
-    }
 };
 
 // Tests that local info is checked.
@@ -460,34 +454,12 @@
     expectSystemManifest();
     expectVendorMatrix();
     expectSystemMatrix();
-    EXPECT_CALL(mounter(), mountSystem()).Times(0);
-    EXPECT_CALL(mounter(), umountSystem()).Times(0);
-    EXPECT_CALL(mounter(), mountVendor()).Times(0);
-    EXPECT_CALL(mounter(), umountVendor()).Times(0);
 
-    int result = vintfObject->checkCompatibility(packageInfo, &error);
+    int result = checkCompatibility(packageInfo, &error);
 
     ASSERT_EQ(result, 0) << "Fail message:" << error.c_str();
     // Check that nothing was ignored.
     ASSERT_STREQ(error.c_str(), "");
-    EXPECT_FALSE(mounter().systemMounted());
-    EXPECT_FALSE(mounter().vendorMounted());
-}
-
-TEST_F(VintfObjectCompatibleTest, TestDeviceCompatibilityMount) {
-    std::string error;
-    std::vector<std::string> packageInfo;
-
-    EXPECT_CALL(mounter(), mountSystem()).Times(2);
-    EXPECT_CALL(mounter(), umountSystem()).Times(1); // Should only umount once
-    EXPECT_CALL(mounter(), mountVendor()).Times(2);
-    EXPECT_CALL(mounter(), umountVendor()).Times(1);
-
-    int result = checkCompatibility(packageInfo, true /* mount */, &error);
-
-    ASSERT_EQ(result, 0) << "Fail message:" << error.c_str();
-    EXPECT_FALSE(mounter().systemMounted());
-    EXPECT_FALSE(mounter().vendorMounted());
 }
 
 // Tests that input info is checked against device and passes.
@@ -499,33 +471,11 @@
     expectSystemManifest();
     expectVendorMatrix();
     expectSystemMatrix(0);
-    EXPECT_CALL(mounter(), mountSystem()).Times(0);
-    EXPECT_CALL(mounter(), umountSystem()).Times(0);
-    EXPECT_CALL(mounter(), mountVendor()).Times(0);
-    EXPECT_CALL(mounter(), umountVendor()).Times(0);
 
-    int result = vintfObject->checkCompatibility(packageInfo, &error);
+    int result = checkCompatibility(packageInfo, &error);
 
     ASSERT_EQ(result, 0) << "Fail message:" << error.c_str();
     ASSERT_STREQ(error.c_str(), "");
-    EXPECT_FALSE(mounter().systemMounted());
-    EXPECT_FALSE(mounter().vendorMounted());
-}
-
-TEST_F(VintfObjectCompatibleTest, TestInputVsDeviceSuccessMount) {
-    std::string error;
-    std::vector<std::string> packageInfo = {systemMatrixXml1};
-
-    EXPECT_CALL(mounter(), mountSystem()).Times(1); // Should only mount once for manifest
-    EXPECT_CALL(mounter(), umountSystem()).Times(1);
-    EXPECT_CALL(mounter(), mountVendor()).Times(2);
-    EXPECT_CALL(mounter(), umountVendor()).Times(1);
-
-    int result = checkCompatibility(packageInfo, true /* mount */, &error);
-
-    ASSERT_EQ(result, 0) << "Fail message:" << error.c_str();
-    EXPECT_FALSE(mounter().systemMounted());
-    EXPECT_FALSE(mounter().vendorMounted());
 }
 
 // Tests that input info is checked against device and fails.
@@ -533,7 +483,7 @@
     std::string error;
     std::vector<std::string> packageInfo = {systemMatrixXml2};
 
-    int result = vintfObject->checkCompatibility(packageInfo, &error);
+    int result = checkCompatibility(packageInfo, &error);
 
     ASSERT_EQ(result, 1) << "Should have failed:" << error.c_str();
     EXPECT_IN(
@@ -548,7 +498,7 @@
     std::string error;
     std::vector<std::string> packageInfo = {systemMatrixXml2, vendorManifestXml2};
 
-    int result = vintfObject->checkCompatibility(packageInfo, &error);
+    int result = checkCompatibility(packageInfo, &error);
 
     ASSERT_EQ(result, 0) << "Failed message:" << error.c_str();
     ASSERT_STREQ(error.c_str(), "");
@@ -562,33 +512,11 @@
     expectSystemManifest(0);
     expectVendorMatrix();
     expectSystemMatrix(0);
-    EXPECT_CALL(mounter(), mountSystem()).Times(0);
-    EXPECT_CALL(mounter(), umountSystem()).Times(0);
-    EXPECT_CALL(mounter(), mountVendor()).Times(0);
-    EXPECT_CALL(mounter(), umountVendor()).Times(0);
 
-    int result = vintfObject->checkCompatibility(packageInfo, &error);
+    int result = checkCompatibility(packageInfo, &error);
 
     ASSERT_EQ(result, 0) << "Fail message:" << error.c_str();
     ASSERT_STREQ(error.c_str(), "");
-    EXPECT_FALSE(mounter().systemMounted());
-    EXPECT_FALSE(mounter().vendorMounted());
-}
-
-TEST_F(VintfObjectCompatibleTest, TestFrameworkOnlyOtaMount) {
-    std::string error;
-    std::vector<std::string> packageInfo = {systemMatrixXml1, systemManifestXml1};
-
-    EXPECT_CALL(mounter(), mountSystem()).Times(0);
-    EXPECT_CALL(mounter(), umountSystem()).Times(1);
-    EXPECT_CALL(mounter(), mountVendor()).Times(2);
-    EXPECT_CALL(mounter(), umountVendor()).Times(1);
-
-    int result = checkCompatibility(packageInfo, true /* mount */, &error);
-
-    ASSERT_EQ(result, 0) << "Fail message:" << error.c_str();
-    EXPECT_FALSE(mounter().systemMounted());
-    EXPECT_FALSE(mounter().vendorMounted());
 }
 
 TEST_F(VintfObjectCompatibleTest, TestFullOta) {
@@ -600,34 +528,11 @@
     expectSystemManifest(0);
     expectVendorMatrix(0);
     expectSystemMatrix(0);
-    EXPECT_CALL(mounter(), mountSystem()).Times(0);
-    EXPECT_CALL(mounter(), umountSystem()).Times(0);
-    EXPECT_CALL(mounter(), mountVendor()).Times(0);
-    EXPECT_CALL(mounter(), umountVendor()).Times(0);
 
-    int result = vintfObject->checkCompatibility(packageInfo, &error);
+    int result = checkCompatibility(packageInfo, &error);
 
     ASSERT_EQ(result, 0) << "Fail message:" << error.c_str();
     ASSERT_STREQ(error.c_str(), "");
-    EXPECT_FALSE(mounter().systemMounted());
-    EXPECT_FALSE(mounter().vendorMounted());
-}
-
-TEST_F(VintfObjectCompatibleTest, TestFullOnlyOtaMount) {
-    std::string error;
-    std::vector<std::string> packageInfo = {systemMatrixXml1, systemManifestXml1,
-            vendorMatrixXml1, vendorManifestXml1};
-
-    EXPECT_CALL(mounter(), mountSystem()).Times(0);
-    EXPECT_CALL(mounter(), umountSystem()).Times(1);
-    EXPECT_CALL(mounter(), mountVendor()).Times(0);
-    EXPECT_CALL(mounter(), umountVendor()).Times(1);
-
-    int result = checkCompatibility(packageInfo, true /* mount */, &error);
-
-    ASSERT_EQ(result, 0) << "Fail message:" << error.c_str();
-    EXPECT_FALSE(mounter().systemMounted());
-    EXPECT_FALSE(mounter().vendorMounted());
 }
 
 // Test fixture that provides incompatible metadata from the mock device.
@@ -636,7 +541,6 @@
     virtual void SetUp() {
         VintfObjectTestBase::SetUp();
         setFakeProperties();
-        mounter().reset();
         setupMockFetcher(vendorManifestXml1, systemMatrixXml2, systemManifestXml1, vendorMatrixXml1,
                          productModel);
     }
@@ -652,7 +556,7 @@
     expectVendorMatrix();
     expectSystemMatrix();
 
-    int result = vintfObject->checkCompatibility(packageInfo, &error);
+    int result = checkCompatibility(packageInfo, &error);
 
     ASSERT_EQ(result, 1) << "Should have failed:" << error.c_str();
 }
@@ -667,7 +571,7 @@
     expectVendorMatrix();
     expectSystemMatrix(0);
 
-    int result = vintfObject->checkCompatibility(packageInfo, &error);
+    int result = checkCompatibility(packageInfo, &error);
 
     ASSERT_EQ(result, 0) << "Failed message:" << error.c_str();
     ASSERT_STREQ(error.c_str(), "");
diff --git a/utils.h b/utils.h
index 8ccda3e..f8cc9cd 100644
--- a/utils.h
+++ b/utils.h
@@ -29,15 +29,6 @@
 namespace vintf {
 namespace details {
 
-class PartitionMounter {
-   public:
-    virtual ~PartitionMounter() {}
-    virtual status_t mountSystem() const { return OK; }
-    virtual status_t mountVendor() const { return OK; }
-    virtual status_t umountSystem() const { return OK; }
-    virtual status_t umountVendor() const { return OK; }
-};
-
 template <typename T>
 status_t fetchAllInformation(const FileSystem* fileSystem, const std::string& path,
                              const XmlConverter<T>& converter, T* outObject, std::string* error) {