libprocessgroup: new method to get cgroup paths
Bug: 180056337
Test: Verified the app freezer is correctly enabled via logs
Change-Id: I3d954dd9bb0f1fa509a275d587e603f33a9d563f
diff --git a/libprocessgroup/include/processgroup/processgroup.h b/libprocessgroup/include/processgroup/processgroup.h
index 1aaed7b..f826e9c 100644
--- a/libprocessgroup/include/processgroup/processgroup.h
+++ b/libprocessgroup/include/processgroup/processgroup.h
@@ -36,7 +36,8 @@
static constexpr const char* CGROUPS_RC_PATH = "/dev/cgroup_info/cgroup.rc";
// Path to test against for freezer support
-// TODO: remove and replace with a function call, see http://b/180056337
+// TODO: remove it once https://r.android.com/1607196 is properly merged to all branches,
+// see http://b/180056337
static constexpr const char* CGROUP_FREEZE_PATH = "/sys/fs/cgroup/uid_0/cgroup.freeze";
bool UsePerAppMemcg();
@@ -68,6 +69,10 @@
void removeAllProcessGroups(void);
+// Provides the path for an attribute in a specific process group
+// Returns false in case of error, true in case of success
+bool getAttributePathForTask(const std::string& attr_name, int tid, std::string* path);
+
#endif // __ANDROID_VNDK__
__END_DECLS
diff --git a/libprocessgroup/processgroup.cpp b/libprocessgroup/processgroup.cpp
index 209ccd9..815d2bb 100644
--- a/libprocessgroup/processgroup.cpp
+++ b/libprocessgroup/processgroup.cpp
@@ -508,3 +508,7 @@
bool setProcessGroupLimit(uid_t, int pid, int64_t limit_in_bytes) {
return SetProcessGroupValue(pid, "MemLimit", limit_in_bytes);
}
+
+bool getAttributePathForTask(const std::string& attr_name, int tid, std::string* path) {
+ return CgroupGetAttributePathForTask(attr_name, tid, path);
+}
diff --git a/libprocessgroup/profiles/cgroups.json b/libprocessgroup/profiles/cgroups.json
index 7bcb94b..962d2ba 100644
--- a/libprocessgroup/profiles/cgroups.json
+++ b/libprocessgroup/profiles/cgroups.json
@@ -37,7 +37,7 @@
"Controllers": [
{
"Controller": "freezer",
- "Path": "freezer",
+ "Path": ".",
"Mode": "0755",
"UID": "system",
"GID": "system"