summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Android.mk2
-rw-r--r--install.cpp2
-rw-r--r--minadbd/minadbd_services.cpp16
-rw-r--r--recovery.cpp16
-rw-r--r--tests/component/applypatch_test.cpp51
5 files changed, 23 insertions, 64 deletions
diff --git a/Android.mk b/Android.mk
index adf478f00..5e2dddec4 100644
--- a/Android.mk
+++ b/Android.mk
@@ -45,7 +45,7 @@ include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
install.cpp
-LOCAL_CFLAGS := -Wno-unused-parameter -Werror
+LOCAL_CFLAGS := -Wall -Werror
LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION)
ifeq ($(AB_OTA_UPDATER),true)
diff --git a/install.cpp b/install.cpp
index e5a59b832..e945d13ab 100644
--- a/install.cpp
+++ b/install.cpp
@@ -211,7 +211,7 @@ static int check_newer_ab_build(ZipArchiveHandle zip) {
return 0;
}
-int update_binary_command(const std::string& path, ZipArchiveHandle zip, int retry_count,
+int update_binary_command(const std::string& path, ZipArchiveHandle zip, int /* retry_count */,
int status_fd, std::vector<std::string>* cmd) {
CHECK(cmd != nullptr);
int ret = check_newer_ab_build(zip);
diff --git a/minadbd/minadbd_services.cpp b/minadbd/minadbd_services.cpp
index a6aa321ca..61c06cc0a 100644
--- a/minadbd/minadbd_services.cpp
+++ b/minadbd/minadbd_services.cpp
@@ -21,6 +21,7 @@
#include <string.h>
#include <unistd.h>
+#include <string>
#include <thread>
#include "adb.h"
@@ -28,33 +29,30 @@
#include "fuse_adb_provider.h"
#include "sysdeps.h"
-static void sideload_host_service(int sfd, void* data) {
- char* args = reinterpret_cast<char*>(data);
+static void sideload_host_service(int sfd, const std::string& args) {
int file_size;
int block_size;
- if (sscanf(args, "%d:%d", &file_size, &block_size) != 2) {
- printf("bad sideload-host arguments: %s\n", args);
+ if (sscanf(args.c_str(), "%d:%d", &file_size, &block_size) != 2) {
+ printf("bad sideload-host arguments: %s\n", args.c_str());
exit(1);
}
- free(args);
printf("sideload-host file size %d block size %d\n", file_size, block_size);
int result = run_adb_fuse(sfd, file_size, block_size);
printf("sideload_host finished\n");
- sleep(1);
exit(result == 0 ? 0 : 1);
}
-static int create_service_thread(void (*func)(int, void *), void *cookie) {
+static int create_service_thread(void (*func)(int, const std::string&), const std::string& args) {
int s[2];
if (adb_socketpair(s)) {
printf("cannot create service socket pair\n");
return -1;
}
- std::thread([s, func, cookie]() { func(s[1], cookie); }).detach();
+ std::thread([s, func, args]() { func(s[1], args); }).detach();
VLOG(SERVICES) << "service thread started, " << s[0] << ":" << s[1];
return s[0];
@@ -69,7 +67,7 @@ int service_to_fd(const char* name, const atransport* transport) {
// sideload-host).
exit(3);
} else if (!strncmp(name, "sideload-host:", 14)) {
- char* arg = strdup(name + 14);
+ std::string arg(name + 14);
ret = create_service_thread(sideload_host_service, arg);
}
if (ret >= 0) {
diff --git a/recovery.cpp b/recovery.cpp
index b24efa963..99126eedc 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -1593,14 +1593,22 @@ int main(int argc, char **argv) {
}
}
- if (!sideload_auto_reboot && (status == INSTALL_ERROR || status == INSTALL_CORRUPT)) {
- copy_logs();
+ if (status == INSTALL_ERROR || status == INSTALL_CORRUPT) {
ui->SetBackground(RecoveryUI::ERROR);
+ if (!ui->IsTextVisible()) {
+ sleep(5);
+ }
}
Device::BuiltinAction after = shutdown_after ? Device::SHUTDOWN : Device::REBOOT;
- if ((status != INSTALL_SUCCESS && status != INSTALL_SKIPPED && !sideload_auto_reboot) ||
- ui->IsTextVisible()) {
+ // 1. If the recovery menu is visible, prompt and wait for commands.
+ // 2. If the state is INSTALL_NONE, wait for commands. (i.e. In user build, manually reboot into
+ // recovery to sideload a package.)
+ // 3. sideload_auto_reboot is an option only available in user-debug build, reboot the device
+ // without waiting.
+ // 4. In all other cases, reboot the device. Therefore, normal users will observe the device
+ // reboot after it shows the "error" screen for 5s.
+ if ((status == INSTALL_NONE && !sideload_auto_reboot) || ui->IsTextVisible()) {
Device::BuiltinAction temp = prompt_and_wait(device, status);
if (temp != Device::NO_ACTION) {
after = temp;
diff --git a/tests/component/applypatch_test.cpp b/tests/component/applypatch_test.cpp
index 5cba68f8a..6fdf78e47 100644
--- a/tests/component/applypatch_test.cpp
+++ b/tests/component/applypatch_test.cpp
@@ -105,9 +105,6 @@ class ApplyPatchTest : public ::testing::Test {
static size_t new_size;
};
-std::string ApplyPatchTest::old_file;
-std::string ApplyPatchTest::new_file;
-
static void cp(const std::string& src, const std::string& tgt) {
std::string cmd = "cp " + src + " " + tgt;
system(cmd.c_str());
@@ -132,48 +129,8 @@ class ApplyPatchCacheTest : public ApplyPatchTest {
}
};
-class ApplyPatchFullTest : public ApplyPatchCacheTest {
- public:
- static void SetUpTestCase() {
- ApplyPatchTest::SetUpTestCase();
-
- output_f = new TemporaryFile();
- output_loc = std::string(output_f->path);
-
- struct FileContents fc;
-
- ASSERT_EQ(0, LoadFileContents(&rand_file[0], &fc));
- patches.push_back(
- std::make_unique<Value>(VAL_BLOB, std::string(fc.data.begin(), fc.data.end())));
-
- ASSERT_EQ(0, LoadFileContents(&patch_file[0], &fc));
- patches.push_back(
- std::make_unique<Value>(VAL_BLOB, std::string(fc.data.begin(), fc.data.end())));
- }
-
- static void TearDownTestCase() {
- delete output_f;
- patches.clear();
- }
-
- static std::vector<std::unique_ptr<Value>> patches;
- static TemporaryFile* output_f;
- static std::string output_loc;
-};
-
-class ApplyPatchDoubleCacheTest : public ApplyPatchFullTest {
- public:
- virtual void SetUp() {
- ApplyPatchCacheTest::SetUp();
- cp(cache_file, "/cache/reallysaved.file");
- }
-
- virtual void TearDown() {
- cp("/cache/reallysaved.file", cache_file);
- ApplyPatchCacheTest::TearDown();
- }
-};
-
+std::string ApplyPatchTest::old_file;
+std::string ApplyPatchTest::new_file;
std::string ApplyPatchTest::rand_file;
std::string ApplyPatchTest::patch_file;
std::string ApplyPatchTest::cache_file;
@@ -184,10 +141,6 @@ std::string ApplyPatchTest::bad_sha1_b;
size_t ApplyPatchTest::old_size;
size_t ApplyPatchTest::new_size;
-std::vector<std::unique_ptr<Value>> ApplyPatchFullTest::patches;
-TemporaryFile* ApplyPatchFullTest::output_f;
-std::string ApplyPatchFullTest::output_loc;
-
TEST_F(ApplyPatchTest, CheckModeSkip) {
std::vector<std::string> sha1s;
ASSERT_EQ(0, applypatch_check(&old_file[0], sha1s));