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

Commit 83d1eda1 authored by Winson Chung's avatar Winson Chung
Browse files

Skip calling adpf session if it's null

Bug: 381899878
Flag: EXEMPT bugfix
Test: Presubmit
Change-Id: I536348afcb412d93c8a527ea9490b8cc35609a69
parent 09eda254
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -163,7 +163,6 @@ public class SystemPerformanceHinter {
    // The active sessions
    private final ArrayList<HighPerfSession> mActiveSessions = new ArrayList<>();
    private final SurfaceControl.Transaction mTransaction;
    private final PerformanceHintManager mPerfHintManager;
    private @Nullable PerformanceHintManager.Session mAdpfSession;
    private @Nullable DisplayRootProvider mDisplayRootProvider;

@@ -184,7 +183,6 @@ public class SystemPerformanceHinter {
            @Nullable DisplayRootProvider displayRootProvider,
            @Nullable Supplier<SurfaceControl.Transaction> transactionSupplier) {
        mDisplayRootProvider = displayRootProvider;
        mPerfHintManager = context.getSystemService(PerformanceHintManager.class);
        mTransaction = transactionSupplier != null
                ? transactionSupplier.get()
                : new SurfaceControl.Transaction();
@@ -273,7 +271,7 @@ public class SystemPerformanceHinter {
                asyncTraceBegin(HINT_SF_EARLY_WAKEUP, Display.INVALID_DISPLAY);
            }
        }
        if (nowEnabled(oldGlobalFlags, newGlobalFlags, HINT_ADPF)) {
        if (mAdpfSession != null && nowEnabled(oldGlobalFlags, newGlobalFlags, HINT_ADPF)) {
            mAdpfSession.sendHint(PerformanceHintManager.Session.CPU_LOAD_UP);
            if (isTraceEnabled) {
                asyncTraceBegin(HINT_ADPF, Display.INVALID_DISPLAY);
@@ -323,7 +321,7 @@ public class SystemPerformanceHinter {
                asyncTraceEnd(HINT_SF_EARLY_WAKEUP);
            }
        }
        if (nowDisabled(oldGlobalFlags, newGlobalFlags, HINT_ADPF)) {
        if (mAdpfSession != null && nowDisabled(oldGlobalFlags, newGlobalFlags, HINT_ADPF)) {
            mAdpfSession.sendHint(PerformanceHintManager.Session.CPU_LOAD_RESET);
            if (isTraceEnabled) {
                asyncTraceEnd(HINT_ADPF);
+9 −3
Original line number Diff line number Diff line
@@ -45,10 +45,16 @@ class PerfHintController(private val mContext: Context,
    private fun onInit() {
        mShellCommandHandler.addDumpCallback(this::dump, this)
        val perfHintMgr = mContext.getSystemService(PerformanceHintManager::class.java)
        val adpfSession = perfHintMgr!!.createHintSession(intArrayOf(Process.myTid()),
                TimeUnit.SECONDS.toNanos(1))
        if (perfHintMgr != null) {
            val adpfSession = perfHintMgr.createHintSession(
                intArrayOf(Process.myTid()),
                TimeUnit.SECONDS.toNanos(1)
            )
            if (adpfSession != null) {
                hinter.setAdpfSession(adpfSession)
            }
        }
    }

    fun dump(pw: PrintWriter, prefix: String?) {
        hinter.dump(pw, prefix)