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

Commit ecff3904 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes from topic "freezer path" into sc-dev am: ea96250c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13498477

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I9d6d7df36f55a4f98fb3aeab0a204ca321a3486c
parents af3a863a ea96250c
Loading
Loading
Loading
Loading
+11 −1
Original line number Original line Diff line number Diff line
@@ -537,6 +537,12 @@ public final class CachedAppOptimizer {
     */
     */
    private static native int getBinderFreezeInfo(int pid);
    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
     * Determines whether the freezer is supported by this system
     */
     */
@@ -545,11 +551,15 @@ public final class CachedAppOptimizer {
        FileReader fr = null;
        FileReader fr = null;


        try {
        try {
            fr = new FileReader("/sys/fs/cgroup/uid_0/cgroup.freeze");
            fr = new FileReader(getFreezerCheckPath());
            char state = (char) fr.read();
            char state = (char) fr.read();


            if (state == '1' || state == '0') {
            if (state == '1' || state == '0') {
                supported = true;
                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 {
            } else {
                Slog.e(TAG_AM, "unexpected value in cgroup.freeze");
                Slog.e(TAG_AM, "unexpected value in cgroup.freeze");
            }
            }
+8 −1
Original line number Original line Diff line number Diff line
@@ -278,6 +278,11 @@ static jint com_android_server_am_CachedAppOptimizer_getBinderFreezeInfo(JNIEnv
    return retVal;
    return retVal;
}
}


static jstring com_android_server_am_CachedAppOptimizer_getFreezerCheckPath(JNIEnv* env,
                                                                            jobject clazz) {
    return env->NewStringUTF(CGROUP_FREEZE_PATH);
}

static const JNINativeMethod sMethods[] = {
static const JNINativeMethod sMethods[] = {
        /* name, signature, funcPtr */
        /* name, signature, funcPtr */
        {"compactSystem", "()V", (void*)com_android_server_am_CachedAppOptimizer_compactSystem},
        {"compactSystem", "()V", (void*)com_android_server_am_CachedAppOptimizer_compactSystem},
@@ -286,7 +291,9 @@ static const JNINativeMethod sMethods[] = {
         (void*)com_android_server_am_CachedAppOptimizer_enableFreezerInternal},
         (void*)com_android_server_am_CachedAppOptimizer_enableFreezerInternal},
        {"freezeBinder", "(IZ)V", (void*)com_android_server_am_CachedAppOptimizer_freezeBinder},
        {"freezeBinder", "(IZ)V", (void*)com_android_server_am_CachedAppOptimizer_freezeBinder},
        {"getBinderFreezeInfo", "(I)I",
        {"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)
int register_android_server_am_CachedAppOptimizer(JNIEnv* env)
{
{