Remove TimeSpec type alias

Bug: n/a
Test: m
Change-Id: I1e7a50483e67cce5993001615aefe03c58f54e98
diff --git a/Apex.cpp b/Apex.cpp
index 8ece758..96fb155 100644
--- a/Apex.cpp
+++ b/Apex.cpp
@@ -81,13 +81,13 @@
     return OK;
 }
 
-std::optional<TimeSpec> GetModifiedTime(FileSystem* fileSystem, PropertyFetcher* propertyFetcher) {
+std::optional<timespec> GetModifiedTime(FileSystem* fileSystem, PropertyFetcher* propertyFetcher) {
     std::string apexInfoFile = details::kApexInfoFile;
     if (!isApexReady(propertyFetcher)) {
         apexInfoFile = details::kBootstrapApexInfoFile;
     }
 
-    TimeSpec mtime{};
+    timespec mtime{};
     std::string error;
     status_t status = fileSystem->modifiedTime(apexInfoFile, &mtime, &error);
     if (status == NAME_NOT_FOUND) {
diff --git a/FileSystem.cpp b/FileSystem.cpp
index 2ff11c5..382dc86 100644
--- a/FileSystem.cpp
+++ b/FileSystem.cpp
@@ -64,7 +64,7 @@
     return -saved_errno;
 }
 
-status_t FileSystemImpl::modifiedTime(const std::string& path, TimeSpec* mtime,
+status_t FileSystemImpl::modifiedTime(const std::string& path, timespec* mtime,
                                       std::string* error) const {
     struct stat stat_buf;
     if (stat(path.c_str(), &stat_buf) != 0) {
@@ -87,7 +87,7 @@
     return NAME_NOT_FOUND;
 }
 
-status_t FileSystemNoOp::modifiedTime(const std::string&, TimeSpec*, std::string*) const {
+status_t FileSystemNoOp::modifiedTime(const std::string&, timespec*, std::string*) const {
     return NAME_NOT_FOUND;
 }
 
@@ -108,7 +108,7 @@
     return mImpl.listFiles(mRootDir + path, out, error);
 }
 
-status_t FileSystemUnderPath::modifiedTime(const std::string& path, TimeSpec* mtime,
+status_t FileSystemUnderPath::modifiedTime(const std::string& path, timespec* mtime,
                                            std::string* error) const {
     return mImpl.modifiedTime(mRootDir + path, mtime, error);
 }
@@ -145,7 +145,7 @@
     return impl_->listFiles(path_replace(path), out, error);
 }
 
-status_t PathReplacingFileSystem::modifiedTime(const std::string& path, TimeSpec* mtime,
+status_t PathReplacingFileSystem::modifiedTime(const std::string& path, timespec* mtime,
                                                std::string* error) const {
     return impl_->modifiedTime(path_replace(path), mtime, error);
 }
diff --git a/HostFileSystem.cpp b/HostFileSystem.cpp
index df24266..b9d513f 100644
--- a/HostFileSystem.cpp
+++ b/HostFileSystem.cpp
@@ -55,7 +55,7 @@
     return status;
 }
 
-status_t HostFileSystem::modifiedTime(const std::string& path, TimeSpec* mtime,
+status_t HostFileSystem::modifiedTime(const std::string& path, timespec* mtime,
                                       std::string* error) const {
     auto resolved = resolve(path, error);
     if (resolved.empty()) {
diff --git a/VintfFm.cpp b/VintfFm.cpp
index 653c2e2..290ad3d 100644
--- a/VintfFm.cpp
+++ b/VintfFm.cpp
@@ -72,7 +72,7 @@
                        std::string* error) const override {
         return mRoFileSystem.listFiles(path, out, error);
     }
-    status_t modifiedTime(const std::string& path, TimeSpec* out,
+    status_t modifiedTime(const std::string& path, timespec* out,
                           std::string* error) const override {
         return mRoFileSystem.modifiedTime(path, out, error);
     }
diff --git a/VintfObjectUtils.h b/VintfObjectUtils.h
index 3abeb8c..7be9b5b 100644
--- a/VintfObjectUtils.h
+++ b/VintfObjectUtils.h
@@ -32,7 +32,7 @@
 // can refer to the "last modified" timestamp of the data source.
 template <typename T, typename F>
 std::shared_ptr<const T> Get(const char* id, LockedSharedPtr<T>* ptr, const F& fetch,
-                             const std::optional<TimeSpec>& lastModified = std::nullopt) {
+                             const std::optional<timespec>& lastModified = std::nullopt) {
     std::unique_lock<std::mutex> lock(ptr->mutex);
     // Check if the last fetched data is fresh. If it's old, re-fetch the data
     // with the new timestamp.
diff --git a/include-host/vintf/HostFileSystem.h b/include-host/vintf/HostFileSystem.h
index 80a2a55..5301232 100644
--- a/include-host/vintf/HostFileSystem.h
+++ b/include-host/vintf/HostFileSystem.h
@@ -39,7 +39,7 @@
                    std::string* error) const override;
     status_t listFiles(const std::string& path, std::vector<std::string>* out,
                        std::string* error) const override;
-    status_t modifiedTime(const std::string& path, TimeSpec* mtime,
+    status_t modifiedTime(const std::string& path, timespec* mtime,
                           std::string* error) const override;
 
    private:
diff --git a/include/vintf/Apex.h b/include/vintf/Apex.h
index af4bc24..175ae96 100644
--- a/include/vintf/Apex.h
+++ b/include/vintf/Apex.h
@@ -25,7 +25,7 @@
 
 namespace android::vintf::apex {
 
-std::optional<TimeSpec> GetModifiedTime(FileSystem* fileSystem, PropertyFetcher* propertyFetcher);
+std::optional<timespec> GetModifiedTime(FileSystem* fileSystem, PropertyFetcher* propertyFetcher);
 status_t GetDeviceVintfDirs(FileSystem* fileSystem, PropertyFetcher* propertyFetcher,
                             std::vector<std::string>* out, std::string* error);
 status_t GetFrameworkVintfDirs(FileSystem* fileSystem, PropertyFetcher* propertyFetcher,
diff --git a/include/vintf/FileSystem.h b/include/vintf/FileSystem.h
index 2697b80..de16d50 100644
--- a/include/vintf/FileSystem.h
+++ b/include/vintf/FileSystem.h
@@ -26,8 +26,6 @@
 
 #include <utils/Errors.h>
 
-using TimeSpec = struct timespec;
-
 namespace android {
 namespace vintf {
 
@@ -49,7 +47,7 @@
                                std::string* error) const = 0;
     // Return NAME_NOT_FOUND if file is not found,
     //        OK if "mtime" is set with modified time of the file.
-    virtual status_t modifiedTime(const std::string& path, TimeSpec* mtime,
+    virtual status_t modifiedTime(const std::string& path, timespec* mtime,
                                   std::string* error) const = 0;
 };
 
@@ -70,7 +68,7 @@
    public:
     status_t fetch(const std::string&, std::string*, std::string*) const override;
     status_t listFiles(const std::string&, std::vector<std::string>*, std::string*) const override;
-    status_t modifiedTime(const std::string& path, TimeSpec* mtime, std::string* error) const;
+    status_t modifiedTime(const std::string& path, timespec* mtime, std::string* error) const;
 };
 
 // Class that does nothing.
@@ -78,7 +76,7 @@
    public:
     status_t fetch(const std::string&, std::string*, std::string*) const override;
     status_t listFiles(const std::string&, std::vector<std::string>*, std::string*) const override;
-    status_t modifiedTime(const std::string& path, TimeSpec* mtime,
+    status_t modifiedTime(const std::string& path, timespec* mtime,
                           std::string* error) const override;
 };
 
@@ -90,7 +88,7 @@
                    std::string* error) const override;
     status_t listFiles(const std::string& path, std::vector<std::string>* out,
                        std::string* error) const override;
-    status_t modifiedTime(const std::string& path, TimeSpec* mtime,
+    status_t modifiedTime(const std::string& path, timespec* mtime,
                           std::string* error) const override;
 
    protected:
@@ -113,7 +111,7 @@
                    std::string* error) const override;
     status_t listFiles(const std::string& path, std::vector<std::string>* out,
                        std::string* error) const override;
-    status_t modifiedTime(const std::string& path, TimeSpec* mtime,
+    status_t modifiedTime(const std::string& path, timespec* mtime,
                           std::string* error) const override;
 
    private:
diff --git a/include/vintf/VintfObject.h b/include/vintf/VintfObject.h
index 6244ecf..8f29ec0 100644
--- a/include/vintf/VintfObject.h
+++ b/include/vintf/VintfObject.h
@@ -52,7 +52,7 @@
 struct LockedSharedPtr {
     std::shared_ptr<T> object;
     std::mutex mutex;
-    std::optional<TimeSpec> lastModified;
+    std::optional<timespec> lastModified;
 };
 
 struct LockedRuntimeInfoCache {
diff --git a/test/LibVintfTest.cpp b/test/LibVintfTest.cpp
index 5708a96..3584800 100644
--- a/test/LibVintfTest.cpp
+++ b/test/LibVintfTest.cpp
@@ -4586,10 +4586,10 @@
         *out = std::vector<std::string>{begin(entries), end(entries)};
         return OK;
     }
-    status_t modifiedTime(const std::string& path, TimeSpec* mtime, std::string* error) const {
+    status_t modifiedTime(const std::string& path, timespec* mtime, std::string* error) const {
         (void)error;
         if (auto it = files.find(path); it != files.end()) {
-            *mtime = TimeSpec{};
+            *mtime = timespec{};
             return OK;
         }
         return NAME_NOT_FOUND;
diff --git a/test/VintfFmTest.cpp b/test/VintfFmTest.cpp
index d376c59..b25dc28 100644
--- a/test/VintfFmTest.cpp
+++ b/test/VintfFmTest.cpp
@@ -115,7 +115,7 @@
                 (const override));
     MOCK_METHOD(status_t, listFiles, (const std::string&, std::vector<std::string>*, std::string*),
                 (const override));
-    MOCK_METHOD(status_t, modifiedTime, (const std::string&, TimeSpec*, std::string*),
+    MOCK_METHOD(status_t, modifiedTime, (const std::string&, timespec*, std::string*),
                 (const override));
     MOCK_METHOD(status_t, write, (const std::string&, const std::string&, std::string*),
                 (const override));
diff --git a/test/utils-fake.h b/test/utils-fake.h
index 0faf3b0..c97d89d 100644
--- a/test/utils-fake.h
+++ b/test/utils-fake.h
@@ -37,7 +37,7 @@
     MOCK_CONST_METHOD2(fetch, status_t(const std::string& path, std::string& fetched));
     MOCK_CONST_METHOD3(listFiles,
                        status_t(const std::string&, std::vector<std::string>*, std::string*));
-    MOCK_CONST_METHOD3(modifiedTime, status_t(const std::string&, TimeSpec*, std::string*));
+    MOCK_CONST_METHOD3(modifiedTime, status_t(const std::string&, timespec*, std::string*));
 
     status_t fetch(const std::string& path, std::string* fetched, std::string*) const override {
         // Call the mocked function
@@ -53,7 +53,7 @@
                 (const override));
     MOCK_METHOD(status_t, listFiles, (const std::string&, std::vector<std::string>*, std::string*),
                 (const override));
-    MOCK_METHOD(status_t, modifiedTime, (const std::string&, TimeSpec*, std::string*),
+    MOCK_METHOD(status_t, modifiedTime, (const std::string&, timespec*, std::string*),
                 (const override));
 };
 
diff --git a/test/vintf_object_tests.cpp b/test/vintf_object_tests.cpp
index 3b6a166..a13007c 100644
--- a/test/vintf_object_tests.cpp
+++ b/test/vintf_object_tests.cpp
@@ -884,12 +884,12 @@
                 preinstalledModulePath="/vendor/apex/com.novintf.apex" isActive="true"/>
         </apex-info-list>)");
         EXPECT_CALL(fetcher(), modifiedTime(kApexInfoFile, _, _))
-            .WillOnce(Invoke([](auto, TimeSpec* out, auto){
+            .WillOnce(Invoke([](auto, timespec* out, auto){
                 *out = {};
                 return ::android::OK;
             }))
             // Update once, but no more.
-            .WillRepeatedly(Invoke([](auto, TimeSpec* out, auto){
+            .WillRepeatedly(Invoke([](auto, timespec* out, auto){
                 *out = {1,};
                 return ::android::OK;
             }))
@@ -2089,7 +2089,7 @@
                     isActive="true"/>
             </apex-info-list>)");
         EXPECT_CALL(fetcher(), modifiedTime(kApexInfoFile, _, _))
-            .WillRepeatedly(Invoke([](auto, TimeSpec* out, auto){
+            .WillRepeatedly(Invoke([](auto, timespec* out, auto){
                 *out = {};
                 return ::android::OK;
             }))
diff --git a/utils.h b/utils.h
index f33472b..40abf2d 100644
--- a/utils.h
+++ b/utils.h
@@ -26,12 +26,14 @@
 #include <vintf/RuntimeInfo.h>
 #include <vintf/parse_xml.h>
 
-// Equility operators for TimeSpec in FileSystem.h
+// Equality for timespec. This should be in global namespace where timespec
+// is defined.
 
-inline bool operator==(const TimeSpec& a, const TimeSpec& b) {
+inline bool operator==(const timespec& a, const timespec& b) noexcept {
     return a.tv_sec == b.tv_sec && a.tv_nsec == b.tv_nsec;
 }
-inline bool operator!=(const TimeSpec& a, const TimeSpec& b) {
+
+inline bool operator!=(const timespec& a, const timespec& b) noexcept {
     return !(a == b);
 }