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 Original line Diff line number Diff line
@@ -163,7 +163,6 @@ public class SystemPerformanceHinter {
    // The active sessions
    // The active sessions
    private final ArrayList<HighPerfSession> mActiveSessions = new ArrayList<>();
    private final ArrayList<HighPerfSession> mActiveSessions = new ArrayList<>();
    private final SurfaceControl.Transaction mTransaction;
    private final SurfaceControl.Transaction mTransaction;
    private final PerformanceHintManager mPerfHintManager;
    private @Nullable PerformanceHintManager.Session mAdpfSession;
    private @Nullable PerformanceHintManager.Session mAdpfSession;
    private @Nullable DisplayRootProvider mDisplayRootProvider;
    private @Nullable DisplayRootProvider mDisplayRootProvider;


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


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