Loading android/app/src/com/android/bluetooth/btservice/bluetoothKeystore/BluetoothKeystoreService.java +27 −14 Original line number Diff line number Diff line Loading @@ -213,6 +213,7 @@ public class BluetoothKeystoreService { @VisibleForTesting public void cleanupForCommonCriteriaModeEnable() { try { Thread.sleep(100); setEncryptKeyOrRemoveKey(CONFIG_FILE_PREFIX, CONFIG_FILE_HASH); } catch (InterruptedException e) { reportBluetoothKeystoreException(e, "Interrupted while operating."); Loading Loading @@ -523,7 +524,7 @@ public class BluetoothKeystoreService { */ @VisibleForTesting public boolean compareFileHash(String hashFilePathString) throws IOException, NoSuchAlgorithmException { throws InterruptedException, IOException, NoSuchAlgorithmException { if (!Files.exists(Paths.get(hashFilePathString))) { infoLog("compareFileHash: File does not exist, path: " + hashFilePathString); return false; Loading Loading @@ -558,13 +559,15 @@ public class BluetoothKeystoreService { } private void readHashFile(String filePathString, String prefixString) throws IOException, NoSuchAlgorithmException { throws InterruptedException, NoSuchAlgorithmException { byte[] dataBuffer = new byte[BUFFER_SIZE]; int bytesRead = 0; boolean successful = false; int counter = 0; while (!successful && counter < TRY_MAX) { try { MessageDigest messageDigest = MessageDigest.getInstance("SHA-256"); InputStream fileStream = Files.newInputStream(Paths.get(filePathString)); while ((bytesRead = fileStream.read(dataBuffer)) != -1) { messageDigest.update(dataBuffer, 0, bytesRead); } Loading @@ -577,6 +580,16 @@ public class BluetoothKeystoreService { } mNameDecryptKey.put(prefixString, hashString.toString()); successful = true; } catch (IOException e) { infoLog("Fail to open file, try again. counter: " + counter); Thread.sleep(50); counter++; } } if (counter > 3) { errorLog("Fail to open file"); } } private void readChecksumFile(String filePathString, String prefixString) throws IOException { Loading android/app/tests/unit/src/com/android/bluetooth/btservice/bluetoothKeystore/BluetoothKeystoreServiceTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -214,7 +214,7 @@ public final class BluetoothKeystoreServiceTest { private boolean compareFileHash(String hashFilePathString) { try { return mBluetoothKeystoreService.compareFileHash(hashFilePathString); } catch (IOException | NoSuchAlgorithmException e) { } catch (InterruptedException | IOException | NoSuchAlgorithmException e) { return false; } } Loading Loading
android/app/src/com/android/bluetooth/btservice/bluetoothKeystore/BluetoothKeystoreService.java +27 −14 Original line number Diff line number Diff line Loading @@ -213,6 +213,7 @@ public class BluetoothKeystoreService { @VisibleForTesting public void cleanupForCommonCriteriaModeEnable() { try { Thread.sleep(100); setEncryptKeyOrRemoveKey(CONFIG_FILE_PREFIX, CONFIG_FILE_HASH); } catch (InterruptedException e) { reportBluetoothKeystoreException(e, "Interrupted while operating."); Loading Loading @@ -523,7 +524,7 @@ public class BluetoothKeystoreService { */ @VisibleForTesting public boolean compareFileHash(String hashFilePathString) throws IOException, NoSuchAlgorithmException { throws InterruptedException, IOException, NoSuchAlgorithmException { if (!Files.exists(Paths.get(hashFilePathString))) { infoLog("compareFileHash: File does not exist, path: " + hashFilePathString); return false; Loading Loading @@ -558,13 +559,15 @@ public class BluetoothKeystoreService { } private void readHashFile(String filePathString, String prefixString) throws IOException, NoSuchAlgorithmException { throws InterruptedException, NoSuchAlgorithmException { byte[] dataBuffer = new byte[BUFFER_SIZE]; int bytesRead = 0; boolean successful = false; int counter = 0; while (!successful && counter < TRY_MAX) { try { MessageDigest messageDigest = MessageDigest.getInstance("SHA-256"); InputStream fileStream = Files.newInputStream(Paths.get(filePathString)); while ((bytesRead = fileStream.read(dataBuffer)) != -1) { messageDigest.update(dataBuffer, 0, bytesRead); } Loading @@ -577,6 +580,16 @@ public class BluetoothKeystoreService { } mNameDecryptKey.put(prefixString, hashString.toString()); successful = true; } catch (IOException e) { infoLog("Fail to open file, try again. counter: " + counter); Thread.sleep(50); counter++; } } if (counter > 3) { errorLog("Fail to open file"); } } private void readChecksumFile(String filePathString, String prefixString) throws IOException { Loading
android/app/tests/unit/src/com/android/bluetooth/btservice/bluetoothKeystore/BluetoothKeystoreServiceTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -214,7 +214,7 @@ public final class BluetoothKeystoreServiceTest { private boolean compareFileHash(String hashFilePathString) { try { return mBluetoothKeystoreService.compareFileHash(hashFilePathString); } catch (IOException | NoSuchAlgorithmException e) { } catch (InterruptedException | IOException | NoSuchAlgorithmException e) { return false; } } Loading