Fix UIAutomation.executeShellCommand()
UIAutomation.executeShellCommand() creates pipe()'ed FDs and transfers ownership to the service and the caller. So, UIAutomationConnection needs to close the passed sink FD and the caller of UIAutomation.executeShellCommand() should close the returned source FD. However, when Runtime.exec() throws an exception FDs are not properly closed. There are two types of exceptions it can throw: a) one that is propagated the caller, and b) the other that is missing in the middle. The server side doesn't close the sink FD in both cases. The caller side behaves differently: For a), UIAutomation.executeShellCommand() throws the exception and the source FD is lost without closing. For b), UIAutomation.executeShellCommand() returns the source FD, but since the other end of this FD isn't closed in the server, the caller's read() hangs. This change fixes: - UIAutomationConnection.executeShellCommand() method closes FDs on exception. - UIAutomation.executeShellCommand() method closes FDs on exception. Bug: 349038571 Test: UiAutomationShellTest Change-Id: Id46a42cbe7fe330627e31389595562af79301a84
Loading
Please register or sign in to comment