Commit 8373cfe2 authored by Ethan Yonker's avatar Ethan Yonker

Update to AOSP 8.0 base

Change-Id: I29fe722b4eb9718765327902779046840a01433e
parents 95e80075 43348a62
BasedOnStyle: Google
AllowShortBlocksOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: true
ColumnLimit: 100
CommentPragmas: NOLINT:.*
DerivePointerAlignment: false
IndentWidth: 2
PointerAlignment: Left
TabWidth: 2
UseTab: Never
PenaltyExcessCharacter: 32
Cpp11BracedListStyle: false
......@@ -104,24 +104,25 @@ LOCAL_CLANG := true
LOCAL_C_INCLUDES += \
system/vold \
system/extras/ext4_utils \
system/extras \
system/core/adb \
system/core/libsparse \
external/zlib
external/zlib \
$(LOCAL_PATH)/bootloader_message_twrp/include
LOCAL_C_INCLUDES += bionic
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0)
LOCAL_C_INCLUDES += external/stlport/stlport external/openssl/include
else
LOCAL_C_INCLUDES += external/boringssl/include
LOCAL_C_INCLUDES += external/boringssl/include external/libcxx/include
endif
LOCAL_STATIC_LIBRARIES :=
LOCAL_SHARED_LIBRARIES :=
LOCAL_STATIC_LIBRARIES += libguitwrp
LOCAL_SHARED_LIBRARIES += libaosprecovery libz libc libcutils libstdc++ libtar libblkid libminuitwrp libminadbd libmtdutils libminzip libtwadbbu libbootloader_message
LOCAL_SHARED_LIBRARIES += libcrecovery libtwadbbu libtwrpdigest
LOCAL_SHARED_LIBRARIES += libaosprecovery libz libc libcutils libstdc++ libtar libblkid libminuitwrp libminadbd libmtdutils libtwadbbu libbootloader_message_twrp
LOCAL_SHARED_LIBRARIES += libcrecovery libtwadbbu libtwrpdigest libc++
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0)
LOCAL_SHARED_LIBRARIES += libstlport
......@@ -132,13 +133,20 @@ ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 24; echo $$?),0)
LOCAL_C_INCLUDES += $(LOCAL_PATH)/libmincrypt/includes
LOCAL_CFLAGS += -DUSE_OLD_VERIFIER
else
LOCAL_SHARED_LIBRARIES += libc++ libcrypto
LOCAL_SHARED_LIBRARIES += libcrypto
endif
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 24; echo $$?),0)
LOCAL_SHARED_LIBRARIES += libbase
endif
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26; echo $$?),0)
LOCAL_SHARED_LIBRARIES += libziparchive
else
LOCAL_SHARED_LIBRARIES += libminzip
LOCAL_CFLAGS += -DUSE_MINZIP
endif
ifneq ($(wildcard system/core/libsparse/Android.mk),)
LOCAL_SHARED_LIBRARIES += libsparse
endif
......@@ -161,14 +169,14 @@ ifeq ($(TARGET_USERIMAGES_USE_EXT4), true)
endif
LOCAL_C_INCLUDES += external/libselinux/include
LOCAL_SHARED_LIBRARIES += libselinux
ifneq ($(TARGET_USERIMAGES_USE_EXT4), true)
LOCAL_CFLAGS += -DUSE_EXT4
LOCAL_C_INCLUDES += system/extras/ext4_utils
LOCAL_SHARED_LIBRARIES += libext4_utils
ifneq ($(wildcard external/lz4/Android.mk),)
LOCAL_STATIC_LIBRARIES += liblz4
endif
endif
#ifneq ($(TARGET_USERIMAGES_USE_EXT4), true)
# LOCAL_CFLAGS += -DUSE_EXT4
# LOCAL_C_INCLUDES += system/extras/ext4_utils
# LOCAL_SHARED_LIBRARIES += libext4_utils
# ifneq ($(wildcard external/lz4/Android.mk),)
# LOCAL_STATIC_LIBRARIES += liblz4
# endif
#endif
ifeq ($(AB_OTA_UPDATER),true)
LOCAL_CFLAGS += -DAB_OTA_UPDATER=1
......@@ -304,7 +312,7 @@ ifeq ($(TW_INCLUDE_CRYPTO), true)
endif
endif
WITH_CRYPTO_UTILS := \
$(if $(wildcard system/core/libcrypto_utils/Android.mk),true)
$(if $(wildcard system/core/libcrypto_utils/android_pubkey.c),true)
ifeq ($(TW_USE_MODEL_HARDWARE_ID_FOR_DEVICE_ID), true)
LOCAL_CFLAGS += -DTW_USE_MODEL_HARDWARE_ID_FOR_DEVICE_ID
endif
......@@ -370,7 +378,8 @@ LOCAL_ADDITIONAL_DEPENDENCIES += \
mkfs.fat \
permissive.sh \
simg2img_twrp \
libbootloader_message \
libbootloader_message_twrp \
init.recovery.hlthchrg.rc \
init.recovery.service.rc
ifneq ($(TARGET_ARCH), arm64)
......@@ -589,6 +598,37 @@ else
endif
include $(BUILD_SHARED_LIBRARY)
# libmounts (static library)
# ===============================
include $(CLEAR_VARS)
LOCAL_SRC_FILES := mounts.cpp
LOCAL_CLANG := true
LOCAL_CFLAGS := -Wall -Wno-unused-parameter -Werror
LOCAL_MODULE := libmounts
include $(BUILD_STATIC_LIBRARY)
# librecovery (static library)
# ===============================
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
install.cpp
LOCAL_CFLAGS := -Wno-unused-parameter -Werror
LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION)
ifeq ($(AB_OTA_UPDATER),true)
LOCAL_CFLAGS += -DAB_OTA_UPDATER=1
endif
LOCAL_MODULE := librecovery
LOCAL_STATIC_LIBRARIES := \
libminui \
libvintf_recovery \
libcrypto_utils \
libcrypto \
libbase
include $(BUILD_STATIC_LIBRARY)
# shared libaosprecovery for Apache code
# ===============================
include $(CLEAR_VARS)
......@@ -596,7 +636,7 @@ include $(CLEAR_VARS)
LOCAL_MODULE := libaosprecovery
LOCAL_MODULE_TAGS := eng optional
LOCAL_CFLAGS := -std=gnu++0x
LOCAL_SRC_FILES := adb_install.cpp asn1_decoder.cpp legacy_property_service.cpp set_metadata.cpp tw_atomic.cpp installcommand.cpp
LOCAL_SRC_FILES := adb_install.cpp legacy_property_service.cpp set_metadata.cpp tw_atomic.cpp installcommand.cpp zipwrap.cpp
LOCAL_SHARED_LIBRARIES += libc liblog libcutils libmtdutils libfusesideload libselinux libminzip
LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION)
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0)
......@@ -608,15 +648,23 @@ endif
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 24; echo $$?),0)
LOCAL_SHARED_LIBRARIES += libmincrypttwrp
LOCAL_C_INCLUDES += $(LOCAL_PATH)/libmincrypt/includes
LOCAL_SRC_FILES += verifier24/verifier.cpp
LOCAL_SRC_FILES += verifier24/verifier.cpp verifier24/asn1_decoder.cpp
LOCAL_CFLAGS += -DUSE_OLD_VERIFIER
else
LOCAL_SHARED_LIBRARIES += libcrypto libbase
LOCAL_SRC_FILES += verifier.cpp
LOCAL_SRC_FILES += verifier.cpp asn1_decoder.cpp
endif
ifeq ($(AB_OTA_UPDATER),true)
LOCAL_CFLAGS += -DAB_OTA_UPDATER=1
endif
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26; echo $$?),0)
LOCAL_SRC_FILES += otautil/ZipUtil.cpp otautil/SysUtil.cpp
LOCAL_SHARED_LIBRARIES += libziparchive libext4_utils libcrypto libcrypto_utils
LOCAL_STATIC_LIBRARIES += libvintf_recovery libfs_mgr liblogwrap libavb libvintf libtinyxml2 libz
LOCAL_WHOLE_STATIC_LIBRARIES +=
else
LOCAL_CFLAGS += -DUSE_MINZIP
endif
include $(BUILD_SHARED_LIBRARY)
......@@ -638,6 +686,7 @@ include $(LOCAL_PATH)/tests/Android.mk \
$(LOCAL_PATH)/edify/Android.mk \
$(LOCAL_PATH)/otafault/Android.mk \
$(LOCAL_PATH)/bootloader_message/Android.mk \
$(LOCAL_PATH)/bootloader_message_twrp/Android.mk \
$(LOCAL_PATH)/updater/Android.mk \
$(LOCAL_PATH)/update_verifier/Android.mk \
$(LOCAL_PATH)/applypatch/Android.mk
......@@ -647,6 +696,10 @@ ifeq ($(wildcard system/core/uncrypt/Android.mk),)
endif
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 22; echo $$?),0)
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 26; echo $$?),0)
TARGET_GLOBAL_CFLAGS += -DTW_USE_MINUI_WITH_DATA
CLANG_TARGET_GLOBAL_CFLAGS += -DTW_USE_MINUI_WITH_DATA
endif
include $(commands_recovery_local_path)/minadbd/Android.mk \
$(commands_recovery_local_path)/minui/Android.mk
else
......@@ -669,6 +722,7 @@ include $(commands_recovery_local_path)/injecttwrp/Android.mk \
$(commands_recovery_local_path)/libcrecovery/Android.mk \
$(commands_recovery_local_path)/libblkid/Android.mk \
$(commands_recovery_local_path)/minuitwrp/Android.mk \
$(commands_recovery_local_path)/otautil/Android.mk \
$(commands_recovery_local_path)/openaes/Android.mk \
$(commands_recovery_local_path)/toolbox/Android.mk \
$(commands_recovery_local_path)/twrpTarMain/Android.mk \
......
**Team Win Recovery Project (TWRP)**
You can find a compiling guide [here](http://forum.xda-developers.com/showthread.php?t=1943625 "Guide").
......@@ -28,6 +28,8 @@
#include "ui.h"
#include "cutils/properties.h"
#include "install.h"
#include "common.h"
#include "adb_install.h"
#include "minadbd/fuse_adb_provider.h"
#include "fuse_sideload.h"
......@@ -37,10 +39,7 @@
#include "verifier.h"
#endif
static RecoveryUI* ui = NULL;
void
set_usb_driver(bool enabled) {
static void set_usb_driver(bool enabled) {
int fd = open("/sys/class/android_usb/android0/enable", O_WRONLY);
if (fd < 0) {
/* These error messages show when built in older Android branches (e.g. Gingerbread)
......@@ -65,20 +64,18 @@ set_usb_driver(bool enabled) {
}
}
static void
stop_adbd() {
static void stop_adbd() {
printf("Stopping adbd...\n");
property_set("ctl.stop", "adbd");
set_usb_driver(false);
}
bool is_ro_debuggable() {
static bool is_ro_debuggable() {
char value[PROPERTY_VALUE_MAX+1];
return (property_get("ro.debuggable", value, NULL) == 1 && value[0] == '1');
}
void
maybe_restart_adbd() {
char value[PROPERTY_VALUE_MAX+1];
static void maybe_restart_adbd() {
if (is_ro_debuggable()) {
printf("Restarting adbd...\n");
set_usb_driver(true);
......@@ -96,6 +93,12 @@ apply_from_adb(const char* install_file, pid_t* child_pid) {
stop_adbd();
set_usb_driver(true);
/*
int apply_from_adb(RecoveryUI* ui, bool* wipe_cache, const char* install_file) {
modified_flash = true;
stop_adbd(ui);
set_usb_driver(ui, true);
ui->Print("\n\nNow send the package you want to apply\n"
"to the device with \"adb sideload <filename>\"...\n");
*/
......
......@@ -19,8 +19,8 @@
//class RecoveryUI;
void set_usb_driver(bool enabled);
void maybe_restart_adbd();
static void set_usb_driver(bool enabled);
static void maybe_restart_adbd();
int apply_from_adb(const char* install_file, pid_t* child_pid);
#endif
......@@ -31,6 +31,7 @@ $(foreach board_define,$(BOARD_RECOVERY_DEFINES), \
)
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/include \
external/bzip2 \
external/zlib \
$(commands_recovery_local_path)
......@@ -42,27 +43,99 @@ LOCAL_MODULE_TAGS := eng
LOCAL_C_INCLUDES += $(RECOVERY_PATH)
LOCAL_STATIC_LIBRARIES += libbase libotafault libmtdutils libcrypto_static libbz libz
# libapplypatch (static library)
# ===============================
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
applypatch.cpp \
bspatch.cpp \
freecache.cpp \
imgpatch.cpp
LOCAL_MODULE := libapplypatch
LOCAL_MODULE_TAGS := eng
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \
$(commands_recovery_local_path)
LOCAL_STATIC_LIBRARIES := \
libotafault \
libbase \
libcrypto \
libbspatch \
libbz \
libz
LOCAL_WHOLE_STATIC_LIBRARIES += libmtdutils
LOCAL_CFLAGS := \
-DZLIB_CONST \
-Werror
include $(BUILD_STATIC_LIBRARY)
# libimgpatch (static library)
# ===============================
include $(CLEAR_VARS)
ifeq ($(HOST_OS),linux)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
bspatch.cpp \
imgpatch.cpp
LOCAL_MODULE := libimgpatch
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \
$(commands_recovery_local_path)
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
LOCAL_STATIC_LIBRARIES := \
libcrypto \
libbspatch \
libbase \
libbz \
libz
LOCAL_CFLAGS := \
-DZLIB_CONST \
-Werror
include $(BUILD_STATIC_LIBRARY)
LOCAL_CLANG := true
LOCAL_SRC_FILES := bspatch.cpp imgpatch.cpp utils.cpp
# libimgpatch (host static library)
# ===============================
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
bspatch.cpp \
imgpatch.cpp
LOCAL_MODULE := libimgpatch
LOCAL_C_INCLUDES += $(RECOVERY_PATH)
LOCAL_MODULE_HOST_OS := linux
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \
$(commands_recovery_local_path)
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
LOCAL_STATIC_LIBRARIES += libcrypto_static libbz libz
LOCAL_STATIC_LIBRARIES := \
libcrypto \
libbspatch \
libbase \
libbz \
libz
LOCAL_CFLAGS := \
-DZLIB_CONST \
-Werror
include $(BUILD_HOST_STATIC_LIBRARY)
endif # HOST_OS == linux
# libapplypatch_modes (static library)
# ===============================
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
applypatch_modes.cpp
LOCAL_MODULE := libapplypatch_modes
LOCAL_C_INCLUDES := $(commands_recovery_local_path)
LOCAL_STATIC_LIBRARIES := \
libapplypatch \
libbase \
libedify \
libcrypto
LOCAL_CFLAGS := -Werror
include $(BUILD_STATIC_LIBRARY)
LOCAL_CLANG := true
LOCAL_SRC_FILES := main.cpp
# applypatch (target executable)
# ===============================
include $(CLEAR_VARS)
LOCAL_SRC_FILES := applypatch_main.cpp
LOCAL_MODULE := applypatch
LOCAL_C_INCLUDES += $(RECOVERY_PATH)
LOCAL_STATIC_LIBRARIES += libapplypatch libbase libotafault libmtdutils libcrypto_static libbz \
......@@ -70,15 +143,78 @@ LOCAL_STATIC_LIBRARIES += libapplypatch libbase libotafault libmtdutils libcrypt
LOCAL_SHARED_LIBRARIES += libz libcutils libc
LOCAL_C_INCLUDES := $(commands_recovery_local_path)
LOCAL_STATIC_LIBRARIES := \
libapplypatch_modes \
libapplypatch \
libbase \
libedify \
libotafault \
libcrypto \
libbspatch \
libbz
LOCAL_SHARED_LIBRARIES := \
libbase \
libz \
libcutils
LOCAL_CFLAGS := -Werror
include $(BUILD_EXECUTABLE)
libimgdiff_src_files := imgdiff.cpp
# libbsdiff is compiled with -D_FILE_OFFSET_BITS=64.
libimgdiff_cflags := \
-Werror \
-D_FILE_OFFSET_BITS=64
libimgdiff_static_libraries := \
libbsdiff \
libdivsufsort \
libdivsufsort64 \
libziparchive \
libutils \
liblog \
libbase \
libz
# libimgdiff (static library)
# ===============================
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(libimgdiff_src_files)
LOCAL_MODULE := libimgdiff
LOCAL_CFLAGS := \
$(libimgdiff_cflags)
LOCAL_STATIC_LIBRARIES := \
$(libimgdiff_static_libraries)
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
include $(BUILD_STATIC_LIBRARY)
LOCAL_CLANG := true
LOCAL_SRC_FILES := imgdiff.cpp utils.cpp bsdiff.cpp
LOCAL_MODULE := imgdiff
LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_C_INCLUDES += external/zlib external/bzip2
LOCAL_STATIC_LIBRARIES += libz libbz
# libimgdiff (host static library)
# ===============================
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(libimgdiff_src_files)
LOCAL_MODULE := libimgdiff
LOCAL_CFLAGS := \
$(libimgdiff_cflags)
LOCAL_STATIC_LIBRARIES := \
$(libimgdiff_static_libraries)
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
include $(BUILD_HOST_STATIC_LIBRARY)
# imgdiff (host static executable)
# ===============================
include $(CLEAR_VARS)
LOCAL_SRC_FILES := imgdiff_main.cpp
LOCAL_MODULE := imgdiff
LOCAL_CFLAGS := -Werror
LOCAL_STATIC_LIBRARIES := \
libimgdiff \
$(libimgdiff_static_libraries) \
libbz
include $(BUILD_HOST_EXECUTABLE)
# Copyright (C) 2016 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This file is for building imgdiff in Chrome OS.
CPPFLAGS += -iquote.. -Iinclude
CXXFLAGS += -std=c++11 -O3 -Wall -Werror
LDLIBS += -lbz2 -lz
.PHONY: all clean
all: imgdiff libimgpatch.a
clean:
rm -f *.o imgdiff libimgpatch.a
imgdiff: imgdiff.o bsdiff.o utils.o
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDLIBS) -o $@ $^
libimgpatch.a utils.o: CXXFLAGS += -fPIC
libimgpatch.a: imgpatch.o bspatch.o utils.o
${AR} rcs $@ $^
......@@ -14,6 +14,8 @@
* limitations under the License.
*/
#include "applypatch/applypatch.h"
#include <errno.h>
#include <fcntl.h>
#include <libgen.h>
......@@ -27,72 +29,65 @@
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include <android-base/logging.h>
#include <android-base/parseint.h>
#include <android-base/strings.h>
#include <openssl/sha.h>
#include "openssl/sha.h"
#include "applypatch.h"
#include "bmlutils/bmlutils.h"
#include "mtdutils/mtdutils.h"
#include "edify/expr.h"
#include "ota_io.h"
#include "print_sha1.h"
static int LoadPartitionContents(const char* filename, FileContents* file);
static int LoadPartitionContents(const std::string& filename, FileContents* file);
static ssize_t FileSink(const unsigned char* data, ssize_t len, void* token);
static int GenerateTarget(FileContents* source_file,
const Value* source_patch_value,
FileContents* copy_file,
const Value* copy_patch_value,
const char* source_filename,
const char* target_filename,
const uint8_t target_sha1[SHA_DIGEST_LENGTH],
size_t target_size,
const Value* bonus_data);
static int GenerateTarget(const FileContents& source_file, const std::unique_ptr<Value>& patch,
const std::string& target_filename,
const uint8_t target_sha1[SHA_DIGEST_LENGTH], const Value* bonus_data);
static bool mtd_partitions_scanned = false;
// Read a file into memory; store the file contents and associated
// metadata in *file.
//
// Read a file into memory; store the file contents and associated metadata in *file.
// Return 0 on success.
int LoadFileContents(const char* filename, FileContents* file) {
// A special 'filename' beginning with "MTD:" or "EMMC:" means to
// load the contents of a partition.
if (strncmp(filename, "MTD:", 4) == 0 ||
strncmp(filename, "EMMC:", 5) == 0 ||
strncmp(filename, "BML:", 4) == 0) {
return LoadPartitionContents(filename, file);
}
if (stat(filename, &file->st) != 0) {
printf("failed to stat \"%s\": %s\n", filename, strerror(errno));
return -1;
}
// A special 'filename' beginning with "MTD:" or "EMMC:" means to
// load the contents of a partition.
if (strncmp(filename, "MTD:", 4) == 0 ||
strncmp(filename, "EMMC:", 5) == 0 ||
strncmp(filename, "BML:", 4) == 0) {
return LoadPartitionContents(filename, file);
}
if (stat(filename, &file->st) == -1) {
printf("failed to stat \"%s\": %s\n", filename, strerror(errno));
return -1;
}
std::vector<unsigned char> data(file->st.st_size);
FILE* f = ota_fopen(filename, "rb");
if (f == NULL) {
printf("failed to open \"%s\": %s\n", filename, strerror(errno));
return -1;
}
std::vector<unsigned char> data(file->st.st_size);
unique_file f(ota_fopen(filename, "rb"));
if (!f) {
printf("failed to open \"%s\": %s\n", filename, strerror(errno));
return -1;
}
size_t bytes_read = ota_fread(data.data(), 1, data.size(), f);
if (bytes_read != data.size()) {
printf("short read of \"%s\" (%zu bytes of %zd)\n", filename, bytes_read, data.size());
ota_fclose(f);
return -1;
}
ota_fclose(f);
file->data = std::move(data);
SHA1(file->data.data(), file->data.size(), file->sha1);
return 0;
size_t bytes_read = ota_fread(data.data(), 1, data.size(), f.get());
if (bytes_read != data.size()) {
printf("short read of \"%s\" (%zu bytes of %zu)\n", filename, bytes_read, data.size());
return -1;
}
file->data = std::move(data);
SHA1(file->data.data(), file->data.size(), file->sha1);
return 0;
}
// Load the contents of an MTD or EMMC partition into the provided
// Load the contents of an EMMC partition into the provided
// FileContents. filename should be a string of the form
// "MTD:<partition_name>:<size_1>:<sha1_1>:<size_2>:<sha1_2>:..." (or
// "EMMC:<partition_device>:..."). The smallest size_n bytes for
// "EMMC:<partition_device>:...". The smallest size_n bytes for
// which that prefix of the partition contents has the corresponding
// sha1 hash will be loaded. It is acceptable for a size value to be
// repeated with different sha1s. Will return 0 on success.
......@@ -106,223 +101,166 @@ int LoadFileContents(const char* filename, FileContents* file) {
// to find one of those hashes.
enum PartitionType { MTD, EMMC };
static int LoadPartitionContents(const char* filename, FileContents* file) {
std::string copy(filename);
std::vector<std::string> pieces = android::base::Split(copy, ":");
if (pieces.size() < 4 || pieces.size() % 2 != 0) {