Merge "Callback the surface package after the views are drawn locally" into rvc-dev am: cf5f65cbe3

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11607123

Change-Id: Iee502e3c891c4df6ae061eac5ebe6821a00c7c82
This commit is contained in:
TreeHugger Robot
2020-06-18 11:18:08 +00:00
committed by Automerger Merge Worker

View File

@@ -64,7 +64,7 @@ public abstract class InlineSuggestionRenderService extends Service {
public static final String SERVICE_INTERFACE = public static final String SERVICE_INTERFACE =
"android.service.autofill.InlineSuggestionRenderService"; "android.service.autofill.InlineSuggestionRenderService";
private final Handler mHandler = new Handler(Looper.getMainLooper(), null, true); private final Handler mMainHandler = new Handler(Looper.getMainLooper(), null, true);
private IInlineSuggestionUiCallback mCallback; private IInlineSuggestionUiCallback mCallback;
@@ -192,15 +192,22 @@ public abstract class InlineSuggestionRenderService extends Service {
} }
return true; return true;
}); });
final InlineSuggestionUiImpl uiImpl = new InlineSuggestionUiImpl(host, mMainHandler);
mActiveInlineSuggestions.put(uiImpl, true);
try { // We post the callback invocation to the end of the main thread handler queue, to make
InlineSuggestionUiImpl uiImpl = new InlineSuggestionUiImpl(host, mHandler); // sure the callback happens after the views are drawn. This is needed because calling
mActiveInlineSuggestions.put(uiImpl, true); // {@link SurfaceControlViewHost#setView()} will post a task to the main thread
callback.onContent(new InlineSuggestionUiWrapper(uiImpl), host.getSurfacePackage(), // to draw the view asynchronously.
measuredSize.getWidth(), measuredSize.getHeight()); mMainHandler.post(() -> {
} catch (RemoteException e) { try {
Log.w(TAG, "RemoteException calling onContent()"); callback.onContent(new InlineSuggestionUiWrapper(uiImpl),
} host.getSurfacePackage(),
measuredSize.getWidth(), measuredSize.getHeight());
} catch (RemoteException e) {
Log.w(TAG, "RemoteException calling onContent()");
}
});
} finally { } finally {
updateDisplay(Display.DEFAULT_DISPLAY); updateDisplay(Display.DEFAULT_DISPLAY);
} }
@@ -305,7 +312,7 @@ public abstract class InlineSuggestionRenderService extends Service {
public void renderSuggestion(@NonNull IInlineSuggestionUiCallback callback, public void renderSuggestion(@NonNull IInlineSuggestionUiCallback callback,
@NonNull InlinePresentation presentation, int width, int height, @NonNull InlinePresentation presentation, int width, int height,
@Nullable IBinder hostInputToken, int displayId) { @Nullable IBinder hostInputToken, int displayId) {
mHandler.sendMessage( mMainHandler.sendMessage(
obtainMessage(InlineSuggestionRenderService::handleRenderSuggestion, obtainMessage(InlineSuggestionRenderService::handleRenderSuggestion,
InlineSuggestionRenderService.this, callback, presentation, InlineSuggestionRenderService.this, callback, presentation,
width, height, hostInputToken, displayId)); width, height, hostInputToken, displayId));
@@ -313,7 +320,7 @@ public abstract class InlineSuggestionRenderService extends Service {
@Override @Override
public void getInlineSuggestionsRendererInfo(@NonNull RemoteCallback callback) { public void getInlineSuggestionsRendererInfo(@NonNull RemoteCallback callback) {
mHandler.sendMessage(obtainMessage( mMainHandler.sendMessage(obtainMessage(
InlineSuggestionRenderService::handleGetInlineSuggestionsRendererInfo, InlineSuggestionRenderService::handleGetInlineSuggestionsRendererInfo,
InlineSuggestionRenderService.this, callback)); InlineSuggestionRenderService.this, callback));
} }