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

Skip to content
Commit 4e4c89a1 authored by Jooyung Han's avatar Jooyung Han
Browse files

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
parent e84fdcef
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment