Add logging around access calls.

We saw evidence, that the keystore exist method may be flaky. This
patch adds logging around the access calls used to check for key blobs.
Also adds a retry loop in case access return EAGAIN. (Although access
should not return EAGAIN).

Bug: 128318105
Test: Only logging added.
Change-Id: Ib07396f590c2f58e227f85869ada8c6d6dd46df4
diff --git a/keystore/blob.cpp b/keystore/blob.cpp
index 9dd85d6..eac8f11 100644
--- a/keystore/blob.cpp
+++ b/keystore/blob.cpp
@@ -676,10 +676,27 @@
 }
 
 bool KeyBlobEntry::hasKeyBlob() const {
-    return !access(getKeyBlobPath().c_str(), R_OK | W_OK);
+    int trys = 3;
+    while (trys--) {
+        if (!access(getKeyBlobPath().c_str(), R_OK | W_OK)) return true;
+        if (errno == ENOENT) return false;
+        LOG(WARNING) << "access encountered " << strerror(errno) << " (" << errno << ")"
+                     << " while checking for key blob";
+        if (errno != EAGAIN) break;
+    }
+    return false;
 }
+
 bool KeyBlobEntry::hasCharacteristicsBlob() const {
-    return !access(getCharacteristicsBlobPath().c_str(), R_OK | W_OK);
+    int trys = 3;
+    while (trys--) {
+        if (!access(getCharacteristicsBlobPath().c_str(), R_OK | W_OK)) return true;
+        if (errno == ENOENT) return false;
+        LOG(WARNING) << "access encountered " << strerror(errno) << " (" << errno << ")"
+                     << " while checking for key characteristics blob";
+        if (errno != EAGAIN) break;
+    }
+    return false;
 }
 
 static std::tuple<bool, uid_t, std::string> filename2UidAlias(const std::string& filepath) {