summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHasini Gunasinghe <hasinitg@google.com>2020-10-14 14:49:58 +0000
committerHasini Gunasinghe <hasinitg@google.com>2020-10-15 23:55:36 +0000
commit8696c2ca1be068551a01008d0df642f5ccd86354 (patch)
tree750df14db71c450631cf864c34bcff2a11949dfd
parent092ed74fbd49e7691ad79aa3bfc61872e2b97df8 (diff)
downloadsecurity-8696c2ca1be068551a01008d0df642f5ccd86354.tar.gz
Make mIsDeviceLockedForUser synchronized.
Bug: 169933423 Test: TBD/Treehugger passes Change-Id: I8e1f57dd5ab8314801bdd62058c9ed5f761b7c55
-rw-r--r--keystore/keystore_keymaster_enforcement.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/keystore/keystore_keymaster_enforcement.h b/keystore/keystore_keymaster_enforcement.h
index e7515a1f..b0dae48e 100644
--- a/keystore/keystore_keymaster_enforcement.h
+++ b/keystore/keystore_keymaster_enforcement.h
@@ -86,16 +86,19 @@ class KeystoreKeymasterEnforcement : public KeymasterEnforcement {
}
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;
};