Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ea96250c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

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

* changes:
  CachedAppOptimizer: enable single cgroup freezer
  CachedAppOptimizer: don't hardcode freezer path
parents 3987bddb be4d5394
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -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");
            }
+8 −1
Original line number Diff line number Diff line
@@ -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)
{