Commit ebd1ba01 authored by Michael W's avatar Michael W
Browse files

Recorder: Prevent running into out of memory exceptions

* Instead of reading the whole taken recording into memory,
  copy it using a built-in method

Fixes: https://gitlab.com/LineageOS/issues/android/-/issues/1982

Change-Id: I820bd71f69eb951467a4927389f8b3b1a866b303
parent 8f080001
/*
* Copyright (C) 2019 The LineageOS Project
* Copyright (C) 2019-2020 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -124,12 +124,12 @@ public final class MediaProviderHelper {
if (pfd == null) {
return null;
}
final FileOutputStream oStream = new FileOutputStream(pfd.getFileDescriptor());
oStream.write(Files.readAllBytes(file.toPath()));
Files.copy(file.toPath(), oStream);
oStream.close();
pfd.close();
final ContentValues values = new ContentValues();
values.put(MediaStore.MediaColumns.IS_PENDING, 0);
cr.update(uri, values, null, null);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment