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
Change-Id: I610014c6bc709796e9d4f7aeadf64e5107f37de3
This commit is contained in:
Patrick Williams
2023-04-21 16:32:56 -05:00
parent 029eb856a3
commit 705aed888b

View File

@@ -961,12 +961,20 @@ public final class ViewRootImpl implements ViewParent,
}
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);
}
}
};