commit | 4f9def32e259251ed530108134879211e51d818b | [log] [tgz] |
---|---|---|
author | weichinweng <weichinweng@google.com> | Wed Jun 17 13:36:43 2020 +0800 |
committer | Weichin Weng <weichinweng@google.com> | Thu Jul 09 02:57:13 2020 +0000 |
tree | 7e12e0be40594de8b6bb90666e99aa32f6508fc8 | |
parent | cc6d55812bcb0f7c448496d888a3485213b94fb1 [diff] |
NIAP: Make sure that call getOrCreateSecretKey once at a time Since the getOrGenerate semantic on keystore is not thread safe, need to synchronize it to make sure that call getOrCreateSecretKey once at a time. Bug: 160630406 Test: atest BluetoothInstrumentationTests Tag: #feature Change-Id: I182eff28666b7fae76c7207cc430bb132a253a4c
diff --git a/src/com/android/bluetooth/btservice/bluetoothKeystore/BluetoothKeystoreService.java b/src/com/android/bluetooth/btservice/bluetoothKeystore/BluetoothKeystoreService.java index f25f367..c838584 100644 --- a/src/com/android/bluetooth/btservice/bluetoothKeystore/BluetoothKeystoreService.java +++ b/src/com/android/bluetooth/btservice/bluetoothKeystore/BluetoothKeystoreService.java
@@ -797,7 +797,8 @@ return keyStore; } - private SecretKey getOrCreateSecretKey() { + // The getOrGenerate semantic on keystore is not thread safe, need to synchronized it. + private synchronized SecretKey getOrCreateSecretKey() { SecretKey secretKey = null; try { KeyStore keyStore = getKeyStore();