Merge changes from topic "freezer path" into sc-dev

* changes:
  CachedAppOptimizer: enable single cgroup freezer
  CachedAppOptimizer: don't hardcode freezer path
This commit is contained in:
TreeHugger Robot
2021-02-09 23:22:04 +00:00
committed by Android (Google) Code Review
2 changed files with 19 additions and 2 deletions

View File

@@ -537,6 +537,12 @@ public final class CachedAppOptimizer {
*/
private static native int getBinderFreezeInfo(int pid);
/**
* Returns the path to be checked to verify whether the freezer is supported by this system.
* @return absolute path to the file
*/
private static native String getFreezerCheckPath();
/**
* Determines whether the freezer is supported by this system
*/
@@ -545,11 +551,15 @@ public final class CachedAppOptimizer {
FileReader fr = null;
try {
fr = new FileReader("/sys/fs/cgroup/uid_0/cgroup.freeze");
fr = new FileReader(getFreezerCheckPath());
char state = (char) fr.read();
if (state == '1' || state == '0') {
supported = true;
// This is a workaround after reverting the cgroup v2 uid/pid hierarchy due to
// http://b/179006802.
// TODO: remove once the uid/pid hierarchy is restored
enableFreezerInternal(true);
} else {
Slog.e(TAG_AM, "unexpected value in cgroup.freeze");
}

View File

@@ -278,6 +278,11 @@ static jint com_android_server_am_CachedAppOptimizer_getBinderFreezeInfo(JNIEnv
return retVal;
}
static jstring com_android_server_am_CachedAppOptimizer_getFreezerCheckPath(JNIEnv* env,
jobject clazz) {
return env->NewStringUTF(CGROUP_FREEZE_PATH);
}
static const JNINativeMethod sMethods[] = {
/* name, signature, funcPtr */
{"compactSystem", "()V", (void*)com_android_server_am_CachedAppOptimizer_compactSystem},
@@ -286,7 +291,9 @@ static const JNINativeMethod sMethods[] = {
(void*)com_android_server_am_CachedAppOptimizer_enableFreezerInternal},
{"freezeBinder", "(IZ)V", (void*)com_android_server_am_CachedAppOptimizer_freezeBinder},
{"getBinderFreezeInfo", "(I)I",
(void*)com_android_server_am_CachedAppOptimizer_getBinderFreezeInfo}};
(void*)com_android_server_am_CachedAppOptimizer_getBinderFreezeInfo},
{"getFreezerCheckPath", "()Ljava/lang/String;",
(void*)com_android_server_am_CachedAppOptimizer_getFreezerCheckPath}};
int register_android_server_am_CachedAppOptimizer(JNIEnv* env)
{