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

Commit 180f91f1 authored by Olivier Gaillard's avatar Olivier Gaillard
Browse files

Wraps #exectTransact to set/restore worksource.

Test: atest binderLibTest BinderWorkSourceTest BinderCallsStatsServiceTest
Change-Id: I334c4569706851925d95bd22931815572907b9a5
parent b44f5026
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -912,6 +912,16 @@ public class Binder implements IBinder {
    // Entry point from android_util_Binder.cpp's onTransact
    private boolean execTransact(int code, long dataObj, long replyObj,
            int flags) {
        final long origWorkSource = ThreadLocalWorkSource.setUid(Binder.getCallingUid());
        try {
            return execTransactInternal(code, dataObj, replyObj, flags);
        } finally {
            ThreadLocalWorkSource.restore(origWorkSource);
        }
    }

    private boolean execTransactInternal(int code, long dataObj, long replyObj,
            int flags) {
        // Make sure the observer won't change while processing a transaction.
        final BinderInternal.Observer observer = sObserver;
        final CallSession callSession =
@@ -925,7 +935,6 @@ public class Binder implements IBinder {
        // Log any exceptions as warnings, don't silently suppress them.
        // If the call was FLAG_ONEWAY then these exceptions disappear into the ether.
        final boolean tracingEnabled = Binder.isTracingEnabled();
        final long origWorkSource = ThreadLocalWorkSource.setUid(Binder.getCallingUid());
        try {
            if (tracingEnabled) {
                final String transactionName = getTransactionName(code);
@@ -952,7 +961,6 @@ public class Binder implements IBinder {
            }
            res = true;
        } finally {
            ThreadLocalWorkSource.restore(origWorkSource);
            if (tracingEnabled) {
                Trace.traceEnd(Trace.TRACE_TAG_ALWAYS);
            }