using ::android::base::GetProperty; using ::android::base::ParseBool; using ::android::base::ParseBoolResult; using ::art::odrefresh::CompilationOptions; using ::art::odrefresh::ExitCode; using ::art::odrefresh::kCheckedSystemPropertyPrefixes; using ::art::odrefresh::kSystemProperties; using ::art::odrefresh::kSystemPropertySystemServerCompilerFilterOverride; using ::art::odrefresh::OdrCompilationLog; using ::art::odrefresh::OdrConfig; using ::art::odrefresh::OdrMetrics; using ::art::odrefresh::OnDeviceRefresh; using ::art::odrefresh::QuotePath; using ::art::odrefresh::ShouldDisablePartialCompilation; using ::art::odrefresh::ShouldDisableRefresh; using ::art::odrefresh::SystemPropertyConfig; using ::art::odrefresh::SystemPropertyForeach; using ::art::odrefresh::ZygoteKind;
std::string zygote; int n = 1; for (; n < argc - 1; ++n) { constchar* arg = argv[n];
std::string value; if (ArgumentEquals(arg, "--compilation-os-mode")) {
config->SetCompilationOsMode(true);
} elseif (ArgumentMatches(arg, "--dalvik-cache=", &value)) {
art::OverrideDalvikCacheSubDirectory(value);
config->SetArtifactDirectory(GetApexDataDalvikCacheDirectory(art::InstructionSet::kNone));
} elseif (ArgumentMatches(arg, "--zygote-arch=", &value)) {
zygote = value;
} elseif (ArgumentMatches(arg, "--boot-image-compiler-filter=", &value)) {
config->SetBootImageCompilerFilter(value);
} elseif (ArgumentMatches(arg, "--system-server-compiler-filter=", &value)) {
config->SetSystemServerCompilerFilter(value);
} elseif (ArgumentMatches(arg, "--staging-dir=", &value)) { // Keep this for compatibility with CompOS in old platforms.
LOG(WARNING) << "--staging-dir is deprecated and its value is ignored";
} elseif (ArgumentEquals(arg, "--dry-run")) {
config->SetDryRun();
} elseif (ArgumentMatches(arg, "--partial-compilation=", &value)) {
config->SetPartialCompilation(ParseBool(value) == ParseBoolResult::kTrue);
} elseif (ArgumentEquals(arg, "--no-refresh")) {
config->SetRefresh(false);
} elseif (ArgumentEquals(arg, "--minimal")) {
config->SetMinimal(true);
} elseif (ArgumentEquals(arg, "--only-boot-images")) {
config->SetOnlyBootImages(true);
} else {
ArgumentError("Unrecognized argument: '%s'", arg);
}
}
if (zygote.empty()) { // Use ro.zygote by default, if not overridden by --zygote-arch flag.
zygote = GetProperty("ro.zygote", {});
}
ZygoteKind zygote_kind; if (!ParseZygoteKind(zygote.c_str(), &zygote_kind)) {
LOG(FATAL) << "Unknown zygote: " << QuotePath(zygote);
}
config->SetZygoteKind(zygote_kind);
NO_RETURN void UsageHelp(constchar* argv0) {
std::string name(android::base::Basename(argv0));
UsageMsg("Usage: %s [OPTION...] ACTION", name.c_str());
UsageMsg("On-device refresh tool for boot classpath and system server");
UsageMsg("following an update of the ART APEX.");
UsageMsg("");
UsageMsg("Valid ACTION choices are:");
UsageMsg("");
UsageMsg("--check Check compilation artifacts are up-to-date based on metadata.");
UsageMsg("--compile Compile boot classpath and system_server jars when necessary.");
UsageMsg("--force-compile Unconditionally compile the bootclass path and system_server jars.");
UsageMsg("--help Display this help information.");
UsageMsg("");
UsageMsg("Available OPTIONs are:");
UsageMsg("");
UsageMsg("--dry-run");
UsageMsg("--partial-compilation Only generate artifacts that are out-of-date or");
UsageMsg(" missing.");
UsageMsg("--no-refresh Do not refresh existing artifacts.");
UsageMsg("--compilation-os-mode Indicate that odrefresh is running in Compilation");
UsageMsg(" OS.");
UsageMsg("--dalvik-cache=<DIR> Write artifacts to .../<DIR> rather than");
UsageMsg(" .../dalvik-cache");
UsageMsg("--zygote-arch=<STRING> Zygote kind that overrides ro.zygote");
UsageMsg("--boot-image-compiler-filter=<STRING>");
UsageMsg(" Compiler filter for the boot image. Default: ");
UsageMsg(" speed-profile");
UsageMsg("--system-server-compiler-filter=<STRING>");
UsageMsg(" Compiler filter that overrides");
UsageMsg(" dalvik.vm.systemservercompilerfilter");
UsageMsg("--minimal Generate a minimal boot image only.");
UsageMsg("--only-boot-images Generate boot images only.");
exit(EX_USAGE);
}
} // namespace
int main(int argc, char** argv) { // odrefresh is launched by `init` which sets the umask of forked processed to // 077 (S_IRWXG | S_IRWXO). This blocks the ability to make files and directories readable // by others and prevents system_server from loading generated artifacts.
umask(S_IWGRP | S_IWOTH);
std::string_view action(argv[0]);
CompilationOptions compilation_options; if (action == "--check") { // Fast determination of whether artifacts are up to date.
ExitCode exit_code = odr.CheckArtifactsAreUpToDate(metrics, &compilation_options); // Normally, `--check` should not write metrics. If compilation is not required, there's no need // to write metrics; if compilation is required, `--compile` will write metrics. Therefore, // `--check` should only write metrics when things went wrong.
metrics.SetEnabled(exit_code != ExitCode::kOkay && exit_code != ExitCode::kCompilationRequired); return exit_code;
} elseif (action == "--compile") {
ExitCode exit_code = odr.CheckArtifactsAreUpToDate(metrics, &compilation_options); if (exit_code != ExitCode::kCompilationRequired) { // No compilation required, so only write metrics when things went wrong.
metrics.SetEnabled(exit_code != ExitCode::kOkay); return exit_code;
} if (config.GetSystemProperties().GetBool("dalvik.vm.disable-odrefresh", /*default_value=*/false)) {
LOG(INFO) << "Compilation skipped because it's disabled by system property"; return ExitCode::kOkay;
}
OdrCompilationLog compilation_log; if (!compilation_log.ShouldAttemptCompile(metrics.GetTrigger())) {
LOG(INFO) << "Compilation skipped because it was attempted recently"; return ExitCode::kOkay;
} // Compilation required, so always write metrics.
metrics.SetEnabled(true);
ExitCode compile_result = odr.Compile(metrics, compilation_options);
compilation_log.Log(metrics.GetArtApexVersion(),
metrics.GetArtApexLastUpdateMillis(),
metrics.GetTrigger(),
compile_result); return compile_result;
} elseif (action == "--force-compile") { // Clean-up existing files. if (!odr.RemoveArtifactsDirectory()) {
metrics.SetStatus(OdrMetrics::Status::kIoError); return ExitCode::kCleanupFailed;
} return odr.Compile(metrics, CompilationOptions::CompileAll(odr));
} elseif (action == "--help") {
UsageHelp(argv[0]);
} else {
ArgumentError("Unknown argument: %s", action.data());
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.