Merge branch 'pie-gsi' of https://android.googlesource.com/platform//system/update_engine into HEAD
Change-Id: Idf70210c8b65816645ba6830a3731ada922c4ec0
diff --git a/binder_bindings/android/os/IUpdateEngine.aidl b/binder_bindings/android/os/IUpdateEngine.aidl
index c0e29f5..a0b0377 100644
--- a/binder_bindings/android/os/IUpdateEngine.aidl
+++ b/binder_bindings/android/os/IUpdateEngine.aidl
@@ -39,4 +39,6 @@
void resetStatus();
/** @hide */
boolean verifyPayloadApplicable(in String metadataFilename);
+ /** @hide */
+ void setPerformanceMode(in boolean enable);
}
diff --git a/binder_service_android.cc b/binder_service_android.cc
index 1702ead..afcbaeb 100644
--- a/binder_service_android.cc
+++ b/binder_service_android.cc
@@ -168,4 +168,11 @@
return true;
}
+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/binder_service_android.h b/binder_service_android.h
index 694b80a..0738968 100644
--- a/binder_service_android.h
+++ b/binder_service_android.h
@@ -67,6 +67,7 @@
android::binder::Status resetStatus() override;
android::binder::Status verifyPayloadApplicable(
const android::String16& metadata_filename, bool* return_value) override;
+ android::binder::Status setPerformanceMode(bool enable) override;
private:
// Remove the passed |callback| from the list of registered callbacks. Called
diff --git a/service_delegate_android_interface.h b/service_delegate_android_interface.h
index 5267bb0..d8bd11d 100644
--- a/service_delegate_android_interface.h
+++ b/service_delegate_android_interface.h
@@ -76,6 +76,8 @@
virtual bool VerifyPayloadApplicable(const std::string& metadata_filename,
brillo::ErrorPtr* error) = 0;
+ virtual bool SetPerformanceMode(bool enable, brillo::ErrorPtr* error) = 0;
+
protected:
ServiceDelegateAndroidInterface() = default;
};
diff --git a/update_attempter_android.cc b/update_attempter_android.cc
index 406e40a..42fd63d 100644
--- a/update_attempter_android.cc
+++ b/update_attempter_android.cc
@@ -29,6 +29,7 @@
#include <brillo/data_encoding.h>
#include <brillo/message_loops/message_loop.h>
#include <brillo/strings/string_utils.h>
+#include <cutils/sched_policy.h>
#include <log/log_safetynet.h>
#include "update_engine/common/constants.h"
@@ -109,6 +110,7 @@
clock_(new Clock()) {
metrics_reporter_ = metrics::CreateMetricsReporter();
network_selector_ = network::CreateNetworkSelector();
+ set_cpuset_policy(0, SP_BACKGROUND);
}
UpdateAttempterAndroid::~UpdateAttempterAndroid() {
@@ -426,6 +428,18 @@
return true;
}
+bool UpdateAttempterAndroid::SetPerformanceMode(bool enable,
+ brillo::ErrorPtr* error) {
+ LOG(INFO) << (enable ? "Enabling" : "Disabling") << " performance mode.";
+
+ if (performance_mode_ == enable)
+ return true;
+ if (set_cpuset_policy(0, enable ? SP_FOREGROUND : SP_BACKGROUND) < 0)
+ return LogAndSetError(error, FROM_HERE, "Could not change policy");
+ performance_mode_ = enable;
+ return true;
+}
+
void UpdateAttempterAndroid::ProcessingDone(const ActionProcessor* processor,
ErrorCode code) {
LOG(INFO) << "Processing Done.";
diff --git a/update_attempter_android.h b/update_attempter_android.h
index f00692e..57f9e8f 100644
--- a/update_attempter_android.h
+++ b/update_attempter_android.h
@@ -71,6 +71,7 @@
bool ResetStatus(brillo::ErrorPtr* error) override;
bool VerifyPayloadApplicable(const std::string& metadata_filename,
brillo::ErrorPtr* error) override;
+ bool SetPerformanceMode(bool enable, brillo::ErrorPtr* error) override;
// ActionProcessorDelegate methods:
void ProcessingDone(const ActionProcessor* processor,
@@ -208,6 +209,8 @@
std::unique_ptr<MetricsReporterInterface> metrics_reporter_;
+ bool performance_mode_ = false;
+
DISALLOW_COPY_AND_ASSIGN(UpdateAttempterAndroid);
};
diff --git a/update_engine.rc b/update_engine.rc
index a7d6235..d1d0d1d 100644
--- a/update_engine.rc
+++ b/update_engine.rc
@@ -2,7 +2,6 @@
class late_start
user root
group root system wakelock inet cache
- writepid /dev/cpuset/system-background/tasks
disabled
on property:ro.boot.slot_suffix=*
diff --git a/update_engine_client_android.cc b/update_engine_client_android.cc
index 267f6e9..6c22b56 100644
--- a/update_engine_client_android.cc
+++ b/update_engine_client_android.cc
@@ -132,6 +132,7 @@
false,
"Follow status update changes until a final state is reached. "
"Exit status is 0 if the update succeeded, and 1 otherwise.");
+ DEFINE_bool(perf_mode, false, "Enable perf mode.");
// Boilerplate init commands.
base::CommandLine::Init(argc_, argv_);
@@ -182,6 +183,10 @@
return ExitWhenIdle(service_->resetStatus());
}
+ if (FLAGS_perf_mode) {
+ return ExitWhenIdle(service_->setPerformanceMode(true));
+ }
+
if (FLAGS_follow) {
// Register a callback object with the service.
callback_ = new UECallback(this);