Merge "update_verifier: Add some missing #include's." am: 05f9a8e100 am: 6105a6fb6e
am: 9d35593f89
Change-Id: I46f64820fe71edf506236f69fe9d90a993bfadb8
diff --git a/tests/component/update_verifier_test.cpp b/tests/component/update_verifier_test.cpp
index 0a59403..e27e58c 100644
--- a/tests/component/update_verifier_test.cpp
+++ b/tests/component/update_verifier_test.cpp
@@ -98,7 +98,7 @@
ASSERT_FALSE(verifier_.ParseCareMap());
}
-TEST_F(UpdateVerifierTest, verify_image_smoke) {
+TEST_F(UpdateVerifierTest, verify_image_text_format) {
// This test relies on dm-verity support.
if (!verity_supported) {
GTEST_LOG_(INFO) << "Test skipped on devices without dm-verity support.";
@@ -107,52 +107,14 @@
std::string content = "system\n2,0,1";
ASSERT_TRUE(android::base::WriteStringToFile(content, care_map_txt_));
- ASSERT_TRUE(verifier_.ParseCareMap());
- ASSERT_TRUE(verifier_.VerifyPartitions());
-
- // Leading and trailing newlines should be accepted.
- ASSERT_TRUE(android::base::WriteStringToFile("\n" + content + "\n\n", care_map_txt_));
- ASSERT_TRUE(verifier_.ParseCareMap());
- ASSERT_TRUE(verifier_.VerifyPartitions());
+ // CareMap in text format is no longer supported.
+ ASSERT_FALSE(verifier_.ParseCareMap());
}
TEST_F(UpdateVerifierTest, verify_image_empty_care_map) {
ASSERT_FALSE(verifier_.ParseCareMap());
}
-TEST_F(UpdateVerifierTest, verify_image_wrong_lines) {
- // The care map file can have only 2 / 4 / 6 lines.
- ASSERT_TRUE(android::base::WriteStringToFile("line1", care_map_txt_));
- ASSERT_FALSE(verifier_.ParseCareMap());
-
- ASSERT_TRUE(android::base::WriteStringToFile("line1\nline2\nline3", care_map_txt_));
- ASSERT_FALSE(verifier_.ParseCareMap());
-}
-
-TEST_F(UpdateVerifierTest, verify_image_malformed_care_map) {
- // This test relies on dm-verity support.
- if (!verity_supported) {
- GTEST_LOG_(INFO) << "Test skipped on devices without dm-verity support.";
- return;
- }
-
- std::string content = "system\n2,1,0";
- ASSERT_TRUE(android::base::WriteStringToFile(content, care_map_txt_));
- ASSERT_FALSE(verifier_.ParseCareMap());
-}
-
-TEST_F(UpdateVerifierTest, verify_image_legacy_care_map) {
- // This test relies on dm-verity support.
- if (!verity_supported) {
- GTEST_LOG_(INFO) << "Test skipped on devices without dm-verity support.";
- return;
- }
-
- std::string content = "/dev/block/bootdevice/by-name/system\n2,1,0";
- ASSERT_TRUE(android::base::WriteStringToFile(content, care_map_txt_));
- ASSERT_FALSE(verifier_.ParseCareMap());
-}
-
TEST_F(UpdateVerifierTest, verify_image_protobuf_care_map_smoke) {
// This test relies on dm-verity support.
if (!verity_supported) {
diff --git a/tools/recovery_l10n/res/values-en-rXC/strings.xml b/tools/recovery_l10n/res/values-en-rXC/strings.xml
index 61390f1..18b077f 100644
--- a/tools/recovery_l10n/res/values-en-rXC/strings.xml
+++ b/tools/recovery_l10n/res/values-en-rXC/strings.xml
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="recovery_installing" msgid="2013591905463558223">"Installing system update"</string>
- <string name="recovery_erasing" msgid="7334826894904037088">"Erasing"</string>
- <string name="recovery_no_command" msgid="4465476568623024327">"No command"</string>
- <string name="recovery_error" msgid="5748178989622716736">"Error!"</string>
- <string name="recovery_installing_security" msgid="9184031299717114342">"Installing security update"</string>
- <string name="recovery_wipe_data_menu_header" msgid="550255032058254478">"Cannot load Android system. Your data may be corrupt. If you continue to get this message, you may need to perform a factory data reset and erase all user data stored on this device."</string>
- <string name="recovery_try_again" msgid="7168248750158873496">"Try again"</string>
- <string name="recovery_factory_data_reset" msgid="7321351565602894783">"Factory data reset"</string>
- <string name="recovery_wipe_data_confirmation" msgid="5439823343348043954">"Wipe all user data?\n\n THIS CAN NOT BE UNDONE!"</string>
- <string name="recovery_cancel_wipe_data" msgid="66987687653647384">"Cancel"</string>
+ <string name="recovery_installing" msgid="2013591905463558223">"Installing system update"</string>
+ <string name="recovery_erasing" msgid="7334826894904037088">"Erasing"</string>
+ <string name="recovery_no_command" msgid="4465476568623024327">"No command"</string>
+ <string name="recovery_error" msgid="5748178989622716736">"Error!"</string>
+ <string name="recovery_installing_security" msgid="9184031299717114342">"Installing security update"</string>
+ <string name="recovery_wipe_data_menu_header" msgid="550255032058254478">"Cannot load Android system. Your data may be corrupt. If you continue to get this message, you may need to perform a factory data reset and erase all user data stored on this device."</string>
+ <string name="recovery_try_again" msgid="7168248750158873496">"Try again"</string>
+ <string name="recovery_factory_data_reset" msgid="7321351565602894783">"Factory data reset"</string>
+ <string name="recovery_wipe_data_confirmation" msgid="5439823343348043954">"Wipe all user data?\n\n THIS CAN NOT BE UNDONE!"</string>
+ <string name="recovery_cancel_wipe_data" msgid="66987687653647384">"Cancel"</string>
</resources>
diff --git a/update_verifier/include/update_verifier/update_verifier.h b/update_verifier/include/update_verifier/update_verifier.h
index b00890e..4c64b1e 100644
--- a/update_verifier/include/update_verifier/update_verifier.h
+++ b/update_verifier/include/update_verifier/update_verifier.h
@@ -50,9 +50,6 @@
private:
friend class UpdateVerifierTest;
- // Parses the legacy care_map.txt in plain text format.
- bool ParseCareMapPlainText(const std::string& content);
-
// Finds all the dm-enabled partitions, and returns a map of <partition_name, block_device>.
std::map<std::string, std::string> FindDmPartitions();
diff --git a/update_verifier/update_verifier.cpp b/update_verifier/update_verifier.cpp
index ce93a46..0cf536c 100644
--- a/update_verifier/update_verifier.cpp
+++ b/update_verifier/update_verifier.cpp
@@ -71,6 +71,7 @@
using android::hardware::boot::V1_0::BoolResult;
using android::hardware::boot::V1_0::CommandResult;
+// TODO(xunchang) remove the prefix and use a default path instead.
constexpr const char* kDefaultCareMapPrefix = "/data/ota_package/care_map";
// Find directories in format of "/sys/block/dm-X".
@@ -199,51 +200,13 @@
return true;
}
-bool UpdateVerifier::ParseCareMapPlainText(const std::string& content) {
- // care_map file has up to six lines, where every two lines make a pair. Within each pair, the
- // first line has the partition name (e.g. "system"), while the second line holds the ranges of
- // all the blocks to verify.
- auto lines = android::base::Split(android::base::Trim(content), "\n");
- if (lines.size() != 2 && lines.size() != 4 && lines.size() != 6) {
- LOG(WARNING) << "Invalid lines in care_map: found " << lines.size()
- << " lines, expecting 2 or 4 or 6 lines.";
- return false;
- }
-
- for (size_t i = 0; i < lines.size(); i += 2) {
- const std::string& partition_name = lines[i];
- const std::string& range_str = lines[i + 1];
- // We're seeing an N care_map.txt. Skip the verification since it's not compatible with O
- // update_verifier (the last few metadata blocks can't be read via device mapper).
- if (android::base::StartsWith(partition_name, "/dev/block/")) {
- LOG(WARNING) << "Found legacy care_map.txt; skipped.";
- return false;
- }
-
- // For block range string, first integer 'count' equals 2 * total number of valid ranges,
- // followed by 'count' number comma separated integers. Every two integers reprensent a
- // block range with the first number included in range but second number not included.
- // For example '4,64536,65343,74149,74150' represents: [64536,65343) and [74149,74150).
- RangeSet ranges = RangeSet::Parse(range_str);
- if (!ranges) {
- LOG(WARNING) << "Error parsing RangeSet string " << range_str;
- return false;
- }
-
- partition_map_.emplace(partition_name, ranges);
- }
-
- return true;
-}
-
bool UpdateVerifier::ParseCareMap() {
partition_map_.clear();
std::string care_map_name = care_map_prefix_ + ".pb";
if (access(care_map_name.c_str(), R_OK) == -1) {
- LOG(WARNING) << care_map_name
- << " doesn't exist, falling back to read the care_map in plain text format.";
- care_map_name = care_map_prefix_ + ".txt";
+ LOG(ERROR) << care_map_name << " doesn't exist";
+ return false;
}
android::base::unique_fd care_map_fd(TEMP_FAILURE_RETRY(open(care_map_name.c_str(), O_RDONLY)));
@@ -266,10 +229,6 @@
return false;
}
- if (android::base::EndsWith(care_map_name, ".txt")) {
- return ParseCareMapPlainText(file_content);
- }
-
recovery_update_verifier::CareMap care_map;
if (!care_map.ParseFromString(file_content)) {
LOG(WARNING) << "Failed to parse " << care_map_name << " in protobuf format.";
diff --git a/updater_sample/tests/Android.bp b/updater_sample/tests/Android.bp
index 7867770..806babd 100644
--- a/updater_sample/tests/Android.bp
+++ b/updater_sample/tests/Android.bp
@@ -23,7 +23,8 @@
],
static_libs: [
- "android-support-test",
+ "androidx.test.runner",
+ "androidx.test.rules",
"mockito-target-minus-junit4",
"guava",
],
diff --git a/updater_sample/tests/AndroidManifest.xml b/updater_sample/tests/AndroidManifest.xml
index 76af5f1..a2da3f7 100644
--- a/updater_sample/tests/AndroidManifest.xml
+++ b/updater_sample/tests/AndroidManifest.xml
@@ -26,7 +26,7 @@
<uses-library android:name="android.test.runner" />
</application>
- <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+ <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
android:targetPackage="com.example.android.systemupdatersample"
android:label="Tests for SystemUpdaterSample."/>
diff --git a/updater_sample/tests/src/com/example/android/systemupdatersample/UpdateConfigTest.java b/updater_sample/tests/src/com/example/android/systemupdatersample/UpdateConfigTest.java
index 48d0e42..ae66683 100644
--- a/updater_sample/tests/src/com/example/android/systemupdatersample/UpdateConfigTest.java
+++ b/updater_sample/tests/src/com/example/android/systemupdatersample/UpdateConfigTest.java
@@ -21,9 +21,10 @@
import static org.junit.Assert.assertTrue;
import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.filters.SmallTest;
-import android.support.test.runner.AndroidJUnit4;
+
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
import com.example.android.systemupdatersample.tests.R;
import com.google.common.io.CharStreams;
diff --git a/updater_sample/tests/src/com/example/android/systemupdatersample/UpdateManagerTest.java b/updater_sample/tests/src/com/example/android/systemupdatersample/UpdateManagerTest.java
index 5ad16d4..af891f0 100644
--- a/updater_sample/tests/src/com/example/android/systemupdatersample/UpdateManagerTest.java
+++ b/updater_sample/tests/src/com/example/android/systemupdatersample/UpdateManagerTest.java
@@ -30,10 +30,11 @@
import android.os.ResultReceiver;
import android.os.UpdateEngine;
import android.os.UpdateEngineCallback;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.annotation.UiThreadTest;
-import android.support.test.filters.SmallTest;
-import android.support.test.runner.AndroidJUnit4;
+
+import androidx.test.InstrumentationRegistry;
+import androidx.test.annotation.UiThreadTest;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
import com.example.android.systemupdatersample.services.PrepareUpdateService;
import com.example.android.systemupdatersample.tests.R;
diff --git a/updater_sample/tests/src/com/example/android/systemupdatersample/util/FileDownloaderTest.java b/updater_sample/tests/src/com/example/android/systemupdatersample/util/FileDownloaderTest.java
index a136ff0..ede2457 100644
--- a/updater_sample/tests/src/com/example/android/systemupdatersample/util/FileDownloaderTest.java
+++ b/updater_sample/tests/src/com/example/android/systemupdatersample/util/FileDownloaderTest.java
@@ -19,9 +19,10 @@
import static org.junit.Assert.assertEquals;
import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.filters.SmallTest;
-import android.support.test.runner.AndroidJUnit4;
+
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
import com.example.android.systemupdatersample.tests.R;
diff --git a/updater_sample/tests/src/com/example/android/systemupdatersample/util/PayloadSpecsTest.java b/updater_sample/tests/src/com/example/android/systemupdatersample/util/PayloadSpecsTest.java
index 0308693..9931e7b 100644
--- a/updater_sample/tests/src/com/example/android/systemupdatersample/util/PayloadSpecsTest.java
+++ b/updater_sample/tests/src/com/example/android/systemupdatersample/util/PayloadSpecsTest.java
@@ -22,9 +22,10 @@
import static org.junit.Assert.assertEquals;
import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.filters.SmallTest;
-import android.support.test.runner.AndroidJUnit4;
+
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
import com.example.android.systemupdatersample.PayloadSpec;
import com.example.android.systemupdatersample.tests.R;
diff --git a/updater_sample/tests/src/com/example/android/systemupdatersample/util/UpdateConfigsTest.java b/updater_sample/tests/src/com/example/android/systemupdatersample/util/UpdateConfigsTest.java
index 4ccae93..4a967a9 100644
--- a/updater_sample/tests/src/com/example/android/systemupdatersample/util/UpdateConfigsTest.java
+++ b/updater_sample/tests/src/com/example/android/systemupdatersample/util/UpdateConfigsTest.java
@@ -18,8 +18,8 @@
import static org.junit.Assert.assertArrayEquals;
-import android.support.test.filters.SmallTest;
-import android.support.test.runner.AndroidJUnit4;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
import com.example.android.systemupdatersample.UpdateConfig;