diff options
author | Eric Erfanian <erfanian@google.com> | 2017-05-05 15:23:13 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-05-05 15:23:13 +0000 |
commit | 300a8683b9c28424fb0f0c571a0abe128c461f69 (patch) | |
tree | 3a325b0effac02fbd228b8ddf2f96589e5df72cd /java/com/android/dialer/persistentlog/PersistentLogFileHandler.java | |
parent | d67f1627521b174f12e0c247f154c7c93c5e408e (diff) | |
parent | 10b34a5ebf12e97ecba0caf3c8e30b476b038a96 (diff) |
Update Dialer to V10 RC16
am: 10b34a5ebf
Change-Id: Iea3e96ccdeaf1fa796ceca702cace82ca20f298c
Diffstat (limited to 'java/com/android/dialer/persistentlog/PersistentLogFileHandler.java')
-rw-r--r-- | java/com/android/dialer/persistentlog/PersistentLogFileHandler.java | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/java/com/android/dialer/persistentlog/PersistentLogFileHandler.java b/java/com/android/dialer/persistentlog/PersistentLogFileHandler.java index c113559a1..4ba5a72ec 100644 --- a/java/com/android/dialer/persistentlog/PersistentLogFileHandler.java +++ b/java/com/android/dialer/persistentlog/PersistentLogFileHandler.java @@ -51,7 +51,7 @@ import java.util.List; * worker thread. */ @SuppressWarnings("AndroidApiChecker") // lambdas -@TargetApi(VERSION_CODES.N) +@TargetApi(VERSION_CODES.M) final class PersistentLogFileHandler { private static final String LOG_DIRECTORY = "persistent_log"; @@ -110,14 +110,21 @@ final class PersistentLogFileHandler { private byte[] readBlob() throws IOException { File[] files = getLogFiles(); - ByteBuffer byteBuffer = - ByteBuffer.allocate(Arrays.stream(files).mapToInt(file -> (int) file.length()).sum()); + ByteBuffer byteBuffer = ByteBuffer.allocate(getTotalSize(files)); for (File file : files) { byteBuffer.put(readAllBytes(file)); } return byteBuffer.array(); } + private static final int getTotalSize(File[] files) { + int sum = 0; + for (File file : files) { + sum += file.length(); + } + return sum; + } + /** Parses the content of all files back to individual byte arrays. */ @WorkerThread @NonNull |