summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Olivier Gaillard <gaillard@google.com> 2018-12-05 15:30:35 +0000
committer Olivier Gaillard <gaillard@google.com> 2018-12-11 15:42:12 +0000
commit0e4d61ea1387f0d274edf99ac475d79444b29219 (patch)
tree63bab156c4cb7c771dd80c3446e69e8613d7124d
parentd4c0617bf4f1b1d6afdeca6cd0dae6e2b2a757bc (diff)
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
-rw-r--r--core/java/android/os/Binder.java8
-rw-r--r--core/java/com/android/internal/os/BinderInternal.java4
2 files changed, 5 insertions, 7 deletions
diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java
index 2ae796c1ec56..6adbad0c61e1 100644
--- a/core/java/android/os/Binder.java
+++ b/core/java/android/os/Binder.java
@@ -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;
}
}
diff --git a/core/java/com/android/internal/os/BinderInternal.java b/core/java/com/android/internal/os/BinderInternal.java
index 015506722c73..7eb944ce3fa2 100644
--- a/core/java/com/android/internal/os/BinderInternal.java
+++ b/core/java/com/android/internal/os/BinderInternal.java
@@ -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);