diff options
Diffstat (limited to 'misc_writer/misc_writer_main.cpp')
-rw-r--r-- | misc_writer/misc_writer_main.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/misc_writer/misc_writer_main.cpp b/misc_writer/misc_writer_main.cpp index 0af45a91..aafb348d 100644 --- a/misc_writer/misc_writer_main.cpp +++ b/misc_writer/misc_writer_main.cpp @@ -42,6 +42,7 @@ static int Usage(std::string_view name) { std::cerr << " --clear-dark-theme Clear the dark theme flag\n"; std::cerr << " --set-sota Write the silent OTA flag\n"; std::cerr << " --clear-sota Clear the silent OTA flag\n"; + std::cerr << " --set-sota-config Set the silent OTA configs\n"; std::cerr << " --set-enable-pkvm Write the enable pKVM flag\n"; std::cerr << " --set-disable-pkvm Write the disable pKVM flag\n"; std::cerr << " --set-wrist-orientation <0-3> Write the wrist orientation flag\n"; @@ -50,6 +51,10 @@ static int Usage(std::string_view name) { std::cerr << " --set-timeoffset Write the time offset value (tz_time - utc_time)\n"; std::cerr << " --set-max-ram-size <2048-65536> Write the sw limit max ram size in MB\n"; std::cerr << " --set-max-ram-size <-1> Clear the sw limit max ram size\n"; + std::cerr << " --set-timertcoffset Write the time offset value (utc_time - rtc_time)\n"; + std::cerr << " --set-minrtc Write the minimum expected rtc value for tilb\n"; + std::cerr << " --set-dsttransition Write the next dst transition in the current timezone\n"; + std::cerr << " --set-dstoffset Write the time offset during the next dst transition\n"; std::cerr << "Writes the given hex string to the specified offset in vendor space in /misc " "partition.\nDefault offset is used for each action unless " "--override-vendor-space-offset is specified.\n"; @@ -71,6 +76,11 @@ int main(int argc, char** argv) { { "set-timeformat", required_argument, nullptr, 0}, { "set-timeoffset", required_argument, nullptr, 0}, { "set-max-ram-size", required_argument, nullptr, 0}, + { "set-timertcoffset", required_argument, nullptr, 0}, + { "set-minrtc", required_argument, nullptr, 0}, + { "set-sota-config", no_argument, nullptr, 0 }, + { "set-dsttransition", required_argument, nullptr, 0}, + { "set-dstoffset", required_argument, nullptr, 0 }, { nullptr, 0, nullptr, 0 }, }; @@ -82,6 +92,7 @@ int main(int argc, char** argv) { { "set-enable-pkvm", MiscWriterActions::kSetEnablePkvmFlag }, { "set-disable-pkvm", MiscWriterActions::kSetDisablePkvmFlag }, { "clear-wrist-orientation", MiscWriterActions::kClearWristOrientationFlag }, + { "set-sota-config", MiscWriterActions::kSetSotaConfig }, }; std::unique_ptr<MiscWriter> misc_writer; @@ -173,12 +184,60 @@ int main(int argc, char** argv) { misc_writer = std::make_unique<MiscWriter>(MiscWriterActions::kSetMaxRamSize, std::to_string(max_ram_size)); } + } else if (option_name == "set-timertcoffset"s) { + long long int timertcoffset = strtoll(optarg, NULL, 10); + if (0 == timertcoffset) { + LOG(ERROR) << "Failed to parse the timertcoffset:" << optarg; + return Usage(argv[0]); + } + if (misc_writer) { + LOG(ERROR) << "Misc writer action has already been set"; + return Usage(argv[0]); + } + misc_writer = std::make_unique<MiscWriter>(MiscWriterActions::kWriteTimeRtcOffset, + std::to_string(timertcoffset)); + } else if (option_name == "set-minrtc"s) { + long long int minrtc = strtoll(optarg, NULL, 10); + if (0 == minrtc) { + LOG(ERROR) << "Failed to parse the minrtc:" << optarg; + return Usage(argv[0]); + } + if (misc_writer) { + LOG(ERROR) << "Misc writer action has already been set"; + return Usage(argv[0]); + } + misc_writer = std::make_unique<MiscWriter>(MiscWriterActions::kWriteTimeMinRtc, + std::to_string(minrtc)); } else if (auto iter = action_map.find(option_name); iter != action_map.end()) { if (misc_writer) { LOG(ERROR) << "Misc writer action has already been set"; return Usage(argv[0]); } misc_writer = std::make_unique<MiscWriter>(iter->second); + } else if (option_name == "set-dsttransition"s) { + long long int dst_transition = strtoll(optarg, NULL, 10); + if (0 == dst_transition) { + LOG(ERROR) << "Failed to parse the dst transition:" << optarg; + return Usage(argv[0]); + } + if (misc_writer) { + LOG(ERROR) << "Misc writer action has already been set"; + return Usage(argv[0]); + } + misc_writer = std::make_unique<MiscWriter>(MiscWriterActions::kWriteDstTransition, + std::to_string(dst_transition)); + } else if (option_name == "set-dstoffset"s) { + int dst_offset; + if (!android::base::ParseInt(optarg, &dst_offset)) { + LOG(ERROR) << "Failed to parse the dst offset: " << optarg; + return Usage(argv[0]); + } + if (misc_writer) { + LOG(ERROR) << "Misc writer action has already been set"; + return Usage(argv[0]); + } + misc_writer = std::make_unique<MiscWriter>(MiscWriterActions::kWriteDstOffset, + std::to_string(dst_offset)); } else { LOG(FATAL) << "Unreachable path, option_name: " << option_name; } |