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

Commit 0e4d61ea authored by Olivier Gaillard's avatar Olivier Gaillard
Browse files

Make sure callEnded is always called.

Currently checkParcel might throw for instance although this is not
enabled by default.

Test: atest binderLibTest BinderWorkSourceTest BinderCallsStatsServiceTest
Change-Id: Ia836da7daa690dfa176d48cfe86ca4b7eb7cccc6
parent d4c0617b
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -971,10 +971,11 @@ public class Binder implements IBinder {
            if (tracingEnabled) {
                Trace.traceEnd(Trace.TRACE_TAG_ALWAYS);
            }
            if (observer != null) {
                observer.callEnded(callSession, data.dataSize(), reply.dataSize());
            }
        }
        checkParcel(this, code, reply, "Unreasonably large binder reply buffer");
        int replySizeBytes = reply.dataSize();
        int requestSizeBytes = data.dataSize();
        reply.recycle();
        data.recycle();

@@ -984,9 +985,6 @@ public class Binder implements IBinder {
        // to the main transaction loop to wait for another incoming transaction.  Either
        // way, strict mode begone!
        StrictMode.clearGatheredViolations();
        if (observer != null) {
            observer.callEnded(callSession, requestSizeBytes, replySizeBytes);
        }
        return res;
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.SystemClock;
import android.util.EventLog;
import android.util.Log;
import android.util.SparseIntArray;

import com.android.internal.util.Preconditions;
@@ -100,7 +99,8 @@ public class BinderInternal {
        /**
         * Called when a binder call stops.
         *
         * <li>This method will be called even when an exception is thrown.
         * <li>This method will be called even when an exception is thrown by the binder stub
         * implementation.
         */
        void callEnded(CallSession s, int parcelRequestSize, int parcelReplySize);