Merge "Pass inline suggestions renderer info Bundle to Frameworks and IME" into rvc-dev am: c0404ff5e5 am: f0694ae747 am: bceeeb4e5b

Change-Id: I32145d1d24ba5edd7cd3341a8e3ce5e769c88d7b
This commit is contained in:
TreeHugger Robot
2020-04-10 03:24:47 +00:00
committed by Automerger Merge Worker
4 changed files with 44 additions and 13 deletions

View File

@@ -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);
}

View File

@@ -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();
}

View File

@@ -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 =

View File

@@ -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));