libprocessgroup: use libcgrouprc to read cgroup.rc
Use the LL-NDK library to read cgroup.rc.
As a side-effect, the CgroupController class is changed
to a wrapper of ACgroupController* from the library. The
class itself essentially becomes the pointer, and can be
trivially copied. Modify all client code for this change.
Test: builds and boots
Bug: 123664216
Change-Id: I635d9885db62e82f37421f6d20f59c84a6f4cbb2
Merged-In: I635d9885db62e82f37421f6d20f59c84a6f4cbb2
diff --git a/libprocessgroup/processgroup.cpp b/libprocessgroup/processgroup.cpp
index 3f6b2d7..abe63dd 100644
--- a/libprocessgroup/processgroup.cpp
+++ b/libprocessgroup/processgroup.cpp
@@ -56,14 +56,14 @@
#define PROCESSGROUP_CGROUP_PROCS_FILE "/cgroup.procs"
bool CgroupGetControllerPath(const std::string& cgroup_name, std::string* path) {
- const CgroupController* controller = CgroupMap::GetInstance().FindController(cgroup_name);
+ auto controller = CgroupMap::GetInstance().FindController(cgroup_name);
- if (controller == nullptr) {
+ if (!controller.HasValue()) {
return false;
}
if (path) {
- *path = controller->path();
+ *path = controller.path();
}
return true;
@@ -107,7 +107,7 @@
static bool isMemoryCgroupSupported() {
std::string cgroup_name;
- static bool memcg_supported = (CgroupMap::GetInstance().FindController("memory") != nullptr);
+ static bool memcg_supported = CgroupMap::GetInstance().FindController("memory").HasValue();
return memcg_supported;
}