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

Commit 245f7d88 authored by Li Li's avatar Li Li Committed by Automerger Merge Worker
Browse files

Merge "Check if freezer cgroup configuration is valid" into udc-dev am: 8c9fd0d8

parents cd52bc91 8c9fd0d8
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -1014,6 +1014,12 @@ public final class CachedAppOptimizer {
     */
    private static native String getFreezerCheckPath();

    /**
     * Check if task_profiles.json includes valid freezer profiles and actions
     * @return false if there are invalid profiles or actions
     */
    private static native boolean isFreezerProfileValid();

    /**
     * Determines whether the freezer is supported by this system
     */
@@ -1031,16 +1037,19 @@ public final class CachedAppOptimizer {
                // Also check freezer binder ioctl
                Slog.d(TAG_AM, "Checking binder freezer ioctl");
                getBinderFreezeInfo(Process.myPid());
                supported = true;

                // Check if task_profiles.json contains invalid profiles
                Slog.d(TAG_AM, "Checking freezer profiles");
                supported = isFreezerProfileValid();
            } else {
                Slog.e(TAG_AM, "unexpected value in cgroup.freeze");
                Slog.e(TAG_AM, "Unexpected value in cgroup.freeze");
            }
        } catch (java.io.FileNotFoundException e) {
            Slog.w(TAG_AM, "cgroup.freeze not present");
            Slog.w(TAG_AM, "File cgroup.freeze not present");
        } catch (RuntimeException e) {
            Slog.w(TAG_AM, "unable to read freezer info");
            Slog.w(TAG_AM, "Unable to read freezer info");
        } catch (Exception e) {
            Slog.w(TAG_AM, "unable to read cgroup.freeze: " + e.toString());
            Slog.w(TAG_AM, "Unable to read cgroup.freeze: " + e.toString());
        }

        if (fr != null) {
+11 −1
Original line number Diff line number Diff line
@@ -561,6 +561,14 @@ static jstring com_android_server_am_CachedAppOptimizer_getFreezerCheckPath(JNIE
    return env->NewStringUTF(path.c_str());
}

static jboolean com_android_server_am_CachedAppOptimizer_isFreezerProfileValid(JNIEnv* env) {
    int uid = getuid();
    int pid = getpid();

    return isProfileValidForProcess("Frozen", uid, pid) &&
            isProfileValidForProcess("Unfrozen", uid, pid);
}

static const JNINativeMethod sMethods[] = {
        /* name, signature, funcPtr */
        {"cancelCompaction", "()V",
@@ -578,7 +586,9 @@ static const JNINativeMethod sMethods[] = {
        {"getBinderFreezeInfo", "(I)I",
         (void*)com_android_server_am_CachedAppOptimizer_getBinderFreezeInfo},
        {"getFreezerCheckPath", "()Ljava/lang/String;",
         (void*)com_android_server_am_CachedAppOptimizer_getFreezerCheckPath}};
         (void*)com_android_server_am_CachedAppOptimizer_getFreezerCheckPath},
        {"isFreezerProfileValid", "()Z",
         (void*)com_android_server_am_CachedAppOptimizer_isFreezerProfileValid}};

int register_android_server_am_CachedAppOptimizer(JNIEnv* env)
{