diff options
Diffstat (limited to '')
-rw-r--r-- | minadbd/Android.bp | 2 | ||||
-rw-r--r-- | minadbd/minadbd_services.cpp | 14 | ||||
-rw-r--r-- | screen_ui.cpp | 1 | ||||
-rw-r--r-- | updater/blockimg.cpp | 21 |
4 files changed, 20 insertions, 18 deletions
diff --git a/minadbd/Android.bp b/minadbd/Android.bp index 370232b3f..a95d979a5 100644 --- a/minadbd/Android.bp +++ b/minadbd/Android.bp @@ -21,6 +21,8 @@ cc_defaults { "-Werror", ], + cpp_std: "experimental", + include_dirs: [ "system/core/adb", ], diff --git a/minadbd/minadbd_services.cpp b/minadbd/minadbd_services.cpp index e9c51da0a..9309ed749 100644 --- a/minadbd/minadbd_services.cpp +++ b/minadbd/minadbd_services.cpp @@ -23,6 +23,7 @@ #include <functional> #include <string> +#include <string_view> #include <thread> #include "adb.h" @@ -49,14 +50,13 @@ static void sideload_host_service(unique_fd sfd, const std::string& args) { exit(result == 0 ? 0 : 1); } -unique_fd daemon_service_to_fd(const char* name, atransport* /* transport */) { - if (!strncmp(name, "sideload:", 9)) { - // this exit status causes recovery to print a special error - // message saying to use a newer adb (that supports - // sideload-host). +unique_fd daemon_service_to_fd(std::string_view name, atransport* /* transport */) { + if (name.starts_with("sideload:")) { + // This exit status causes recovery to print a special error message saying to use a newer adb + // (that supports sideload-host). exit(3); - } else if (!strncmp(name, "sideload-host:", 14)) { - std::string arg(name + 14); + } else if (name.starts_with("sideload-host:")) { + std::string arg(name.substr(strlen("sideload-host:"))); return create_service_thread("sideload-host", std::bind(sideload_host_service, std::placeholders::_1, arg)); } diff --git a/screen_ui.cpp b/screen_ui.cpp index 575605452..7fa41c4e4 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -252,6 +252,7 @@ int GraphicMenu::DrawItems(int x, int y, int screen_width, bool long_press) cons draw_funcs_.SetColor(UIElement::MENU); } + offset += draw_funcs_.DrawHorizontalRule(y + offset); return offset; } diff --git a/updater/blockimg.cpp b/updater/blockimg.cpp index c4c09098e..9d5b01734 100644 --- a/updater/blockimg.cpp +++ b/updater/blockimg.cpp @@ -178,14 +178,18 @@ static bool SetPartitionUpdatedMarker(const std::string& marker) { return true; } -static bool discard_blocks(int fd, off64_t offset, uint64_t size) { - // Don't discard blocks unless the update is a retry run. - if (!is_retry) { +static bool discard_blocks(int fd, off64_t offset, uint64_t size, bool force = false) { + // Don't discard blocks unless the update is a retry run or force == true + if (!is_retry && !force) { return true; } uint64_t args[2] = { static_cast<uint64_t>(offset), size }; if (ioctl(fd, BLKDISCARD, &args) == -1) { + // On devices that does not support BLKDISCARD, ignore the error. + if (errno == EOPNOTSUPP) { + return true; + } PLOG(ERROR) << "BLKDISCARD ioctl failed"; return false; } @@ -1448,14 +1452,9 @@ static int PerformCommandErase(CommandParameters& params) { LOG(INFO) << " erasing " << tgt.blocks() << " blocks"; for (const auto& [begin, end] : tgt) { - uint64_t blocks[2]; - // offset in bytes - blocks[0] = begin * static_cast<uint64_t>(BLOCKSIZE); - // length in bytes - blocks[1] = (end - begin) * static_cast<uint64_t>(BLOCKSIZE); - - if (ioctl(params.fd, BLKDISCARD, &blocks) == -1) { - PLOG(ERROR) << "BLKDISCARD ioctl failed"; + off64_t offset = static_cast<off64_t>(begin) * BLOCKSIZE; + size_t size = (end - begin) * BLOCKSIZE; + if (!discard_blocks(params.fd, offset, size, true /* force */)) { return -1; } } |