Make mIsDeviceLockedForUser synchronized. am: c7431a287b am: eed15b0281

Original change: https://googleplex-android-review.googlesource.com/c/platform/system/security/+/12855494

Change-Id: I6aad65815b23d46c69b62df02ea20c6f04fbd0bc
diff --git a/keystore/keystore_keymaster_enforcement.h b/keystore/keystore_keymaster_enforcement.h
index e7515a1..b0dae48 100644
--- a/keystore/keystore_keymaster_enforcement.h
+++ b/keystore/keystore_keymaster_enforcement.h
@@ -86,16 +86,19 @@
     }
 
     bool is_device_locked(int32_t userId) const override {
+        std::lock_guard<std::mutex> lock(is_device_locked_for_user_map_lock_);
         // If we haven't had a set call for this user yet, assume the device is locked.
         if (mIsDeviceLockedForUser.count(userId) == 0) return true;
         return mIsDeviceLockedForUser.find(userId)->second;
     }
 
     void set_device_locked(bool isLocked, int32_t userId) {
+        std::lock_guard<std::mutex> lock(is_device_locked_for_user_map_lock_);
         mIsDeviceLockedForUser[userId] = isLocked;
     }
 
   private:
+    mutable std::mutex is_device_locked_for_user_map_lock_;
     std::map<int32_t, bool> mIsDeviceLockedForUser;
 };