diff --git a/core/java/android/service/autofill/IInlineSuggestionRenderService.aidl b/core/java/android/service/autofill/IInlineSuggestionRenderService.aidl index dd434b440af4e..bf0bb9e2a41f5 100644 --- a/core/java/android/service/autofill/IInlineSuggestionRenderService.aidl +++ b/core/java/android/service/autofill/IInlineSuggestionRenderService.aidl @@ -17,6 +17,7 @@ package android.service.autofill; import android.os.IBinder; +import android.os.RemoteCallback; import android.service.autofill.IInlineSuggestionUiCallback; import android.service.autofill.InlinePresentation; @@ -29,4 +30,5 @@ oneway interface IInlineSuggestionRenderService { void renderSuggestion(in IInlineSuggestionUiCallback callback, in InlinePresentation presentation, int width, int height, in IBinder hostInputToken, int displayId); + void getInlineSuggestionsRendererInfo(in RemoteCallback callback); } diff --git a/core/java/android/service/autofill/InlineSuggestionRenderService.java b/core/java/android/service/autofill/InlineSuggestionRenderService.java index cba6608db1b82..e3ed21ff556d7 100644 --- a/core/java/android/service/autofill/InlineSuggestionRenderService.java +++ b/core/java/android/service/autofill/InlineSuggestionRenderService.java @@ -30,6 +30,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Looper; +import android.os.RemoteCallback; import android.os.RemoteException; import android.util.Log; import android.view.Display; @@ -128,6 +129,11 @@ public abstract class InlineSuggestionRenderService extends Service { } } + private void handleGetInlineSuggestionsRendererInfo(@NonNull RemoteCallback callback) { + final Bundle rendererInfo = onGetInlineSuggestionsRendererInfo(); + callback.sendResult(rendererInfo); + } + private void sendResult(@NonNull IInlineSuggestionUiCallback callback, @Nullable SurfaceControlViewHost.SurfacePackage surface) { try { @@ -151,6 +157,13 @@ public abstract class InlineSuggestionRenderService extends Service { InlineSuggestionRenderService.this, callback, presentation, width, height, hostInputToken, displayId)); } + + @Override + public void getInlineSuggestionsRendererInfo(@NonNull RemoteCallback callback) { + mHandler.sendMessage(obtainMessage( + InlineSuggestionRenderService::handleGetInlineSuggestionsRendererInfo, + InlineSuggestionRenderService.this, callback)); + } }.asBinder(); } diff --git a/services/autofill/java/com/android/server/autofill/RemoteInlineSuggestionRenderService.java b/services/autofill/java/com/android/server/autofill/RemoteInlineSuggestionRenderService.java index 7ad5632dd70e5..347174c4c8042 100644 --- a/services/autofill/java/com/android/server/autofill/RemoteInlineSuggestionRenderService.java +++ b/services/autofill/java/com/android/server/autofill/RemoteInlineSuggestionRenderService.java @@ -27,7 +27,9 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; +import android.os.Bundle; import android.os.IBinder; +import android.os.RemoteCallback; import android.service.autofill.IInlineSuggestionRenderService; import android.service.autofill.IInlineSuggestionUiCallback; import android.service.autofill.InlinePresentation; @@ -91,6 +93,15 @@ public final class RemoteInlineSuggestionRenderService extends hostInputToken, displayId)); } + /** + * Gets the inline suggestions renderer info as a {@link Bundle}. + */ + public void getInlineSuggestionsRendererInfo(@NonNull RemoteCallback callback) { + scheduleAsyncRequest((s) -> s.getInlineSuggestionsRendererInfo(new RemoteCallback( + (bundle) -> callback.sendResult(bundle) + ))); + } + @Nullable private static ServiceInfo getServiceInfo(Context context, int userId) { final String packageName = diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java index 4ecffd8d29b03..53cc1ed580095 100644 --- a/services/autofill/java/com/android/server/autofill/Session.java +++ b/services/autofill/java/com/android/server/autofill/Session.java @@ -652,10 +652,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState return mService.isInlineSuggestionsEnabled(); } - private boolean isInlineSuggestionRenderServiceAvailable() { - return mService.getRemoteInlineSuggestionRenderServiceLocked() != null; - } - /** * Clears the existing response for the partition, reads a new structure, and then requests a * new fill response from the fill service. @@ -715,14 +711,18 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState // Only ask IME to create inline suggestions request if Autofill provider supports it and // the render service is available. - if (isInlineSuggestionsEnabledByAutofillProviderLocked() - && isInlineSuggestionRenderServiceAvailable()) { + final RemoteInlineSuggestionRenderService remoteRenderService = + mService.getRemoteInlineSuggestionRenderServiceLocked(); + if (isInlineSuggestionsEnabledByAutofillProviderLocked() && remoteRenderService != null) { Consumer inlineSuggestionsRequestConsumer = mAssistReceiver.newAutofillRequestLocked(/*isInlineRequest=*/ true); if (inlineSuggestionsRequestConsumer != null) { - // TODO(b/146454892): pipe the uiExtras from the ExtServices. - mInlineSessionController.onCreateInlineSuggestionsRequestLocked(mCurrentViewId, - inlineSuggestionsRequestConsumer, Bundle.EMPTY); + remoteRenderService.getInlineSuggestionsRendererInfo( + new RemoteCallback((extras) -> { + mInlineSessionController.onCreateInlineSuggestionsRequestLocked( + mCurrentViewId, inlineSuggestionsRequestConsumer, extras); + } + )); } } else { mAssistReceiver.newAutofillRequestLocked(/*isInlineRequest=*/ false); @@ -3128,13 +3128,18 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState // 1. the field is augmented autofill only (when standard autofill provider is None or // when it returns null response) // 2. standard autofill provider doesn't support inline suggestion - if (isInlineSuggestionRenderServiceAvailable() + final RemoteInlineSuggestionRenderService remoteRenderService = + mService.getRemoteInlineSuggestionRenderServiceLocked(); + if (remoteRenderService != null && (mForAugmentedAutofillOnly || !isInlineSuggestionsEnabledByAutofillProviderLocked())) { if (sDebug) Slog.d(TAG, "Create inline request for augmented autofill"); - // TODO(b/146454892): pipe the uiExtras from the ExtServices. - mInlineSessionController.onCreateInlineSuggestionsRequestLocked(mCurrentViewId, - /*requestConsumer=*/ requestAugmentedAutofill, Bundle.EMPTY); + remoteRenderService.getInlineSuggestionsRendererInfo(new RemoteCallback( + (extras) -> { + mInlineSessionController.onCreateInlineSuggestionsRequestLocked( + mCurrentViewId, /*requestConsumer=*/ requestAugmentedAutofill, + extras); + }, mHandler)); } else { requestAugmentedAutofill.accept( mInlineSessionController.getInlineSuggestionsRequestLocked().orElse(null));