Merge "Pass inline suggestions renderer info Bundle to Frameworks and IME" into rvc-dev am: c0404ff5e5 am: f0694ae747
Change-Id: I299376ee614f0924a3f84e85c8770e036e006d45
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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<InlineSuggestionsRequest> 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);
|
||||
@@ -3130,13 +3130,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));
|
||||
|
||||
Reference in New Issue
Block a user