Merge "libprocessgroup: Proceed if activation of an optional controller fails"
diff --git a/fs_mgr/libsnapshot/snapuserd/include/snapuserd/snapuserd_client.h b/fs_mgr/libsnapshot/snapuserd/include/snapuserd/snapuserd_client.h
index fb2251e..010beb3 100644
--- a/fs_mgr/libsnapshot/snapuserd/include/snapuserd/snapuserd_client.h
+++ b/fs_mgr/libsnapshot/snapuserd/include/snapuserd/snapuserd_client.h
@@ -47,6 +47,8 @@
bool ValidateConnection();
std::string GetDaemonAliveIndicatorPath();
+ void WaitForServiceToTerminate(std::chrono::milliseconds timeout_ms);
+
public:
explicit SnapuserdClient(android::base::unique_fd&& sockfd);
SnapuserdClient(){};
diff --git a/fs_mgr/libsnapshot/snapuserd/snapuserd_client.cpp b/fs_mgr/libsnapshot/snapuserd/snapuserd_client.cpp
index 695b581..3bed3a4 100644
--- a/fs_mgr/libsnapshot/snapuserd/snapuserd_client.cpp
+++ b/fs_mgr/libsnapshot/snapuserd/snapuserd_client.cpp
@@ -94,6 +94,21 @@
return client;
}
+void SnapuserdClient::WaitForServiceToTerminate(std::chrono::milliseconds timeout_ms) {
+ auto start = std::chrono::steady_clock::now();
+ while (android::base::GetProperty("init.svc.snapuserd", "") == "running") {
+ auto now = std::chrono::steady_clock::now();
+ auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(now - start);
+ if (elapsed >= timeout_ms) {
+ LOG(ERROR) << "Timed out - Snapuserd service did not stop - Forcefully terminating the "
+ "service";
+ android::base::SetProperty("ctl.stop", "snapuserd");
+ return;
+ }
+ std::this_thread::sleep_for(100ms);
+ }
+}
+
bool SnapuserdClient::ValidateConnection() {
if (!Sendmsg("query")) {
return false;
@@ -238,6 +253,8 @@
LOG(ERROR) << "Failed to detach snapuserd.";
return false;
}
+
+ WaitForServiceToTerminate(3s);
return true;
}
diff --git a/libstats/expresslog/Histogram.cpp b/libstats/expresslog/Histogram.cpp
index c90282d..cb29a00 100644
--- a/libstats/expresslog/Histogram.cpp
+++ b/libstats/expresslog/Histogram.cpp
@@ -26,8 +26,8 @@
namespace android {
namespace expresslog {
-Histogram::UniformOptions* Histogram::UniformOptions::create(int binCount, float minValue,
- float exclusiveMaxValue) {
+std::shared_ptr<Histogram::UniformOptions> Histogram::UniformOptions::create(
+ int binCount, float minValue, float exclusiveMaxValue) {
if (binCount < 1) {
ALOGE("Bin count should be positive number");
return nullptr;
@@ -38,7 +38,8 @@
return nullptr;
}
- return new UniformOptions(binCount, minValue, exclusiveMaxValue);
+ return std::shared_ptr<UniformOptions>(
+ new UniformOptions(binCount, minValue, exclusiveMaxValue));
}
Histogram::UniformOptions::UniformOptions(int binCount, float minValue, float exclusiveMaxValue)
diff --git a/libstats/expresslog/include/Histogram.h b/libstats/expresslog/include/Histogram.h
index aba2786..8fdc1b6 100644
--- a/libstats/expresslog/include/Histogram.h
+++ b/libstats/expresslog/include/Histogram.h
@@ -46,10 +46,9 @@
/** Used by Histogram to map data sample to corresponding bin for uniform bins */
class UniformOptions : public BinOptions {
- UniformOptions(int binCount, float minValue, float exclusiveMaxValue);
-
public:
- static UniformOptions* create(int binCount, float minValue, float exclusiveMaxValue);
+ static std::shared_ptr<UniformOptions> create(int binCount, float minValue,
+ float exclusiveMaxValue);
int getBinsCount() const override {
return mBinCount;
@@ -58,6 +57,8 @@
int getBinForSample(float sample) const override;
private:
+ UniformOptions(int binCount, float minValue, float exclusiveMaxValue);
+
const int mBinCount;
const float mMinValue;
const float mExclusiveMaxValue;