diff options
Diffstat (limited to '')
-rw-r--r-- | Android.bp | 1 | ||||
-rw-r--r-- | Android.mk | 1 | ||||
-rw-r--r-- | bootloader_message/Android.bp | 26 | ||||
-rw-r--r-- | bootloader_message/Android.mk | 25 | ||||
-rw-r--r-- | recovery.cpp | 26 | ||||
-rw-r--r-- | updater/install.cpp | 8 |
6 files changed, 45 insertions, 42 deletions
diff --git a/Android.bp b/Android.bp index f919ebc83..49438ad9e 100644 --- a/Android.bp +++ b/Android.bp @@ -1,3 +1,4 @@ subdirs = [ + "bootloader_message", "otautil", ] diff --git a/Android.mk b/Android.mk index 1f69d5d5a..e619db031 100644 --- a/Android.mk +++ b/Android.mk @@ -185,7 +185,6 @@ include $(BUILD_STATIC_LIBRARY) include \ $(LOCAL_PATH)/applypatch/Android.mk \ $(LOCAL_PATH)/boot_control/Android.mk \ - $(LOCAL_PATH)/bootloader_message/Android.mk \ $(LOCAL_PATH)/edify/Android.mk \ $(LOCAL_PATH)/minadbd/Android.mk \ $(LOCAL_PATH)/minui/Android.mk \ diff --git a/bootloader_message/Android.bp b/bootloader_message/Android.bp new file mode 100644 index 000000000..f0d76e718 --- /dev/null +++ b/bootloader_message/Android.bp @@ -0,0 +1,26 @@ +// +// Copyright (C) 2017 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. +// + +cc_library_static { + name: "libbootloader_message", + srcs: ["bootloader_message.cpp"], + cppflags: ["-Werror"], + static_libs: [ + "libbase", + "libfs_mgr", + ], + export_include_dirs: ["include"], +} diff --git a/bootloader_message/Android.mk b/bootloader_message/Android.mk deleted file mode 100644 index a8c50819b..000000000 --- a/bootloader_message/Android.mk +++ /dev/null @@ -1,25 +0,0 @@ -# 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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_CLANG := true -LOCAL_SRC_FILES := bootloader_message.cpp -LOCAL_MODULE := libbootloader_message -LOCAL_STATIC_LIBRARIES := libbase libfs_mgr -LOCAL_CFLAGS := -Werror -LOCAL_C_INCLUDES := $(LOCAL_PATH)/include -LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include -include $(BUILD_STATIC_LIBRARY) diff --git a/recovery.cpp b/recovery.cpp index 944c24086..dfae7f03d 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -1304,20 +1304,20 @@ static bool is_battery_ok() { } } -static void set_retry_bootloader_message(int retry_count, int argc, char** argv) { - std::vector<std::string> options; - for (int i = 1; i < argc; ++i) { - if (strstr(argv[i], "retry_count") == nullptr) { - options.push_back(argv[i]); - } +static void set_retry_bootloader_message(int retry_count, const std::vector<std::string>& args) { + std::vector<std::string> options; + for (const auto& arg : args) { + if (!android::base::StartsWith(arg, "--retry_count")) { + options.push_back(arg); } + } - // Increment the retry counter by 1. - options.push_back(android::base::StringPrintf("--retry_count=%d", retry_count+1)); - std::string err; - if (!update_bootloader_message(options, &err)) { - LOG(ERROR) << err; - } + // Increment the retry counter by 1. + options.push_back(android::base::StringPrintf("--retry_count=%d", retry_count + 1)); + std::string err; + if (!update_bootloader_message(options, &err)) { + LOG(ERROR) << err; + } } static bool bootreason_in_blacklist() { @@ -1534,7 +1534,7 @@ int main(int argc, char **argv) { // times before we abandon this OTA update. if (status == INSTALL_RETRY && retry_count < EIO_RETRY_COUNT) { copy_logs(); - set_retry_bootloader_message(retry_count, argc, argv); + set_retry_bootloader_message(retry_count, args); // Print retry count on screen. ui->Print("Retry attempt %d\n", retry_count); diff --git a/updater/install.cpp b/updater/install.cpp index 888239c83..c5f9a89bb 100644 --- a/updater/install.cpp +++ b/updater/install.cpp @@ -317,9 +317,11 @@ Value* FormatFn(const char* name, State* state, const std::vector<std::unique_pt std::string num_sectors = std::to_string(size / 512); const char* f2fs_path = "/sbin/mkfs.f2fs"; - const char* const f2fs_argv[] = { "mkfs.f2fs", "-t", "-d1", location.c_str(), - num_sectors.c_str(), nullptr }; - int status = exec_cmd(f2fs_path, const_cast<char* const*>(f2fs_argv)); + const char* f2fs_argv[] = { + "mkfs.f2fs", "-t", "-d1", location.c_str(), (size < 512) ? nullptr : num_sectors.c_str(), + nullptr + }; + int status = exec_cmd(f2fs_path, const_cast<char**>(f2fs_argv)); if (status != 0) { LOG(ERROR) << name << ": mkfs.f2fs failed (" << status << ") on " << location; return StringValue(""); |