Loading core/java/android/app/UiAutomation.java +16 −8 Original line number Diff line number Diff line Loading @@ -1647,10 +1647,13 @@ public final class UiAutomation { // Calling out without a lock held. mUiAutomationConnection.executeShellCommand(command, sink, null); } catch (IOException ioe) { Log.e(LOG_TAG, "Error executing shell command!", ioe); } catch (RemoteException re) { Log.e(LOG_TAG, "Error executing shell command!", re); } catch (IOException | RemoteException e) { Log.e(LOG_TAG, "Error executing shell command!", e); } catch (IllegalArgumentException | NullPointerException | SecurityException e) { // An exception of these types is propagated from the server. // Rethrow it to keep the old behavior. To avoid FD leak, close the source. IoUtils.closeQuietly(source); throw e; } finally { IoUtils.closeQuietly(sink); } Loading Loading @@ -1734,10 +1737,15 @@ public final class UiAutomation { // Calling out without a lock held. mUiAutomationConnection.executeShellCommandWithStderr( command, sink_read, source_write, stderr_sink_read); } catch (IOException ioe) { Log.e(LOG_TAG, "Error executing shell command!", ioe); } catch (RemoteException re) { Log.e(LOG_TAG, "Error executing shell command!", re); } catch (IOException | RemoteException e) { Log.e(LOG_TAG, "Error executing shell command!", e); } catch (IllegalArgumentException | SecurityException | NullPointerException e) { // An exception of these types is propagated from the server. // Rethrow it to keep the old behavior. To avoid FD leaks, close the sources. IoUtils.closeQuietly(sink_write); IoUtils.closeQuietly(source_read); IoUtils.closeQuietly(stderr_source_read); throw e; } finally { IoUtils.closeQuietly(sink_read); IoUtils.closeQuietly(source_write); Loading core/java/android/app/UiAutomationConnection.java +15 −2 Original line number Diff line number Diff line Loading @@ -550,8 +550,21 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub { try { process = Runtime.getRuntime().exec(command); } catch (IOException exc) { throw new RuntimeException("Error running shell command '" + command + "'", exc); } catch (IOException ex) { // Make sure the passed FDs are closed. IoUtils.closeQuietly(sink); IoUtils.closeQuietly(source); IoUtils.closeQuietly(stderrSink); // No to need to wrap in RuntimeException. Only to keep the old behavior. // This is just logged and not propagated to the remote caller anyway. throw new RuntimeException("Error running shell command '" + command + "'", ex); } catch (IllegalArgumentException | NullPointerException | SecurityException ex) { // Make sure the passed FDs are closed. IoUtils.closeQuietly(sink); IoUtils.closeQuietly(source); IoUtils.closeQuietly(stderrSink); // Rethrow the exception. This will be propagated to the remote caller. throw ex; } // Read from process and write to pipe Loading Loading
core/java/android/app/UiAutomation.java +16 −8 Original line number Diff line number Diff line Loading @@ -1647,10 +1647,13 @@ public final class UiAutomation { // Calling out without a lock held. mUiAutomationConnection.executeShellCommand(command, sink, null); } catch (IOException ioe) { Log.e(LOG_TAG, "Error executing shell command!", ioe); } catch (RemoteException re) { Log.e(LOG_TAG, "Error executing shell command!", re); } catch (IOException | RemoteException e) { Log.e(LOG_TAG, "Error executing shell command!", e); } catch (IllegalArgumentException | NullPointerException | SecurityException e) { // An exception of these types is propagated from the server. // Rethrow it to keep the old behavior. To avoid FD leak, close the source. IoUtils.closeQuietly(source); throw e; } finally { IoUtils.closeQuietly(sink); } Loading Loading @@ -1734,10 +1737,15 @@ public final class UiAutomation { // Calling out without a lock held. mUiAutomationConnection.executeShellCommandWithStderr( command, sink_read, source_write, stderr_sink_read); } catch (IOException ioe) { Log.e(LOG_TAG, "Error executing shell command!", ioe); } catch (RemoteException re) { Log.e(LOG_TAG, "Error executing shell command!", re); } catch (IOException | RemoteException e) { Log.e(LOG_TAG, "Error executing shell command!", e); } catch (IllegalArgumentException | SecurityException | NullPointerException e) { // An exception of these types is propagated from the server. // Rethrow it to keep the old behavior. To avoid FD leaks, close the sources. IoUtils.closeQuietly(sink_write); IoUtils.closeQuietly(source_read); IoUtils.closeQuietly(stderr_source_read); throw e; } finally { IoUtils.closeQuietly(sink_read); IoUtils.closeQuietly(source_write); Loading
core/java/android/app/UiAutomationConnection.java +15 −2 Original line number Diff line number Diff line Loading @@ -550,8 +550,21 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub { try { process = Runtime.getRuntime().exec(command); } catch (IOException exc) { throw new RuntimeException("Error running shell command '" + command + "'", exc); } catch (IOException ex) { // Make sure the passed FDs are closed. IoUtils.closeQuietly(sink); IoUtils.closeQuietly(source); IoUtils.closeQuietly(stderrSink); // No to need to wrap in RuntimeException. Only to keep the old behavior. // This is just logged and not propagated to the remote caller anyway. throw new RuntimeException("Error running shell command '" + command + "'", ex); } catch (IllegalArgumentException | NullPointerException | SecurityException ex) { // Make sure the passed FDs are closed. IoUtils.closeQuietly(sink); IoUtils.closeQuietly(source); IoUtils.closeQuietly(stderrSink); // Rethrow the exception. This will be propagated to the remote caller. throw ex; } // Read from process and write to pipe Loading