diff options
Diffstat (limited to 'aosp')
-rw-r--r-- | aosp/binder_service_android.cc | 7 | ||||
-rw-r--r-- | aosp/binder_service_android.h | 1 | ||||
-rw-r--r-- | aosp/service_delegate_android_interface.h | 2 | ||||
-rw-r--r-- | aosp/update_attempter_android.cc | 19 | ||||
-rw-r--r-- | aosp/update_attempter_android.h | 4 | ||||
-rw-r--r-- | aosp/update_engine_client_android.cc | 5 |
6 files changed, 38 insertions, 0 deletions
diff --git a/aosp/binder_service_android.cc b/aosp/binder_service_android.cc index ed76c4a8..9efd272d 100644 --- a/aosp/binder_service_android.cc +++ b/aosp/binder_service_android.cc @@ -240,4 +240,11 @@ Status BinderUpdateEngineAndroidService::cleanupSuccessfulUpdate( return Status::ok(); } +Status BinderUpdateEngineAndroidService::setPerformanceMode(bool enable) { + brillo::ErrorPtr error; + if (!service_delegate_->SetPerformanceMode(enable, &error)) + return ErrorPtrToStatus(error); + return Status::ok(); +} + } // namespace chromeos_update_engine diff --git a/aosp/binder_service_android.h b/aosp/binder_service_android.h index f41fbdf2..6bfe2923 100644 --- a/aosp/binder_service_android.h +++ b/aosp/binder_service_android.h @@ -76,6 +76,7 @@ class BinderUpdateEngineAndroidService : public android::os::BnUpdateEngine, int64_t* return_value) override; android::binder::Status cleanupSuccessfulUpdate( const android::sp<android::os::IUpdateEngineCallback>& callback) override; + android::binder::Status setPerformanceMode(bool enable) override; private: // Remove the passed |callback| from the list of registered callbacks. Called diff --git a/aosp/service_delegate_android_interface.h b/aosp/service_delegate_android_interface.h index 3c287940..1ac71533 100644 --- a/aosp/service_delegate_android_interface.h +++ b/aosp/service_delegate_android_interface.h @@ -118,6 +118,8 @@ class ServiceDelegateAndroidInterface { std::unique_ptr<CleanupSuccessfulUpdateCallbackInterface> callback, brillo::ErrorPtr* error) = 0; + virtual bool SetPerformanceMode(bool enable, brillo::ErrorPtr* error) = 0; + protected: ServiceDelegateAndroidInterface() = default; }; diff --git a/aosp/update_attempter_android.cc b/aosp/update_attempter_android.cc index 4636c430..bc03a1f2 100644 --- a/aosp/update_attempter_android.cc +++ b/aosp/update_attempter_android.cc @@ -30,6 +30,7 @@ #include <brillo/message_loops/message_loop.h> #include <brillo/strings/string_utils.h> #include <log/log_safetynet.h> +#include <processgroup/processgroup.h> #include "update_engine/aosp/cleanup_previous_update_action.h" #include "update_engine/common/constants.h" @@ -144,6 +145,7 @@ UpdateAttempterAndroid::UpdateAttempterAndroid( metrics_reporter_ = metrics::CreateMetricsReporter( boot_control_->GetDynamicPartitionControl(), &install_plan_); network_selector_ = network::CreateNetworkSelector(); + SetTaskProfiles(0, {"ServiceCapacityLow", "LowIoPriority", "HighEnergySaving"}); } UpdateAttempterAndroid::~UpdateAttempterAndroid() { @@ -541,6 +543,23 @@ bool UpdateAttempterAndroid::VerifyPayloadApplicable( return true; } +bool UpdateAttempterAndroid::SetPerformanceMode(bool enable, + brillo::ErrorPtr* error) { + LOG(INFO) << (enable ? "Enabling" : "Disabling") << " performance mode."; + + if (performance_mode_ == enable) + return true; + bool ret; + if (enable) + ret = SetTaskProfiles(0, {"ProcessCapacityMax", "HighIoPriority", "MaxPerformance"}); + else + ret = SetTaskProfiles(0, {"ServiceCapacityLow", "LowIoPriority", "HighEnergySaving"}); + if (!ret) + return LogAndSetError(error, FROM_HERE, "Could not change profiles"); + performance_mode_ = enable; + return true; +} + void UpdateAttempterAndroid::ProcessingDone(const ActionProcessor* processor, ErrorCode code) { LOG(INFO) << "Processing Done."; diff --git a/aosp/update_attempter_android.h b/aosp/update_attempter_android.h index 70938bcd..f7c48a2d 100644 --- a/aosp/update_attempter_android.h +++ b/aosp/update_attempter_android.h @@ -90,6 +90,8 @@ class UpdateAttempterAndroid std::unique_ptr<CleanupSuccessfulUpdateCallbackInterface> callback, brillo::ErrorPtr* error) override; + bool SetPerformanceMode(bool enable, brillo::ErrorPtr* error) override; + // ActionProcessorDelegate methods: void ProcessingDone(const ActionProcessor* processor, ErrorCode code) override; @@ -245,6 +247,8 @@ class UpdateAttempterAndroid // CleanupPreviousUpdateAction has not been executed. std::optional<ErrorCode> cleanup_previous_update_code_{std::nullopt}; + bool performance_mode_ = false; + DISALLOW_COPY_AND_ASSIGN(UpdateAttempterAndroid); }; diff --git a/aosp/update_engine_client_android.cc b/aosp/update_engine_client_android.cc index 1a68cf49..2b3cfffe 100644 --- a/aosp/update_engine_client_android.cc +++ b/aosp/update_engine_client_android.cc @@ -149,6 +149,7 @@ int UpdateEngineClientAndroid::OnInit() { false, "Wait for previous update to merge. " "Only available after rebooting to new slot."); + DEFINE_bool(perf_mode, false, "Enable perf mode."); // Boilerplate init commands. base::CommandLine::Init(argc_, argv_); brillo::FlagHelper::Init(argc_, argv_, "Android Update Engine Client"); @@ -237,6 +238,10 @@ int UpdateEngineClientAndroid::OnInit() { keep_running = true; } + if (FLAGS_perf_mode) { + return ExitWhenIdle(service_->setPerformanceMode(true)); + } + if (FLAGS_follow) { // Register a callback object with the service. callback_ = new UECallback(this); |