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

Commit 3a9b8aef authored by Li Li's avatar Li Li
Browse files

Freezer: check freeze binder ioctl

Some old kernels don't have the necessary binder ioctls for freezer
(BINDER_FREEZE & BINDER_GET_FROZEN_INFO). In such a case, disable
freezer with a warning log.

Bug: 199803449
Test: confirm freezer is enabled/disabled on new/old kernels
Change-Id: I9e19515746d4c415dc5eb871e2d3e232c0876a15
parent b7c776aa
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -645,21 +645,25 @@ public final class CachedAppOptimizer {
            char state = (char) fr.read();

            if (state == '1' || state == '0') {
                // Also check freezer binder ioctl
                getBinderFreezeInfo(Process.myPid());
                supported = true;
            } else {
                Slog.e(TAG_AM, "unexpected value in cgroup.freeze");
            }
        } catch (java.io.FileNotFoundException e) {
            Slog.d(TAG_AM, "cgroup.freeze not present");
            Slog.w(TAG_AM, "cgroup.freeze not present");
        } catch (RuntimeException e) {
            Slog.w(TAG_AM, "unable to read freezer info");
        } catch (Exception e) {
            Slog.d(TAG_AM, "unable to read cgroup.freeze: " + e.toString());
            Slog.w(TAG_AM, "unable to read cgroup.freeze: " + e.toString());
        }

        if (fr != null) {
            try {
                fr.close();
            } catch (java.io.IOException e) {
                Slog.e(TAG_AM, "Exception closing freezer.killable: " + e.toString());
                Slog.e(TAG_AM, "Exception closing cgroup.freeze: " + e.toString());
            }
        }