commit | 1425f884954d8f024051c1572efe9bcd40f80c04 | [log] [tgz] |
---|---|---|
author | Patrick Williams <pdwilliams@google.com> | Fri Apr 21 16:32:56 2023 -0500 |
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Tue May 02 03:59:13 2023 +0000 |
tree | 5906b208c987f96337c95619d788cf893ea6c7cf | |
parent | ee7f3be81e2a4707c1299ac3ffc0b1f64146c3ef [diff] |
Clear calling identity in TransactionHangCallback This ensures the ActivityManagerService is called with the correct pid. Bug: 278526360 Test: manually tested that the correct PID is sent to ActivityManager (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:705aed888b5a783d2a1f9f0392e9863afe309bdd) Merged-In: I610014c6bc709796e9d4f7aeadf64e5107f37de3 Change-Id: I610014c6bc709796e9d4f7aeadf64e5107f37de3
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index c0ac04c..8f20e2d 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java
@@ -961,12 +961,20 @@ } sAnrReported = true; + // If we're making an in-process call to ActivityManagerService + // and the previous binder call on this thread was oneway, the + // calling PID will be 0. Clearing the calling identity fixes + // this and ensures ActivityManager gets the correct calling + // pid. + final long identityToken = Binder.clearCallingIdentity(); try { ActivityManager.getService().appNotResponding(reason); } catch (RemoteException e) { // We asked the system to crash us, but the system // already crashed. Unfortunately things may be // out of control. + } finally { + Binder.restoreCallingIdentity(identityToken); } } };