Merge "Some clean ups to the updater"

am: 52e61f6995

Change-Id: I515d9cd9cf0d3b82fd2a28ccfcef8e2eea1e5683
This commit is contained in:
Tianjie Xu
2019-05-23 22:44:44 -07:00
committed by android-build-merger
6 changed files with 16 additions and 14 deletions
+3 -1
View File
@@ -85,7 +85,7 @@ static void expect(const char* expected, const std::string& expr_str, CauseCode
} }
static void expect(const char* expected, const std::string& expr_str, CauseCode cause_code) { static void expect(const char* expected, const std::string& expr_str, CauseCode cause_code) {
Updater updater; Updater updater(std::make_unique<UpdaterRuntime>(nullptr));
expect(expected, expr_str, cause_code, &updater); expect(expected, expr_str, cause_code, &updater);
} }
@@ -133,6 +133,8 @@ static Value* BlobToString(const char* name, State* state,
class UpdaterTestBase { class UpdaterTestBase {
protected: protected:
UpdaterTestBase() : updater_(std::make_unique<UpdaterRuntime>(nullptr)) {}
void SetUp() { void SetUp() {
RegisterBuiltins(); RegisterBuiltins();
RegisterInstallFunctions(); RegisterInstallFunctions();
+8 -4
View File
@@ -49,7 +49,6 @@
#include <brotli/decode.h> #include <brotli/decode.h>
#include <fec/io.h> #include <fec/io.h>
#include <openssl/sha.h> #include <openssl/sha.h>
#include <private/android_filesystem_config.h>
#include <verity/hash_tree_builder.h> #include <verity/hash_tree_builder.h>
#include <ziparchive/zip_archive.h> #include <ziparchive/zip_archive.h>
@@ -63,10 +62,15 @@
#include "private/commands.h" #include "private/commands.h"
#include "updater/install.h" #include "updater/install.h"
// Set this to 0 to interpret 'erase' transfers to mean do a #ifdef __ANDROID__
// BLKDISCARD ioctl (the normal behavior). Set to 1 to interpret #include <private/android_filesystem_config.h>
// erase to mean fill the region with zeroes. // Set this to 0 to interpret 'erase' transfers to mean do a BLKDISCARD ioctl (the normal behavior).
// Set to 1 to interpret erase to mean fill the region with zeroes.
#define DEBUG_ERASE 0 #define DEBUG_ERASE 0
#else
#define DEBUG_ERASE 1
#define AID_SYSTEM -1
#endif // __ANDROID__
static constexpr size_t BLOCKSIZE = 4096; static constexpr size_t BLOCKSIZE = 4096;
static constexpr mode_t STASH_DIRECTORY_MODE = 0700; static constexpr mode_t STASH_DIRECTORY_MODE = 0700;
-4
View File
@@ -30,15 +30,11 @@
#include "otautil/error_code.h" #include "otautil/error_code.h"
#include "otautil/sysutil.h" #include "otautil/sysutil.h"
class UpdaterRuntime;
class Updater : public UpdaterInterface { class Updater : public UpdaterInterface {
public: public:
explicit Updater(std::unique_ptr<UpdaterRuntimeInterface> run_time) explicit Updater(std::unique_ptr<UpdaterRuntimeInterface> run_time)
: runtime_(std::move(run_time)) {} : runtime_(std::move(run_time)) {}
Updater();
~Updater() override; ~Updater() override;
// Memory-maps the OTA package and opens it as a zip file. Also sets up the command pipe and // Memory-maps the OTA package and opens it as a zip file. Also sets up the command pipe and
@@ -25,7 +25,6 @@
#include "edify/updater_runtime_interface.h" #include "edify/updater_runtime_interface.h"
struct selabel_handle; struct selabel_handle;
struct Partition;
class UpdaterRuntime : public UpdaterRuntimeInterface { class UpdaterRuntime : public UpdaterRuntimeInterface {
public: public:
+4 -1
View File
@@ -53,7 +53,6 @@
#include <openssl/sha.h> #include <openssl/sha.h>
#include <selinux/label.h> #include <selinux/label.h>
#include <selinux/selinux.h> #include <selinux/selinux.h>
#include <tune2fs.h>
#include <ziparchive/zip_archive.h> #include <ziparchive/zip_archive.h>
#include "edify/expr.h" #include "edify/expr.h"
@@ -65,6 +64,10 @@
#include "otautil/print_sha1.h" #include "otautil/print_sha1.h"
#include "otautil/sysutil.h" #include "otautil/sysutil.h"
#ifndef __ANDROID__
#include <cutils/memory.h> // for strlcpy
#endif
static bool UpdateBlockDeviceNameForPartition(UpdaterInterface* updater, Partition* partition) { static bool UpdateBlockDeviceNameForPartition(UpdaterInterface* updater, Partition* partition) {
CHECK(updater); CHECK(updater);
std::string name = updater->FindBlockDeviceName(partition->name); std::string name = updater->FindBlockDeviceName(partition->name);
+1 -3
View File
@@ -24,9 +24,7 @@
#include <android-base/logging.h> #include <android-base/logging.h>
#include <android-base/strings.h> #include <android-base/strings.h>
#include "updater/updater_runtime.h" #include "edify/updater_runtime_interface.h"
Updater::Updater() : Updater(std::make_unique<UpdaterRuntime>(nullptr)) {}
Updater::~Updater() { Updater::~Updater() {
if (package_handle_) { if (package_handle_) {