Add OWNERS for odsign_e2e_tests. am: 11bdac03c5 am: 188c6c207c am: fdcc21eaf9
Original change: https://android-review.googlesource.com/c/platform/art/+/2051201
Change-Id: I32d0aeba012a752615d435591c25522c2ae6be3d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/libartservice/service/java/com/android/server/art/ArtManagerLocal.java b/libartservice/service/java/com/android/server/art/ArtManagerLocal.java
index 04629cb..aac4b25 100644
--- a/libartservice/service/java/com/android/server/art/ArtManagerLocal.java
+++ b/libartservice/service/java/com/android/server/art/ArtManagerLocal.java
@@ -16,6 +16,8 @@
package com.android.server.art;
+import libcore.api.CorePlatformApi;
+
/**
* This class provides a system API for functionality provided by the ART
* module.
diff --git a/odrefresh/odr_common.cc b/odrefresh/odr_common.cc
index c3c410e..a83e18e 100644
--- a/odrefresh/odr_common.cc
+++ b/odrefresh/odr_common.cc
@@ -17,16 +17,24 @@
#include "odr_common.h"
#include <initializer_list>
+#include <regex>
#include <sstream>
#include <string>
#include <string_view>
#include "android-base/logging.h"
#include "android-base/parseint.h"
+#include "android-base/result.h"
namespace art {
namespace odrefresh {
+namespace {
+
+using ::android::base::Result;
+
+}
+
std::string Concatenate(std::initializer_list<std::string_view> args) {
std::stringstream ss;
for (auto arg : args) {
@@ -39,10 +47,34 @@
return Concatenate({"'", path, "'"});
}
+Result<int> ParseSecurityPatchStr(const std::string& security_patch_str) {
+ std::regex security_patch_regex(R"re((\d{4})-(\d{2})-(\d{2}))re");
+ std::smatch m;
+ if (!std::regex_match(security_patch_str, m, security_patch_regex)) {
+ return Errorf("Invalid security patch string \"{}\"", security_patch_str);
+ }
+ int year = 0, month = 0, day = 0;
+ if (!android::base::ParseInt(m[1], &year) ||
+ !android::base::ParseInt(m[2], &month) ||
+ !android::base::ParseInt(m[3], &day)) {
+ // This should never happen because the string already matches the regex.
+ return Errorf("Unknown error when parsing security patch string \"{}\"", security_patch_str);
+ }
+ return year * 10000 + month * 100 + day;
+}
+
+bool ShouldDisablePartialCompilation(const std::string& security_patch_str) {
+ Result<int> security_patch_value = ParseSecurityPatchStr(security_patch_str);
+ if (!security_patch_value.ok()) {
+ LOG(ERROR) << security_patch_value.error();
+ return false;
+ }
+ return security_patch_value.value() < ParseSecurityPatchStr("2022-03-05").value();
+}
+
bool ShouldDisableRefresh(const std::string& sdk_version_str) {
int sdk_version = 0;
if (!android::base::ParseInt(sdk_version_str, &sdk_version)) {
- LOG(ERROR) << "Invalid SDK version string \"" << sdk_version_str << "\"";
return false;
}
return sdk_version >= 32;
diff --git a/odrefresh/odr_common.h b/odrefresh/odr_common.h
index c7680e2..63f35f9 100644
--- a/odrefresh/odr_common.h
+++ b/odrefresh/odr_common.h
@@ -21,6 +21,8 @@
#include <string>
#include <string_view>
+#include "android-base/result.h"
+
namespace art {
namespace odrefresh {
@@ -30,6 +32,13 @@
// Quotes a path with single quotes (').
std::string QuotePath(std::string_view path);
+// Converts the security patch date to a comparable integer.
+android::base::Result<int> ParseSecurityPatchStr(const std::string& security_patch_str);
+
+// Returns true if partial compilation should be disabled. Takes a string from
+// `ro.build.version.security_patch`, which represents the security patch date.
+bool ShouldDisablePartialCompilation(const std::string& security_patch_str);
+
// Returns true if there is no need to load existing artifacts that are already up-to-date and write
// them back. See `OnDeviceRefresh::RefreshExistingArtifacts` for more details. Takes a string from
// `ro.build.version.sdk`, which represents the SDK version.
diff --git a/odrefresh/odr_common_test.cc b/odrefresh/odr_common_test.cc
index 976b3f0..150f57b 100644
--- a/odrefresh/odr_common_test.cc
+++ b/odrefresh/odr_common_test.cc
@@ -22,6 +22,31 @@
namespace art {
namespace odrefresh {
+namespace {
+
+using ::android::base::Result;
+
+}
+
+TEST(OdrCommonTest, ParseSecurityPatchStr) {
+ Result<int> result = ParseSecurityPatchStr("2022-03-08");
+ EXPECT_TRUE(result.ok());
+ EXPECT_EQ(result.value(), 20220308);
+ EXPECT_FALSE(ParseSecurityPatchStr("").ok());
+ EXPECT_FALSE(ParseSecurityPatchStr("20-2203-08").ok());
+ EXPECT_FALSE(ParseSecurityPatchStr("20220308").ok());
+}
+
+TEST(OdrCommonTest, ShouldDisablePartialCompilation) {
+ EXPECT_TRUE(ShouldDisablePartialCompilation("2021-03-05"));
+ EXPECT_TRUE(ShouldDisablePartialCompilation("2022-02-05"));
+ EXPECT_TRUE(ShouldDisablePartialCompilation("2022-03-04"));
+ EXPECT_FALSE(ShouldDisablePartialCompilation("2022-03-05"));
+ EXPECT_FALSE(ShouldDisablePartialCompilation("2022-03-06"));
+ EXPECT_FALSE(ShouldDisablePartialCompilation("2022-04-04"));
+ EXPECT_FALSE(ShouldDisablePartialCompilation("2023-03-04"));
+}
+
TEST(OdrCommonTest, ShouldDisableRefresh) {
EXPECT_TRUE(ShouldDisableRefresh("32"));
EXPECT_TRUE(ShouldDisableRefresh("33"));
diff --git a/odrefresh/odr_config.h b/odrefresh/odr_config.h
index d95ab96..ec0290c 100644
--- a/odrefresh/odr_config.h
+++ b/odrefresh/odr_config.h
@@ -128,6 +128,9 @@
}
bool GetDryRun() const { return dry_run_; }
+ bool HasPartialCompilation() const {
+ return partial_compilation_.has_value();
+ }
bool GetPartialCompilation() const {
return partial_compilation_.value_or(true);
}
diff --git a/odrefresh/odrefresh_main.cc b/odrefresh/odrefresh_main.cc
index c2298f0..ffce81c 100644
--- a/odrefresh/odrefresh_main.cc
+++ b/odrefresh/odrefresh_main.cc
@@ -41,6 +41,7 @@
using ::art::odrefresh::OdrMetrics;
using ::art::odrefresh::OnDeviceRefresh;
using ::art::odrefresh::QuotePath;
+using ::art::odrefresh::ShouldDisablePartialCompilation;
using ::art::odrefresh::ShouldDisableRefresh;
using ::art::odrefresh::ZygoteKind;
@@ -169,6 +170,12 @@
config->SetSystemServerCompilerFilter(filter);
}
+ if (!config->HasPartialCompilation() &&
+ ShouldDisablePartialCompilation(
+ android::base::GetProperty("ro.build.version.security_patch", /*default_value=*/""))) {
+ config->SetPartialCompilation(false);
+ }
+
if (ShouldDisableRefresh(
android::base::GetProperty("ro.build.version.sdk", /*default_value=*/""))) {
config->SetRefresh(false);