Merge "dataloader/incfs openWrite returns int" into rvc-dev am: 1f9875dc17

Change-Id: Ib93efe0ef11c6d3926f906500f7e0c8ab0f97cf6
This commit is contained in:
Automerger Merge Worker
2020-03-04 00:39:13 +00:00
3 changed files with 15 additions and 14 deletions

View File

@@ -101,8 +101,7 @@ public final class IncrementalFileStorages {
} catch (IOException e) { } catch (IOException e) {
// TODO(b/146080380): add incremental-specific error code // TODO(b/146080380): add incremental-specific error code
throw new IOException( throw new IOException(
"Failed to add file to IncFS: " + file.getName() + ", reason: " "Failed to add file to IncFS: " + file.getName() + ", reason: ", e);
+ e.getMessage(), e.getCause());
} }
} else { } else {
throw new IOException("Unknown file location: " + file.getLocation()); throw new IOException("Unknown file location: " + file.getLocation());
@@ -117,6 +116,7 @@ public final class IncrementalFileStorages {
return result; return result;
} catch (IOException e) { } catch (IOException e) {
Slog.e(TAG, "Failed to initialize Incremental file storages. Cleaning up...", e);
if (result != null) { if (result != null) {
result.cleanUp(); result.cleanUp();
} }

View File

@@ -424,14 +424,18 @@ public final class IncrementalStorage {
*/ */
private static IncrementalSignature parseV4Signature(@Nullable byte[] v4signatureBytes) private static IncrementalSignature parseV4Signature(@Nullable byte[] v4signatureBytes)
throws IOException { throws IOException {
if (v4signatureBytes == null) { if (v4signatureBytes == null || v4signatureBytes.length == 0) {
return null; return null;
} }
final V4Signature signature; final V4Signature signature;
try (DataInputStream input = new DataInputStream( try (DataInputStream input = new DataInputStream(
new ByteArrayInputStream(v4signatureBytes))) { new ByteArrayInputStream(v4signatureBytes))) {
signature = V4Signature.readFrom(input); try {
signature = V4Signature.readFrom(input);
} catch (IOException e) {
throw new IOException("Failed to read v4 signature:", e);
}
} }
if (!signature.isVersionSupported()) { if (!signature.isVersionSupported()) {

View File

@@ -16,22 +16,17 @@
#define ATRACE_TAG ATRACE_TAG_ADB #define ATRACE_TAG ATRACE_TAG_ADB
#define LOG_TAG "PackageManagerShellCommandDataLoader-jni" #define LOG_TAG "PackageManagerShellCommandDataLoader-jni"
#include <android-base/logging.h>
#include <android-base/file.h> #include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/stringprintf.h> #include <android-base/stringprintf.h>
#include <android-base/unique_fd.h> #include <android-base/unique_fd.h>
#include <core_jni_helpers.h>
#include <cutils/trace.h> #include <cutils/trace.h>
#include <endian.h>
#include <nativehelper/JNIHelp.h>
#include <sys/eventfd.h> #include <sys/eventfd.h>
#include <sys/poll.h> #include <sys/poll.h>
#include <nativehelper/JNIHelp.h>
#include <core_jni_helpers.h>
#include <endian.h>
#include "dataloader.h"
#include <charconv> #include <charconv>
#include <chrono> #include <chrono>
#include <span> #include <span>
@@ -40,6 +35,8 @@
#include <unordered_map> #include <unordered_map>
#include <unordered_set> #include <unordered_set>
#include "dataloader.h"
namespace android { namespace android {
namespace { namespace {
@@ -681,7 +678,7 @@ private:
auto& writeFd = writeFds[fileIdx]; auto& writeFd = writeFds[fileIdx];
if (writeFd < 0) { if (writeFd < 0) {
writeFd = this->mIfs->openWrite(fileId); writeFd.reset(this->mIfs->openWrite(fileId));
if (writeFd < 0) { if (writeFd < 0) {
ALOGE("Failed to open file %d for writing (%d). Aboring.", header.fileIdx, ALOGE("Failed to open file %d for writing (%d). Aboring.", header.fileIdx,
-writeFd); -writeFd);