diff --git a/core/java/com/android/internal/inputmethod/RemoteInputConnectionImpl.java b/core/java/com/android/internal/inputmethod/RemoteInputConnectionImpl.java index 74211fb974df2..fc299febef3ed 100644 --- a/core/java/com/android/internal/inputmethod/RemoteInputConnectionImpl.java +++ b/core/java/com/android/internal/inputmethod/RemoteInputConnectionImpl.java @@ -752,6 +752,15 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { private void dispatch(@NonNull AndroidFuture untypedFuture, @NonNull Supplier supplier) { @SuppressWarnings("unchecked") final AndroidFuture future = untypedFuture; - dispatch(() -> future.complete(supplier.get())); + dispatch(() -> { + final T result; + try { + result = supplier.get(); + } catch (Throwable throwable) { + future.completeExceptionally(throwable); + throw throwable; + } + future.complete(result); + }); } }