summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Android.bp3
-rw-r--r--CleanSpec.mk4
-rw-r--r--README.md2
-rw-r--r--TEST_MAPPING14
-rw-r--r--fsck_unshare_blocks.cpp1
-rw-r--r--install/Android.bp2
-rw-r--r--install/include/install/install.h3
-rw-r--r--install/include/install/wipe_device.h29
-rw-r--r--install/wipe_device.cpp198
-rw-r--r--minui/resources.cpp18
-rw-r--r--otautil/Android.bp4
-rw-r--r--otautil/include/otautil/sysutil.h15
-rw-r--r--otautil/sysutil.cpp13
-rw-r--r--recovery.cpp173
-rw-r--r--recovery_main.cpp19
-rw-r--r--recovery_ui/include/recovery_ui/ui.h2
-rw-r--r--recovery_ui/screen_ui.cpp20
-rw-r--r--recovery_ui/ui.cpp2
-rw-r--r--tests/Android.bp47
-rw-r--r--tests/AndroidTest.xml33
-rw-r--r--tests/component/resources_test.cpp120
-rw-r--r--tests/unit/applypatch_modes_test.cpp (renamed from tests/component/applypatch_modes_test.cpp)0
-rw-r--r--tests/unit/bootloader_message_test.cpp (renamed from tests/component/bootloader_message_test.cpp)0
-rw-r--r--tests/unit/edify_test.cpp (renamed from tests/component/edify_test.cpp)0
-rw-r--r--tests/unit/fuse_sideload_test.cpp (renamed from tests/component/sideload_test.cpp)0
-rw-r--r--tests/unit/imgdiff_test.cpp (renamed from tests/component/imgdiff_test.cpp)0
-rw-r--r--tests/unit/install_test.cpp (renamed from tests/component/install_test.cpp)1
-rw-r--r--tests/unit/locale_test.cpp4
-rw-r--r--tests/unit/resources_test.cpp99
-rw-r--r--tests/unit/uncrypt_test.cpp (renamed from tests/component/uncrypt_test.cpp)0
-rw-r--r--tests/unit/update_verifier_test.cpp (renamed from tests/component/update_verifier_test.cpp)0
-rw-r--r--tests/unit/updater_test.cpp (renamed from tests/component/updater_test.cpp)0
-rw-r--r--tests/unit/verifier_test.cpp (renamed from tests/component/verifier_test.cpp)0
-rw-r--r--tools/recovery_l10n/res/values-gl/strings.xml4
-rw-r--r--tools/recovery_l10n/res/values-ja/strings.xml2
-rw-r--r--updater/install.cpp2
36 files changed, 434 insertions, 400 deletions
diff --git a/Android.bp b/Android.bp
index f92078256..0eb5fd9e5 100644
--- a/Android.bp
+++ b/Android.bp
@@ -76,7 +76,6 @@ cc_defaults {
// external dependencies
"libhealthhalutils",
- "libfstab",
],
}
@@ -150,7 +149,6 @@ cc_binary {
static_libs: [
"libotautil",
- "libfstab",
],
init_rc: [
@@ -177,7 +175,6 @@ cc_binary {
static_libs: [
"libotautil",
- "libfstab",
],
init_rc: [
diff --git a/CleanSpec.mk b/CleanSpec.mk
index a7ab0d9be..6bd1eb170 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -51,6 +51,10 @@ $(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/sbin)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libinstall.recovery_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/system/lib64/libinstall.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/nativetest/recovery_component_test)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/nativetest64/recovery_component_test)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/testcases/recovery_component_test)
+
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
diff --git a/README.md b/README.md
index efcd318b5..0ccc10b50 100644
--- a/README.md
+++ b/README.md
@@ -22,11 +22,9 @@ Running the tests
# 32-bit device
adb shell /data/nativetest/recovery_unit_test/recovery_unit_test
- adb shell /data/nativetest/recovery_component_test/recovery_component_test
# Or 64-bit device
adb shell /data/nativetest64/recovery_unit_test/recovery_unit_test
- adb shell /data/nativetest64/recovery_component_test/recovery_component_test
Running the manual tests
------------------------
diff --git a/TEST_MAPPING b/TEST_MAPPING
new file mode 100644
index 000000000..a3045828e
--- /dev/null
+++ b/TEST_MAPPING
@@ -0,0 +1,14 @@
+{
+ "presubmit": [
+ {
+ "name": "minadbd_test"
+ },
+ {
+ "name": "recovery_unit_test"
+ },
+ {
+ "name": "recovery_host_test",
+ "host": true
+ }
+ ]
+}
diff --git a/fsck_unshare_blocks.cpp b/fsck_unshare_blocks.cpp
index e74f8ba6f..0f8ffface 100644
--- a/fsck_unshare_blocks.cpp
+++ b/fsck_unshare_blocks.cpp
@@ -34,7 +34,6 @@
#include <android-base/logging.h>
#include <android-base/properties.h>
#include <android-base/unique_fd.h>
-#include <fstab/fstab.h>
#include "otautil/roots.h"
diff --git a/install/Android.bp b/install/Android.bp
index ea893a075..4696e501e 100644
--- a/install/Android.bp
+++ b/install/Android.bp
@@ -47,7 +47,6 @@ cc_defaults {
// external dependencies
"libvintf_recovery",
"libvintf",
- "libfstab",
],
}
@@ -67,6 +66,7 @@ cc_library_static {
"package.cpp",
"verifier.cpp",
"wipe_data.cpp",
+ "wipe_device.cpp",
],
shared_libs: [
diff --git a/install/include/install/install.h b/install/include/install/install.h
index c0a8f1f4c..d90c20f3a 100644
--- a/install/include/install/install.h
+++ b/install/include/install/install.h
@@ -58,9 +58,6 @@ bool verify_package(Package* package, RecoveryUI* ui);
// result to |metadata|. Return true if succeed, otherwise return false.
bool ReadMetadataFromPackage(ZipArchiveHandle zip, std::map<std::string, std::string>* metadata);
-// Reads the "recovery.wipe" entry in the zip archive returns a list of partitions to wipe.
-std::vector<std::string> GetWipePartitionList(Package* wipe_package);
-
// Verifies the compatibility info in a Treble-compatible package. Returns true directly if the
// entry doesn't exist.
bool verify_package_compatibility(ZipArchiveHandle package_zip);
diff --git a/install/include/install/wipe_device.h b/install/include/install/wipe_device.h
new file mode 100644
index 000000000..c60b99997
--- /dev/null
+++ b/install/include/install/wipe_device.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#pragma once
+
+#include <string>
+#include <vector>
+
+#include "install/package.h"
+#include "recovery_ui/device.h"
+
+// Wipes the current A/B device, with a secure wipe of all the partitions in RECOVERY_WIPE.
+bool WipeAbDevice(Device* device, size_t wipe_package_size);
+
+// Reads the "recovery.wipe" entry in the zip archive returns a list of partitions to wipe.
+std::vector<std::string> GetWipePartitionList(Package* wipe_package);
diff --git a/install/wipe_device.cpp b/install/wipe_device.cpp
new file mode 100644
index 000000000..72b96f7b4
--- /dev/null
+++ b/install/wipe_device.cpp
@@ -0,0 +1,198 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#include "install/wipe_device.h"
+
+#include <errno.h>
+#include <fcntl.h>
+#include <linux/fs.h>
+#include <stdint.h>
+#include <sys/ioctl.h>
+
+#include <map>
+#include <memory>
+#include <string>
+#include <vector>
+
+#include <android-base/file.h>
+#include <android-base/logging.h>
+#include <android-base/strings.h>
+#include <android-base/unique_fd.h>
+#include <ziparchive/zip_archive.h>
+
+#include "bootloader_message/bootloader_message.h"
+#include "install/install.h"
+#include "install/package.h"
+#include "recovery_ui/device.h"
+#include "recovery_ui/ui.h"
+
+std::vector<std::string> GetWipePartitionList(Package* wipe_package) {
+ ZipArchiveHandle zip = wipe_package->GetZipArchiveHandle();
+ if (!zip) {
+ LOG(ERROR) << "Failed to get ZipArchiveHandle";
+ return {};
+ }
+
+ constexpr char RECOVERY_WIPE_ENTRY_NAME[] = "recovery.wipe";
+
+ std::string partition_list_content;
+ ZipString path(RECOVERY_WIPE_ENTRY_NAME);
+ ZipEntry entry;
+ if (FindEntry(zip, path, &entry) == 0) {
+ uint32_t length = entry.uncompressed_length;
+ partition_list_content = std::string(length, '\0');
+ if (auto err = ExtractToMemory(
+ zip, &entry, reinterpret_cast<uint8_t*>(partition_list_content.data()), length);
+ err != 0) {
+ LOG(ERROR) << "Failed to extract " << RECOVERY_WIPE_ENTRY_NAME << ": "
+ << ErrorCodeString(err);
+ return {};
+ }
+ } else {
+ LOG(INFO) << "Failed to find " << RECOVERY_WIPE_ENTRY_NAME
+ << ", falling back to use the partition list on device.";
+
+ constexpr char RECOVERY_WIPE_ON_DEVICE[] = "/etc/recovery.wipe";
+ if (!android::base::ReadFileToString(RECOVERY_WIPE_ON_DEVICE, &partition_list_content)) {
+ PLOG(ERROR) << "failed to read \"" << RECOVERY_WIPE_ON_DEVICE << "\"";
+ return {};
+ }
+ }
+
+ std::vector<std::string> result;
+ auto lines = android::base::Split(partition_list_content, "\n");
+ for (const auto& line : lines) {
+ auto partition = android::base::Trim(line);
+ // Ignore '#' comment or empty lines.
+ if (android::base::StartsWith(partition, "#") || partition.empty()) {
+ continue;
+ }
+ result.push_back(line);
+ }
+
+ return result;
+}
+
+// Secure-wipes a given partition. It uses BLKSECDISCARD, if supported. Otherwise, it goes with
+// BLKDISCARD (if device supports BLKDISCARDZEROES) or BLKZEROOUT.
+static bool SecureWipePartition(const std::string& partition) {
+ android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(partition.c_str(), O_WRONLY)));
+ if (fd == -1) {
+ PLOG(ERROR) << "Failed to open \"" << partition << "\"";
+ return false;
+ }
+
+ uint64_t range[2] = { 0, 0 };
+ if (ioctl(fd, BLKGETSIZE64, &range[1]) == -1 || range[1] == 0) {
+ PLOG(ERROR) << "Failed to get partition size";
+ return false;
+ }
+ LOG(INFO) << "Secure-wiping \"" << partition << "\" from " << range[0] << " to " << range[1];
+
+ LOG(INFO) << " Trying BLKSECDISCARD...";
+ if (ioctl(fd, BLKSECDISCARD, &range) == -1) {
+ PLOG(WARNING) << " Failed";
+
+ // Use BLKDISCARD if it zeroes out blocks, otherwise use BLKZEROOUT.
+ unsigned int zeroes;
+ if (ioctl(fd, BLKDISCARDZEROES, &zeroes) == 0 && zeroes != 0) {
+ LOG(INFO) << " Trying BLKDISCARD...";
+ if (ioctl(fd, BLKDISCARD, &range) == -1) {
+ PLOG(ERROR) << " Failed";
+ return false;
+ }
+ } else {
+ LOG(INFO) << " Trying BLKZEROOUT...";
+ if (ioctl(fd, BLKZEROOUT, &range) == -1) {
+ PLOG(ERROR) << " Failed";
+ return false;
+ }
+ }
+ }
+
+ LOG(INFO) << " Done";
+ return true;
+}
+
+static std::unique_ptr<Package> ReadWipePackage(size_t wipe_package_size) {
+ if (wipe_package_size == 0) {
+ LOG(ERROR) << "wipe_package_size is zero";
+ return nullptr;
+ }
+
+ std::string wipe_package;
+ if (std::string err_str; !read_wipe_package(&wipe_package, wipe_package_size, &err_str)) {
+ PLOG(ERROR) << "Failed to read wipe package" << err_str;
+ return nullptr;
+ }
+
+ return Package::CreateMemoryPackage(
+ std::vector<uint8_t>(wipe_package.begin(), wipe_package.end()), nullptr);
+}
+
+// Checks if the wipe package matches expectation. If the check passes, reads the list of
+// partitions to wipe from the package. Checks include
+// 1. verify the package.
+// 2. check metadata (ota-type, pre-device and serial number if having one).
+static bool CheckWipePackage(Package* wipe_package, RecoveryUI* ui) {
+ if (!verify_package(wipe_package, ui)) {
+ LOG(ERROR) << "Failed to verify package";
+ return false;
+ }
+
+ ZipArchiveHandle zip = wipe_package->GetZipArchiveHandle();
+ if (!zip) {
+ LOG(ERROR) << "Failed to get ZipArchiveHandle";
+ return false;
+ }
+
+ std::map<std::string, std::string> metadata;
+ if (!ReadMetadataFromPackage(zip, &metadata)) {
+ LOG(ERROR) << "Failed to parse metadata in the zip file";
+ return false;
+ }
+
+ return CheckPackageMetadata(metadata, OtaType::BRICK) == 0;
+}
+
+bool WipeAbDevice(Device* device, size_t wipe_package_size) {
+ auto ui = device->GetUI();
+ ui->SetBackground(RecoveryUI::ERASING);
+ ui->SetProgressType(RecoveryUI::INDETERMINATE);
+
+ auto wipe_package = ReadWipePackage(wipe_package_size);
+ if (!wipe_package) {
+ LOG(ERROR) << "Failed to open wipe package";
+ return false;
+ }
+
+ if (!CheckWipePackage(wipe_package.get(), ui)) {
+ LOG(ERROR) << "Failed to verify wipe package";
+ return false;
+ }
+
+ auto partition_list = GetWipePartitionList(wipe_package.get());
+ if (partition_list.empty()) {
+ LOG(ERROR) << "Empty wipe ab partition list";
+ return false;
+ }
+
+ for (const auto& partition : partition_list) {
+ // Proceed anyway even if it fails to wipe some partition.
+ SecureWipePartition(partition);
+ }
+ return true;
+}
diff --git a/minui/resources.cpp b/minui/resources.cpp
index 069a49529..00d36d5fb 100644
--- a/minui/resources.cpp
+++ b/minui/resources.cpp
@@ -347,6 +347,10 @@ bool matches_locale(const std::string& prefix, const std::string& locale) {
// match the locale string without the {script} section.
// For instance, prefix == "en" matches locale == "en-US", prefix == "sr-Latn" matches locale
// == "sr-Latn-BA", and prefix == "zh-CN" matches locale == "zh-Hans-CN".
+ if (prefix.empty()) {
+ return false;
+ }
+
if (android::base::StartsWith(locale, prefix)) {
return true;
}
@@ -414,12 +418,18 @@ int res_create_localized_alpha_surface(const char* name,
__unused int len = row[4];
char* loc = reinterpret_cast<char*>(&row[5]);
- if (y + 1 + h >= height || matches_locale(loc, locale)) {
+ // We need to include one additional line for the metadata of the localized image.
+ if (y + 1 + h > height) {
+ printf("Read exceeds the image boundary, y %u, h %d, height %u\n", y, h, height);
+ return -8;
+ }
+
+ if (matches_locale(loc, locale)) {
printf(" %20s: %s (%d x %d @ %d)\n", name, loc, w, h, y);
auto surface = GRSurface::Create(w, h, w, 1);
if (!surface) {
- return -8;
+ return -9;
}
for (int i = 0; i < h; ++i, ++y) {
@@ -428,7 +438,7 @@ int res_create_localized_alpha_surface(const char* name,
}
*pSurface = surface.release();
- break;
+ return 0;
}
for (int i = 0; i < h; ++i, ++y) {
@@ -436,7 +446,7 @@ int res_create_localized_alpha_surface(const char* name,
}
}
- return 0;
+ return -10;
}
void res_free_surface(GRSurface* surface) {
diff --git a/otautil/Android.bp b/otautil/Android.bp
index 0a21731e8..73398c3aa 100644
--- a/otautil/Android.bp
+++ b/otautil/Android.bp
@@ -62,6 +62,10 @@ cc_library_static {
"libfs_mgr",
"libselinux",
],
+
+ export_static_lib_headers: [
+ "libfstab",
+ ],
},
},
}
diff --git a/otautil/include/otautil/sysutil.h b/otautil/include/otautil/sysutil.h
index 692a99e9d..48e9011e5 100644
--- a/otautil/include/otautil/sysutil.h
+++ b/otautil/include/otautil/sysutil.h
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-#ifndef _OTAUTIL_SYSUTIL
-#define _OTAUTIL_SYSUTIL
+#pragma once
#include <sys/types.h>
#include <string>
+#include <string_view>
#include <vector>
#include "rangeset.h"
@@ -101,13 +101,14 @@ class MemMapping {
std::vector<MappedRange> ranges_;
};
-// Wrapper function to trigger a reboot, by additionally handling quiescent reboot mode. The
-// command should start with "reboot," (e.g. "reboot,bootloader" or "reboot,").
-bool reboot(const std::string& command);
+// Reboots the device into the specified target, by additionally handling quiescent reboot mode.
+// 'target' can be an empty string, which indicates booting into Android.
+bool Reboot(std::string_view target);
+
+// Triggers a shutdown.
+bool Shutdown();
// Returns a null-terminated char* array, where the elements point to the C-strings in the given
// vector, plus an additional nullptr at the end. This is a helper function that facilitates
// calling C functions (such as getopt(3)) that expect an array of C-strings.
std::vector<char*> StringVectorToNullTerminatedArray(const std::vector<std::string>& args);
-
-#endif // _OTAUTIL_SYSUTIL
diff --git a/otautil/sysutil.cpp b/otautil/sysutil.cpp
index 8366fa0ac..2b4861809 100644
--- a/otautil/sysutil.cpp
+++ b/otautil/sysutil.cpp
@@ -214,14 +214,21 @@ MemMapping::~MemMapping() {
ranges_.clear();
}
-bool reboot(const std::string& command) {
- std::string cmd = command;
- if (android::base::GetBoolProperty("ro.boot.quiescent", false)) {
+bool Reboot(std::string_view target) {
+ std::string cmd = "reboot," + std::string(target);
+ // Honor the quiescent mode if applicable.
+ if (target != "bootloader" && target != "fastboot" &&
+ android::base::GetBoolProperty("ro.boot.quiescent", false)) {
cmd += ",quiescent";
}
return android::base::SetProperty(ANDROID_RB_PROPERTY, cmd);
}
+bool Shutdown() {
+ // "shutdown" doesn't need a "reason" arg nor a comma.
+ return android::base::SetProperty(ANDROID_RB_PROPERTY, "shutdown");
+}
+
std::vector<char*> StringVectorToNullTerminatedArray(const std::vector<std::string>& args) {
std::vector<char*> result(args.size());
std::transform(args.cbegin(), args.cend(), result.begin(),
diff --git a/recovery.cpp b/recovery.cpp
index 5fc673ec2..36813904a 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -18,11 +18,9 @@
#include <ctype.h>
#include <errno.h>
-#include <fcntl.h>
#include <getopt.h>
#include <inttypes.h>
#include <limits.h>
-#include <linux/fs.h>
#include <linux/input.h>
#include <stdio.h>
#include <stdlib.h>
@@ -30,8 +28,8 @@
#include <sys/types.h>
#include <unistd.h>
-#include <algorithm>
#include <functional>
+#include <iterator>
#include <memory>
#include <string>
#include <vector>
@@ -42,12 +40,11 @@
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
-#include <android-base/unique_fd.h>
-#include <bootloader_message/bootloader_message.h>
#include <cutils/properties.h> /* for property_list */
#include <healthhalutils/HealthHalUtils.h>
#include <ziparchive/zip_archive.h>
+#include "bootloader_message/bootloader_message.h"
#include "common.h"
#include "fsck_unshare_blocks.h"
#include "install/adb_install.h"
@@ -55,6 +52,7 @@
#include "install/install.h"
#include "install/package.h"
#include "install/wipe_data.h"
+#include "install/wipe_device.h"
#include "otautil/error_code.h"
#include "otautil/logging.h"
#include "otautil/paths.h"
@@ -221,165 +219,6 @@ static InstallResult prompt_and_wipe_data(Device* device) {
}
}
-// Secure-wipe a given partition. It uses BLKSECDISCARD, if supported. Otherwise, it goes with
-// BLKDISCARD (if device supports BLKDISCARDZEROES) or BLKZEROOUT.
-static bool secure_wipe_partition(const std::string& partition) {
- android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(partition.c_str(), O_WRONLY)));
- if (fd == -1) {
- PLOG(ERROR) << "Failed to open \"" << partition << "\"";
- return false;
- }
-
- uint64_t range[2] = { 0, 0 };
- if (ioctl(fd, BLKGETSIZE64, &range[1]) == -1 || range[1] == 0) {
- PLOG(ERROR) << "Failed to get partition size";
- return false;
- }
- LOG(INFO) << "Secure-wiping \"" << partition << "\" from " << range[0] << " to " << range[1];
-
- LOG(INFO) << " Trying BLKSECDISCARD...";
- if (ioctl(fd, BLKSECDISCARD, &range) == -1) {
- PLOG(WARNING) << " Failed";
-
- // Use BLKDISCARD if it zeroes out blocks, otherwise use BLKZEROOUT.
- unsigned int zeroes;
- if (ioctl(fd, BLKDISCARDZEROES, &zeroes) == 0 && zeroes != 0) {
- LOG(INFO) << " Trying BLKDISCARD...";
- if (ioctl(fd, BLKDISCARD, &range) == -1) {
- PLOG(ERROR) << " Failed";
- return false;
- }
- } else {
- LOG(INFO) << " Trying BLKZEROOUT...";
- if (ioctl(fd, BLKZEROOUT, &range) == -1) {
- PLOG(ERROR) << " Failed";
- return false;
- }
- }
- }
-
- LOG(INFO) << " Done";
- return true;
-}
-
-static std::unique_ptr<Package> ReadWipePackage(size_t wipe_package_size) {
- if (wipe_package_size == 0) {
- LOG(ERROR) << "wipe_package_size is zero";
- return nullptr;
- }
-
- std::string wipe_package;
- std::string err_str;
- if (!read_wipe_package(&wipe_package, wipe_package_size, &err_str)) {
- PLOG(ERROR) << "Failed to read wipe package" << err_str;
- return nullptr;
- }
-
- return Package::CreateMemoryPackage(
- std::vector<uint8_t>(wipe_package.begin(), wipe_package.end()), nullptr);
-}
-
-// Checks if the wipe package matches expectation. If the check passes, reads the list of
-// partitions to wipe from the package. Checks include
-// 1. verify the package.
-// 2. check metadata (ota-type, pre-device and serial number if having one).
-static bool CheckWipePackage(Package* wipe_package) {
- if (!verify_package(wipe_package, ui)) {
- LOG(ERROR) << "Failed to verify package";
- return false;
- }
-
- ZipArchiveHandle zip = wipe_package->GetZipArchiveHandle();
- if (!zip) {
- LOG(ERROR) << "Failed to get ZipArchiveHandle";
- return false;
- }
-
- std::map<std::string, std::string> metadata;
- if (!ReadMetadataFromPackage(zip, &metadata)) {
- LOG(ERROR) << "Failed to parse metadata in the zip file";
- return false;
- }
-
- return CheckPackageMetadata(metadata, OtaType::BRICK) == 0;
-}
-
-std::vector<std::string> GetWipePartitionList(Package* wipe_package) {
- ZipArchiveHandle zip = wipe_package->GetZipArchiveHandle();
- if (!zip) {
- LOG(ERROR) << "Failed to get ZipArchiveHandle";
- return {};
- }
-
- static constexpr const char* RECOVERY_WIPE_ENTRY_NAME = "recovery.wipe";
-
- std::string partition_list_content;
- ZipString path(RECOVERY_WIPE_ENTRY_NAME);
- ZipEntry entry;
- if (FindEntry(zip, path, &entry) == 0) {
- uint32_t length = entry.uncompressed_length;
- partition_list_content = std::string(length, '\0');
- if (auto err = ExtractToMemory(
- zip, &entry, reinterpret_cast<uint8_t*>(partition_list_content.data()), length);
- err != 0) {
- LOG(ERROR) << "Failed to extract " << RECOVERY_WIPE_ENTRY_NAME << ": "
- << ErrorCodeString(err);
- return {};
- }
- } else {
- LOG(INFO) << "Failed to find " << RECOVERY_WIPE_ENTRY_NAME
- << ", falling back to use the partition list on device.";
-
- static constexpr const char* RECOVERY_WIPE_ON_DEVICE = "/etc/recovery.wipe";
- if (!android::base::ReadFileToString(RECOVERY_WIPE_ON_DEVICE, &partition_list_content)) {
- PLOG(ERROR) << "failed to read \"" << RECOVERY_WIPE_ON_DEVICE << "\"";
- return {};
- }
- }
-
- std::vector<std::string> result;
- std::vector<std::string> lines = android::base::Split(partition_list_content, "\n");
- for (const std::string& line : lines) {
- std::string partition = android::base::Trim(line);
- // Ignore '#' comment or empty lines.
- if (android::base::StartsWith(partition, "#") || partition.empty()) {
- continue;
- }
- result.push_back(line);
- }
-
- return result;
-}
-
-// Wipes the current A/B device, with a secure wipe of all the partitions in RECOVERY_WIPE.
-static bool wipe_ab_device(size_t wipe_package_size) {
- ui->SetBackground(RecoveryUI::ERASING);
- ui->SetProgressType(RecoveryUI::INDETERMINATE);
-
- auto wipe_package = ReadWipePackage(wipe_package_size);
- if (!wipe_package) {
- LOG(ERROR) << "Failed to open wipe package";
- return false;
- }
-
- if (!CheckWipePackage(wipe_package.get())) {
- LOG(ERROR) << "Failed to verify wipe package";
- return false;
- }
-
- auto partition_list = GetWipePartitionList(wipe_package.get());
- if (partition_list.empty()) {
- LOG(ERROR) << "Empty wipe ab partition list";
- return false;
- }
-
- for (const auto& partition : partition_list) {
- // Proceed anyway even if it fails to wipe some partition.
- secure_wipe_partition(partition);
- }
- return true;
-}
-
static void choose_recovery_file(Device* device) {
std::vector<std::string> entries;
if (has_cache) {
@@ -895,8 +734,8 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector<std::stri
// Print retry count on screen.
ui->Print("Retry attempt %d\n", retry_count);
- // Reboot and retry the update
- if (!reboot("reboot,recovery")) {
+ // Reboot back into recovery to retry the update.
+ if (!Reboot("recovery")) {
ui->Print("Reboot failed\n");
} else {
while (true) {
@@ -934,7 +773,7 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector<std::stri
status = INSTALL_ERROR;
}
} else if (should_wipe_ab) {
- if (!wipe_ab_device(wipe_package_size)) {
+ if (!WipeAbDevice(device, wipe_package_size)) {
status = INSTALL_ERROR;
}
} else if (sideload) {
diff --git a/recovery_main.cpp b/recovery_main.cpp
index de8ac1f42..b999505fb 100644
--- a/recovery_main.cpp
+++ b/recovery_main.cpp
@@ -41,7 +41,6 @@
#include <android-base/strings.h>
#include <android-base/unique_fd.h>
#include <bootloader_message/bootloader_message.h>
-#include <cutils/android_reboot.h>
#include <cutils/sockets.h>
#include <private/android_logger.h> /* private pmsg functions */
#include <selinux/android.h>
@@ -375,7 +374,6 @@ int main(int argc, char** argv) {
}
if (locale.empty()) {
- static constexpr const char* DEFAULT_LOCALE = "en-US";
locale = DEFAULT_LOCALE;
}
}
@@ -472,27 +470,26 @@ int main(int argc, char** argv) {
switch (ret) {
case Device::SHUTDOWN:
ui->Print("Shutting down...\n");
- // TODO: Move all the reboots to reboot(), which should conditionally set quiescent flag.
- android::base::SetProperty(ANDROID_RB_PROPERTY, "shutdown,");
+ Shutdown();
break;
case Device::REBOOT_BOOTLOADER:
ui->Print("Rebooting to bootloader...\n");
- android::base::SetProperty(ANDROID_RB_PROPERTY, "reboot,bootloader");
+ Reboot("bootloader");
break;
case Device::REBOOT_FASTBOOT:
ui->Print("Rebooting to recovery/fastboot...\n");
- android::base::SetProperty(ANDROID_RB_PROPERTY, "reboot,fastboot");
+ Reboot("fastboot");
break;
case Device::REBOOT_RECOVERY:
ui->Print("Rebooting to recovery...\n");
- reboot("reboot,recovery");
+ Reboot("recovery");
break;
case Device::REBOOT_RESCUE: {
- // Not using `reboot("reboot,rescue")`, as it requires matching support in kernel and/or
+ // Not using `Reboot("rescue")`, as it requires matching support in kernel and/or
// bootloader.
bootloader_message boot = {};
strlcpy(boot.command, "boot-rescue", sizeof(boot.command));
@@ -503,14 +500,14 @@ int main(int argc, char** argv) {
continue;
}
ui->Print("Rebooting to recovery/rescue...\n");
- reboot("reboot,recovery");
+ Reboot("recovery");
break;
}
case Device::ENTER_FASTBOOT:
if (logical_partitions_mapped()) {
ui->Print("Partitions may be mounted - rebooting to enter fastboot.");
- android::base::SetProperty(ANDROID_RB_PROPERTY, "reboot,fastboot");
+ Reboot("fastboot");
} else {
LOG(INFO) << "Entering fastboot";
fastboot = true;
@@ -524,7 +521,7 @@ int main(int argc, char** argv) {
default:
ui->Print("Rebooting...\n");
- reboot("reboot,");
+ Reboot("");
break;
}
}
diff --git a/recovery_ui/include/recovery_ui/ui.h b/recovery_ui/include/recovery_ui/ui.h
index d55322cf0..797e2f0d5 100644
--- a/recovery_ui/include/recovery_ui/ui.h
+++ b/recovery_ui/include/recovery_ui/ui.h
@@ -27,6 +27,8 @@
#include <thread>
#include <vector>
+static constexpr const char* DEFAULT_LOCALE = "en-US";
+
// Abstract class for controlling the user interface during recovery.
class RecoveryUI {
public:
diff --git a/recovery_ui/screen_ui.cpp b/recovery_ui/screen_ui.cpp
index 870db621c..823004521 100644
--- a/recovery_ui/screen_ui.cpp
+++ b/recovery_ui/screen_ui.cpp
@@ -817,12 +817,22 @@ std::unique_ptr<GRSurface> ScreenRecoveryUI::LoadBitmap(const std::string& filen
std::unique_ptr<GRSurface> ScreenRecoveryUI::LoadLocalizedBitmap(const std::string& filename) {
GRSurface* surface;
- if (auto result = res_create_localized_alpha_surface(filename.c_str(), locale_.c_str(), &surface);
- result < 0) {
- LOG(ERROR) << "Failed to load bitmap " << filename << " (error " << result << ")";
- return nullptr;
+ auto result = res_create_localized_alpha_surface(filename.c_str(), locale_.c_str(), &surface);
+ if (result == 0) {
+ return std::unique_ptr<GRSurface>(surface);
}
- return std::unique_ptr<GRSurface>(surface);
+ // TODO(xunchang) create a error code enum to refine the retry condition.
+ LOG(WARNING) << "Failed to load bitmap " << filename << " for locale " << locale_ << " (error "
+ << result << "). Falling back to use default locale.";
+
+ result = res_create_localized_alpha_surface(filename.c_str(), DEFAULT_LOCALE, &surface);
+ if (result == 0) {
+ return std::unique_ptr<GRSurface>(surface);
+ }
+
+ LOG(ERROR) << "Failed to load bitmap " << filename << " for locale " << DEFAULT_LOCALE
+ << " (error " << result << ")";
+ return nullptr;
}
static char** Alloc2d(size_t rows, size_t cols) {
diff --git a/recovery_ui/ui.cpp b/recovery_ui/ui.cpp
index b7107ff21..7ea9307c9 100644
--- a/recovery_ui/ui.cpp
+++ b/recovery_ui/ui.cpp
@@ -375,7 +375,7 @@ void RecoveryUI::ProcessKey(int key_code, int updown) {
case RecoveryUI::REBOOT:
if (reboot_enabled) {
- reboot("reboot,");
+ Reboot("");
while (true) {
pause();
}
diff --git a/tests/Android.bp b/tests/Android.bp
index 09ef716d6..ec2124a54 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -79,6 +79,8 @@ librecovery_static_libs = [
"libinstall",
"librecovery_ui",
"libminui",
+ "libfusesideload",
+ "libbootloader_message",
"libotautil",
"libhealthhalutils",
@@ -87,10 +89,8 @@ librecovery_static_libs = [
"android.hardware.health@2.0",
"android.hardware.health@1.0",
- "libbootloader_message",
"libext4_utils",
"libfs_mgr",
- "libfusesideload",
"libhidl-gen-utils",
"libhidlbase",
"libhidltransport",
@@ -107,6 +107,7 @@ cc_test {
defaults: [
"recovery_test_defaults",
+ "libupdater_defaults",
],
test_suites: ["device-tests"],
@@ -115,16 +116,21 @@ cc_test {
"unit/*.cpp",
],
- static_libs: libapplypatch_static_libs + [
- "libinstall",
+ static_libs: libapplypatch_static_libs + librecovery_static_libs + [
"librecovery_ui",
"libminui",
"libotautil",
"libupdater",
+ "libupdate_verifier",
+
"libgtest_prod",
+ "libprotobuf-cpp-lite",
],
- data: ["testdata/*"],
+ data: [
+ "testdata/*",
+ ":res-testdata",
+ ],
}
cc_test {
@@ -142,33 +148,6 @@ cc_test {
],
}
-cc_test {
- name: "recovery_component_test",
- isolated: true,
-
- defaults: [
- "recovery_test_defaults",
- "libupdater_defaults",
- ],
-
- test_suites: ["device-tests"],
-
- srcs: [
- "component/*.cpp",
- ],
-
- static_libs: libapplypatch_static_libs + librecovery_static_libs + [
- "libupdater",
- "libupdate_verifier",
- "libprotobuf-cpp-lite",
- ],
-
- data: [
- "testdata/*",
- ":res-testdata",
- ],
-}
-
cc_test_host {
name: "recovery_host_test",
isolated: true,
@@ -178,7 +157,7 @@ cc_test_host {
],
srcs: [
- "component/imgdiff_test.cpp",
+ "unit/imgdiff_test.cpp",
],
static_libs: [
@@ -197,6 +176,8 @@ cc_test_host {
"libz",
],
+ test_suites: ["general-tests"],
+
data: ["testdata/*"],
target: {
diff --git a/tests/AndroidTest.xml b/tests/AndroidTest.xml
deleted file mode 100644
index 6b86085aa..000000000
--- a/tests/AndroidTest.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-<configuration description="Config for recovery_component_test and recovery_unit_test">
- <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
- <option name="cleanup" value="true" />
- <option name="push" value="recovery_component_test->/data/local/tmp/recovery_component_test/recovery_component_test" />
- <option name="push" value="testdata->/data/local/tmp/recovery_component_test/testdata" />
- <option name="push" value="recovery_unit_test->/data/local/tmp/recovery_unit_test/recovery_unit_test" />
- <option name="push" value="testdata->/data/local/tmp/recovery_unit_test/testdata" />
- </target_preparer>
- <option name="test-suite-tag" value="apct" />
- <test class="com.android.tradefed.testtype.GTest" >
- <option name="native-test-device-path" value="/data/local/tmp/recovery_component_test" />
- <option name="module-name" value="recovery_component_test" />
- </test>
- <test class="com.android.tradefed.testtype.GTest" >
- <option name="native-test-device-path" value="/data/local/tmp/recovery_unit_test" />
- <option name="module-name" value="recovery_unit_test" />
- </test>
-</configuration>
diff --git a/tests/component/resources_test.cpp b/tests/component/resources_test.cpp
deleted file mode 100644
index d7fdb8fa0..000000000
--- a/tests/component/resources_test.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2018 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.
- */
-
-#include <dirent.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include <android-base/file.h>
-#include <android-base/strings.h>
-#include <gtest/gtest.h>
-#include <png.h>
-
-#include "minui/minui.h"
-#include "private/resources.h"
-
-static const std::string kLocale = "zu";
-
-static const std::vector<std::string> kResourceImagesDirs{
- "res-mdpi/images/", "res-hdpi/images/", "res-xhdpi/images/",
- "res-xxhdpi/images/", "res-xxxhdpi/images/",
-};
-
-static int png_filter(const dirent* de) {
- if (de->d_type != DT_REG || !android::base::EndsWith(de->d_name, "_text.png")) {
- return 0;
- }
- return 1;
-}
-
-// Finds out all the PNG files to test, which stay under the same dir with the executabl..
-static std::vector<std::string> add_files() {
- std::vector<std::string> files;
- for (const std::string& images_dir : kResourceImagesDirs) {
- static std::string exec_dir = android::base::GetExecutableDirectory();
- std::string dir_path = exec_dir + "/" + images_dir;
- dirent** namelist;
- int n = scandir(dir_path.c_str(), &namelist, png_filter, alphasort);
- if (n == -1) {
- printf("Failed to scandir %s: %s\n", dir_path.c_str(), strerror(errno));
- continue;
- }
- if (n == 0) {
- printf("No file is added for test in %s\n", dir_path.c_str());
- }
-
- while (n--) {
- std::string file_path = dir_path + namelist[n]->d_name;
- files.push_back(file_path);
- free(namelist[n]);
- }
- free(namelist);
- }
- return files;
-}
-
-class ResourcesTest : public testing::TestWithParam<std::string> {
- public:
- static std::vector<std::string> png_list;
-
- protected:
- void SetUp() override {
- png_ = std::make_unique<PngHandler>(GetParam());
- ASSERT_TRUE(png_);
-
- ASSERT_EQ(PNG_COLOR_TYPE_GRAY, png_->color_type()) << "Recovery expects grayscale PNG file.";
- ASSERT_LT(static_cast<png_uint_32>(5), png_->width());
- ASSERT_LT(static_cast<png_uint_32>(0), png_->height());
- ASSERT_EQ(1, png_->channels()) << "Recovery background text images expects 1-channel PNG file.";
- }
-
- std::unique_ptr<PngHandler> png_{ nullptr };
-};
-
-// Parses a png file and tests if it's qualified for the background text image under recovery.
-TEST_P(ResourcesTest, ValidateLocale) {
- std::vector<unsigned char> row(png_->width());
- for (png_uint_32 y = 0; y < png_->height(); ++y) {
- png_read_row(png_->png_ptr(), row.data(), nullptr);
- int w = (row[1] << 8) | row[0];
- int h = (row[3] << 8) | row[2];
- int len = row[4];
- EXPECT_LT(0, w);
- EXPECT_LT(0, h);
- EXPECT_LT(0, len) << "Locale string should be non-empty.";
- EXPECT_NE(0, row[5]) << "Locale string is missing.";
-
- ASSERT_GE(png_->height(), y + 1 + h) << "Locale: " << kLocale << " is not found in the file.";
- char* loc = reinterpret_cast<char*>(&row[5]);
- if (matches_locale(loc, kLocale.c_str())) {
- EXPECT_TRUE(android::base::StartsWith(loc, kLocale));
- break;
- }
- for (int i = 0; i < h; ++i, ++y) {
- png_read_row(png_->png_ptr(), row.data(), nullptr);
- }
- }
-}
-
-std::vector<std::string> ResourcesTest::png_list = add_files();
-
-INSTANTIATE_TEST_CASE_P(BackgroundTextValidation, ResourcesTest,
- ::testing::ValuesIn(ResourcesTest::png_list.cbegin(),
- ResourcesTest::png_list.cend()));
diff --git a/tests/component/applypatch_modes_test.cpp b/tests/unit/applypatch_modes_test.cpp
index 08414b796..08414b796 100644
--- a/tests/component/applypatch_modes_test.cpp
+++ b/tests/unit/applypatch_modes_test.cpp
diff --git a/tests/component/bootloader_message_test.cpp b/tests/unit/bootloader_message_test.cpp
index b005d199c..b005d199c 100644
--- a/tests/component/bootloader_message_test.cpp
+++ b/tests/unit/bootloader_message_test.cpp
diff --git a/tests/component/edify_test.cpp b/tests/unit/edify_test.cpp
index 8397bd38e..8397bd38e 100644
--- a/tests/component/edify_test.cpp
+++ b/tests/unit/edify_test.cpp
diff --git a/tests/component/sideload_test.cpp b/tests/unit/fuse_sideload_test.cpp
index 6add99f41..6add99f41 100644
--- a/tests/component/sideload_test.cpp
+++ b/tests/unit/fuse_sideload_test.cpp
diff --git a/tests/component/imgdiff_test.cpp b/tests/unit/imgdiff_test.cpp
index e76ccbdfb..e76ccbdfb 100644
--- a/tests/component/imgdiff_test.cpp
+++ b/tests/unit/imgdiff_test.cpp
diff --git a/tests/component/install_test.cpp b/tests/unit/install_test.cpp
index 385132939..36820f837 100644
--- a/tests/component/install_test.cpp
+++ b/tests/unit/install_test.cpp
@@ -33,6 +33,7 @@
#include <ziparchive/zip_writer.h>
#include "install/install.h"
+#include "install/wipe_device.h"
#include "otautil/paths.h"
#include "private/setup_commands.h"
diff --git a/tests/unit/locale_test.cpp b/tests/unit/locale_test.cpp
index cdaba0e8b..c69434c12 100644
--- a/tests/unit/locale_test.cpp
+++ b/tests/unit/locale_test.cpp
@@ -27,7 +27,7 @@ TEST(LocaleTest, Misc) {
EXPECT_FALSE(matches_locale("en-GB", "en"));
EXPECT_FALSE(matches_locale("en-GB", "en-US"));
EXPECT_FALSE(matches_locale("en-US", ""));
- // Empty locale prefix in the PNG file will match the input locale.
- EXPECT_TRUE(matches_locale("", "en-US"));
+ // Empty locale prefix in the PNG file should not match the input locale.
+ EXPECT_FALSE(matches_locale("", "en-US"));
EXPECT_TRUE(matches_locale("sr-Latn", "sr-Latn-BA"));
}
diff --git a/tests/unit/resources_test.cpp b/tests/unit/resources_test.cpp
index c3f72718f..302744308 100644
--- a/tests/unit/resources_test.cpp
+++ b/tests/unit/resources_test.cpp
@@ -14,12 +14,62 @@
* limitations under the License.
*/
+#include <dirent.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <memory>
#include <string>
+#include <vector>
+#include <android-base/file.h>
+#include <android-base/strings.h>
#include <gtest/gtest.h>
+#include <png.h>
#include "common/test_constants.h"
#include "minui/minui.h"
+#include "private/resources.h"
+
+static const std::string kLocale = "zu";
+
+static const std::vector<std::string> kResourceImagesDirs{
+ "res-mdpi/images/", "res-hdpi/images/", "res-xhdpi/images/",
+ "res-xxhdpi/images/", "res-xxxhdpi/images/",
+};
+
+static int png_filter(const dirent* de) {
+ if (de->d_type != DT_REG || !android::base::EndsWith(de->d_name, "_text.png")) {
+ return 0;
+ }
+ return 1;
+}
+
+// Finds out all the PNG files to test, which stay under the same dir with the executabl..
+static std::vector<std::string> add_files() {
+ std::vector<std::string> files;
+ for (const std::string& images_dir : kResourceImagesDirs) {
+ static std::string exec_dir = android::base::GetExecutableDirectory();
+ std::string dir_path = exec_dir + "/" + images_dir;
+ dirent** namelist;
+ int n = scandir(dir_path.c_str(), &namelist, png_filter, alphasort);
+ if (n == -1) {
+ printf("Failed to scandir %s: %s\n", dir_path.c_str(), strerror(errno));
+ continue;
+ }
+ if (n == 0) {
+ printf("No file is added for test in %s\n", dir_path.c_str());
+ }
+
+ while (n--) {
+ std::string file_path = dir_path + namelist[n]->d_name;
+ files.push_back(file_path);
+ free(namelist[n]);
+ }
+ free(namelist);
+ }
+ return files;
+}
TEST(ResourcesTest, res_create_multi_display_surface) {
GRSurface** frames;
@@ -35,3 +85,52 @@ TEST(ResourcesTest, res_create_multi_display_surface) {
}
free(frames);
}
+
+class ResourcesTest : public testing::TestWithParam<std::string> {
+ public:
+ static std::vector<std::string> png_list;
+
+ protected:
+ void SetUp() override {
+ png_ = std::make_unique<PngHandler>(GetParam());
+ ASSERT_TRUE(png_);
+
+ ASSERT_EQ(PNG_COLOR_TYPE_GRAY, png_->color_type()) << "Recovery expects grayscale PNG file.";
+ ASSERT_LT(static_cast<png_uint_32>(5), png_->width());
+ ASSERT_LT(static_cast<png_uint_32>(0), png_->height());
+ ASSERT_EQ(1, png_->channels()) << "Recovery background text images expects 1-channel PNG file.";
+ }
+
+ std::unique_ptr<PngHandler> png_{ nullptr };
+};
+
+// Parses a png file and tests if it's qualified for the background text image under recovery.
+TEST_P(ResourcesTest, ValidateLocale) {
+ std::vector<unsigned char> row(png_->width());
+ for (png_uint_32 y = 0; y < png_->height(); ++y) {
+ png_read_row(png_->png_ptr(), row.data(), nullptr);
+ int w = (row[1] << 8) | row[0];
+ int h = (row[3] << 8) | row[2];
+ int len = row[4];
+ EXPECT_LT(0, w);
+ EXPECT_LT(0, h);
+ EXPECT_LT(0, len) << "Locale string should be non-empty.";
+ EXPECT_NE(0, row[5]) << "Locale string is missing.";
+
+ ASSERT_GE(png_->height(), y + 1 + h) << "Locale: " << kLocale << " is not found in the file.";
+ char* loc = reinterpret_cast<char*>(&row[5]);
+ if (matches_locale(loc, kLocale.c_str())) {
+ EXPECT_TRUE(android::base::StartsWith(loc, kLocale));
+ break;
+ }
+ for (int i = 0; i < h; ++i, ++y) {
+ png_read_row(png_->png_ptr(), row.data(), nullptr);
+ }
+ }
+}
+
+std::vector<std::string> ResourcesTest::png_list = add_files();
+
+INSTANTIATE_TEST_CASE_P(BackgroundTextValidation, ResourcesTest,
+ ::testing::ValuesIn(ResourcesTest::png_list.cbegin(),
+ ResourcesTest::png_list.cend()));
diff --git a/tests/component/uncrypt_test.cpp b/tests/unit/uncrypt_test.cpp
index e97d589a6..e97d589a6 100644
--- a/tests/component/uncrypt_test.cpp
+++ b/tests/unit/uncrypt_test.cpp
diff --git a/tests/component/update_verifier_test.cpp b/tests/unit/update_verifier_test.cpp
index e27e58c22..e27e58c22 100644
--- a/tests/component/update_verifier_test.cpp
+++ b/tests/unit/update_verifier_test.cpp
diff --git a/tests/component/updater_test.cpp b/tests/unit/updater_test.cpp
index a0a7b66ab..a0a7b66ab 100644
--- a/tests/component/updater_test.cpp
+++ b/tests/unit/updater_test.cpp
diff --git a/tests/component/verifier_test.cpp b/tests/unit/verifier_test.cpp
index ded23c52f..ded23c52f 100644
--- a/tests/component/verifier_test.cpp
+++ b/tests/unit/verifier_test.cpp
diff --git a/tools/recovery_l10n/res/values-gl/strings.xml b/tools/recovery_l10n/res/values-gl/strings.xml
index e6f2ffd84..e51b36dfb 100644
--- a/tools/recovery_l10n/res/values-gl/strings.xml
+++ b/tools/recovery_l10n/res/values-gl/strings.xml
@@ -6,9 +6,9 @@
<string name="recovery_no_command" msgid="4465476568623024327">"Non hai ningún comando"</string>
<string name="recovery_error" msgid="5748178989622716736">"Erro"</string>
<string name="recovery_installing_security" msgid="9184031299717114342">"Instalando actualización de seguranza"</string>
- <string name="recovery_wipe_data_menu_header" msgid="550255032058254478">"Non se puido cargar o sistema Android. Os teus datos poden estar danados. Se segue aparecendo esta mensaxe, pode ser necesario restablecer os datos de fábrica e borrar todos os datos do usuario almacenados neste dispositivo."</string>
+ <string name="recovery_wipe_data_menu_header" msgid="550255032058254478">"Non se puido cargar o sistema Android. Os teus datos poden estar danados. Se segue aparecendo esta mensaxe, pode ser necesario restablecer os datos de fábrica e borrar todos os datos de usuario almacenados neste dispositivo."</string>
<string name="recovery_try_again" msgid="7168248750158873496">"Tentar de novo"</string>
<string name="recovery_factory_data_reset" msgid="7321351565602894783">"Restablecemento dos datos de fábrica"</string>
- <string name="recovery_wipe_data_confirmation" msgid="5439823343348043954">"Queres borrar todos os datos do usuario?\n\n ESTA ACCIÓN NON SE PODE DESFACER."</string>
+ <string name="recovery_wipe_data_confirmation" msgid="5439823343348043954">"Queres borrar todos os datos de usuario?\n\n ESTA ACCIÓN NON SE PODE DESFACER."</string>
<string name="recovery_cancel_wipe_data" msgid="66987687653647384">"Cancelar"</string>
</resources>
diff --git a/tools/recovery_l10n/res/values-ja/strings.xml b/tools/recovery_l10n/res/values-ja/strings.xml
index 2d6c0abc4..3d6637278 100644
--- a/tools/recovery_l10n/res/values-ja/strings.xml
+++ b/tools/recovery_l10n/res/values-ja/strings.xml
@@ -6,7 +6,7 @@
<string name="recovery_no_command" msgid="4465476568623024327">"コマンドが指定されていません"</string>
<string name="recovery_error" msgid="5748178989622716736">"エラーが発生しました。"</string>
<string name="recovery_installing_security" msgid="9184031299717114342">"セキュリティ アップデートをインストールしています"</string>
- <string name="recovery_wipe_data_menu_header" msgid="550255032058254478">"Android システムを読み込めません。データが破損している可能性があります。このメッセージが引き続き表示される場合は、データの初期化を行い、このデバイスに保存されているすべてのユーザー データを消去することが必要な場合があります。"</string>
+ <string name="recovery_wipe_data_menu_header" msgid="550255032058254478">"Android システムを読み込めません。データが破損している可能性があります。このメッセージが引き続き表示される場合は、データの初期化を行い、この端末に保存されているすべてのユーザー データを消去することが必要な場合があります。"</string>
<string name="recovery_try_again" msgid="7168248750158873496">"再試行"</string>
<string name="recovery_factory_data_reset" msgid="7321351565602894783">"データの初期化"</string>
<string name="recovery_wipe_data_confirmation" msgid="5439823343348043954">"すべてのユーザー データをワイプしますか?\n\nこの操作は元に戻せません。"</string>
diff --git a/updater/install.cpp b/updater/install.cpp
index 20a204a83..8eba64f5d 100644
--- a/updater/install.cpp
+++ b/updater/install.cpp
@@ -778,7 +778,7 @@ Value* RebootNowFn(const char* name, State* state, const std::vector<std::unique
return StringValue("");
}
- reboot("reboot," + property);
+ Reboot(property);
sleep(5);
return ErrorAbort(state, kRebootFailure, "%s() failed to reboot", name);