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

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

Merge "Skip calling adpf session if it's null" into main

parents 1d5b180a 83d1eda1
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)