Fix deadlock in keystore

The keystore dispatcher thread must not hold any locks when it calls
LockedKeyBlobEntry::list.

Also fixed an issue with the KeyBlobEntry conparisson function that lead
to clients beeing blockd by each other if they edit the same alias at
the same time altough they have different name spaces.

Test: A script that is currently under development. Stay tuned
Change-Id: I1d7f46cc27b3d90305a0ea64b8859d85b42996d8
diff --git a/keystore/KeyStore.cpp b/keystore/KeyStore.cpp
index 7530243..ac3ab5f 100644
--- a/keystore/KeyStore.cpp
+++ b/keystore/KeyStore.cpp
@@ -138,21 +138,13 @@
     android::String8 prefix("");
     android::Vector<android::String16> aliases;
 
-    // DO NOT
-    // move
-    // auto userState = userStateDB_.getUserState(userId);
-    // here, in an attempt to replace userStateDB_.getUserState(userId) with userState.
-    // userState is a proxy that holds a lock which may required by a worker.
-    // LockedKeyBlobEntry::list has a fence that waits until all workers have finished which may
-    // not happen if a user state lock is held. The following line only briefly grabs the lock.
-    // Grabbing the user state lock after the list call is also save since workers cannot grab
-    // blob entry locks.
-
     auto userState = mUserStateDB.getUserState(userId);
     std::string userDirName = userState->getUserDirName();
     auto encryptionKey = userState->getEncryptionKey();
     auto state = userState->getState();
-    // unlock the user state
+    // userState is a proxy that holds a lock which may be required by a worker.
+    // LockedKeyBlobEntry::list has a fence that waits until all workers have finished which may
+    // not happen if a user state lock is held. The following line relinquishes the lock.
     userState = {};
 
     ResponseCode rc;
@@ -217,7 +209,7 @@
 bool KeyStore::isEmpty(uid_t userId) const {
     std::string userDirName;
     {
-        // userState hold a lock which must be relinqhished before list is called. This scope
+        // userState holds a lock which must be relinquished before list is called. This scope
         // prevents deadlocks.
         auto userState = mUserStateDB.getUserState(userId);
         if (!userState) {