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

Commit 9d867076 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use PooledLambda.obtainMessage() when possible"

parents 09e24d7e e2fa39ec
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1541,7 +1541,7 @@ public final class ActivityThread extends ClientTransactionHandler {

        public void scheduleTrimMemory(int level) {
            final Runnable r = PooledLambda.obtainRunnable(ActivityThread::handleTrimMemory,
                    ActivityThread.this, level);
                    ActivityThread.this, level).recycleOnUse();
            // Schedule trimming memory after drawing the frame to minimize jank-risk.
            Choreographer choreographer = Choreographer.getMainThreadInstance();
            if (choreographer != null) {
+2 −3
Original line number Diff line number Diff line
@@ -1197,10 +1197,9 @@ public final class UiAutomation {
                    }
                    if (listener != null) {
                        // Calling out only without a lock held.
                        mLocalCallbackHandler.post(PooledLambda.obtainRunnable(
                        mLocalCallbackHandler.sendMessage(PooledLambda.obtainMessage(
                                OnAccessibilityEventListener::onAccessibilityEvent,
                                listener, AccessibilityEvent.obtain(event))
                                .recycleOnUse());
                                listener, AccessibilityEvent.obtain(event)));
                    }
                }

+2 −2
Original line number Diff line number Diff line
@@ -3188,10 +3188,10 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D

        // Kill the running processes. Post on handle since we don't want to hold the service lock
        // while calling into AM.
        final Runnable r = PooledLambda.obtainRunnable(
        final Message m = PooledLambda.obtainMessage(
                ActivityManagerInternal::killProcessesForRemovedTask, mService.mAmInternal,
                procsToKill);
        mService.mH.post(r);
        mService.mH.sendMessage(m);
    }

    /**
+2 −2
Original line number Diff line number Diff line
@@ -91,9 +91,9 @@ public class OomAdjProfiler {
                return;
            }
            mSystemServerCpuTimeUpdateScheduled = true;
            BackgroundThread.getHandler().post(PooledLambda.obtainRunnable(
            BackgroundThread.getHandler().sendMessage(PooledLambda.obtainMessage(
                    OomAdjProfiler::updateSystemServerCpuTime,
                    this, mOnBattery, mScreenOff).recycleOnUse());
                    this, mOnBattery, mScreenOff));
        }
    }

+13 −10
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.app.servertransaction.ConfigurationChangeItem;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.res.Configuration;
import android.os.Message;
import android.os.RemoteException;
import android.util.ArraySet;
import android.util.Log;
@@ -510,48 +511,50 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
    void clearProfilerIfNeeded() {
        if (mListener == null) return;
        // Posting on handler so WM lock isn't held when we call into AM.
        mAtm.mH.post(() -> mListener.clearProfilerIfNeeded());
        mAtm.mH.sendMessage(PooledLambda.obtainMessage(
                WindowProcessListener::clearProfilerIfNeeded, mListener));
    }

    void updateProcessInfo(boolean updateServiceConnectionActivities, boolean updateLru,
            boolean activityChange, boolean updateOomAdj) {
        if (mListener == null) return;
        // Posting on handler so WM lock isn't held when we call into AM.
        final Runnable r = PooledLambda.obtainRunnable(WindowProcessListener::updateProcessInfo,
        final Message m = PooledLambda.obtainMessage(WindowProcessListener::updateProcessInfo,
                mListener, updateServiceConnectionActivities, updateLru, activityChange,
                updateOomAdj);
        mAtm.mH.post(r);
        mAtm.mH.sendMessage(m);
    }

    void updateServiceConnectionActivities() {
        if (mListener == null) return;
        // Posting on handler so WM lock isn't held when we call into AM.
        mAtm.mH.post(() -> mListener.updateServiceConnectionActivities());
        mAtm.mH.sendMessage(PooledLambda.obtainMessage(
                WindowProcessListener::updateServiceConnectionActivities, mListener));
    }

    void setPendingUiClean(boolean pendingUiClean) {
        if (mListener == null) return;
        // Posting on handler so WM lock isn't held when we call into AM.
        final Runnable r = PooledLambda.obtainRunnable(
        final Message m = PooledLambda.obtainMessage(
                WindowProcessListener::setPendingUiClean, mListener, pendingUiClean);
        mAtm.mH.post(r);
        mAtm.mH.sendMessage(m);
    }

    void setPendingUiCleanAndForceProcessStateUpTo(int newState) {
        if (mListener == null) return;
        // Posting on handler so WM lock isn't held when we call into AM.
        final Runnable r = PooledLambda.obtainRunnable(
        final Message m = PooledLambda.obtainMessage(
                WindowProcessListener::setPendingUiCleanAndForceProcessStateUpTo,
                mListener, newState);
        mAtm.mH.post(r);
        mAtm.mH.sendMessage(m);
    }

    void setRemoved(boolean removed) {
        if (mListener == null) return;
        // Posting on handler so WM lock isn't held when we call into AM.
        final Runnable r = PooledLambda.obtainRunnable(
        final Message m = PooledLambda.obtainMessage(
                WindowProcessListener::setRemoved, mListener, removed);
        mAtm.mH.post(r);
        mAtm.mH.sendMessage(m);
    }

    @Override