Merge "Release remove inline suggestion views when session destroyed" into rvc-dev am: 6e3a4d7625
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11972118 Change-Id: Iea1d860438282cc334f179f57eb9a8302500080e
This commit is contained in:
@@ -29,6 +29,12 @@ import android.service.autofill.InlinePresentation;
|
|||||||
oneway interface IInlineSuggestionRenderService {
|
oneway interface IInlineSuggestionRenderService {
|
||||||
void renderSuggestion(in IInlineSuggestionUiCallback callback,
|
void renderSuggestion(in IInlineSuggestionUiCallback callback,
|
||||||
in InlinePresentation presentation, int width, int height,
|
in InlinePresentation presentation, int width, int height,
|
||||||
in IBinder hostInputToken, int displayId);
|
in IBinder hostInputToken, int displayId, int userId, int sessionId);
|
||||||
void getInlineSuggestionsRendererInfo(in RemoteCallback callback);
|
void getInlineSuggestionsRendererInfo(in RemoteCallback callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Releases the inline suggestion SurfaceControlViewHosts hosted in the service, for the
|
||||||
|
* provided userId and sessionId.
|
||||||
|
*/
|
||||||
|
void destroySuggestionViews(int userId, int sessionId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
|
import java.io.FileDescriptor;
|
||||||
|
import java.io.PrintWriter;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,7 +84,7 @@ public abstract class InlineSuggestionRenderService extends Service {
|
|||||||
Boolean newValue) {
|
Boolean newValue) {
|
||||||
if (evicted) {
|
if (evicted) {
|
||||||
Log.w(TAG,
|
Log.w(TAG,
|
||||||
"Hit max=100 entries in the cache. Releasing oldest one to make "
|
"Hit max=30 entries in the cache. Releasing oldest one to make "
|
||||||
+ "space.");
|
+ "space.");
|
||||||
key.releaseSurfaceControlViewHost();
|
key.releaseSurfaceControlViewHost();
|
||||||
}
|
}
|
||||||
@@ -130,7 +132,7 @@ public abstract class InlineSuggestionRenderService extends Service {
|
|||||||
|
|
||||||
private void handleRenderSuggestion(IInlineSuggestionUiCallback callback,
|
private void handleRenderSuggestion(IInlineSuggestionUiCallback callback,
|
||||||
InlinePresentation presentation, int width, int height, IBinder hostInputToken,
|
InlinePresentation presentation, int width, int height, IBinder hostInputToken,
|
||||||
int displayId) {
|
int displayId, int userId, int sessionId) {
|
||||||
if (hostInputToken == null) {
|
if (hostInputToken == null) {
|
||||||
try {
|
try {
|
||||||
callback.onError();
|
callback.onError();
|
||||||
@@ -192,7 +194,8 @@ public abstract class InlineSuggestionRenderService extends Service {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
final InlineSuggestionUiImpl uiImpl = new InlineSuggestionUiImpl(host, mMainHandler);
|
final InlineSuggestionUiImpl uiImpl = new InlineSuggestionUiImpl(host, mMainHandler,
|
||||||
|
userId, sessionId);
|
||||||
mActiveInlineSuggestions.put(uiImpl, true);
|
mActiveInlineSuggestions.put(uiImpl, true);
|
||||||
|
|
||||||
// We post the callback invocation to the end of the main thread handler queue, to make
|
// We post the callback invocation to the end of the main thread handler queue, to make
|
||||||
@@ -218,6 +221,18 @@ public abstract class InlineSuggestionRenderService extends Service {
|
|||||||
callback.sendResult(rendererInfo);
|
callback.sendResult(rendererInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleDestroySuggestionViews(int userId, int sessionId) {
|
||||||
|
Log.v(TAG, "handleDestroySuggestionViews called for " + userId + ":" + sessionId);
|
||||||
|
for (final InlineSuggestionUiImpl inlineSuggestionUi :
|
||||||
|
mActiveInlineSuggestions.snapshot().keySet()) {
|
||||||
|
if (inlineSuggestionUi.mUserId == userId
|
||||||
|
&& inlineSuggestionUi.mSessionId == sessionId) {
|
||||||
|
Log.v(TAG, "Destroy " + inlineSuggestionUi);
|
||||||
|
inlineSuggestionUi.releaseSurfaceControlViewHost();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A wrapper class around the {@link InlineSuggestionUiImpl} to ensure it's not strongly
|
* A wrapper class around the {@link InlineSuggestionUiImpl} to ensure it's not strongly
|
||||||
* reference by the remote system server process.
|
* reference by the remote system server process.
|
||||||
@@ -260,10 +275,15 @@ public abstract class InlineSuggestionRenderService extends Service {
|
|||||||
private SurfaceControlViewHost mViewHost;
|
private SurfaceControlViewHost mViewHost;
|
||||||
@NonNull
|
@NonNull
|
||||||
private final Handler mHandler;
|
private final Handler mHandler;
|
||||||
|
private final int mUserId;
|
||||||
|
private final int mSessionId;
|
||||||
|
|
||||||
InlineSuggestionUiImpl(SurfaceControlViewHost viewHost, Handler handler) {
|
InlineSuggestionUiImpl(SurfaceControlViewHost viewHost, Handler handler, int userId,
|
||||||
|
int sessionId) {
|
||||||
this.mViewHost = viewHost;
|
this.mViewHost = viewHost;
|
||||||
this.mHandler = handler;
|
this.mHandler = handler;
|
||||||
|
this.mUserId = userId;
|
||||||
|
this.mSessionId = sessionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -302,6 +322,16 @@ public abstract class InlineSuggestionRenderService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
@Override
|
||||||
|
protected final void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw,
|
||||||
|
@NonNull String[] args) {
|
||||||
|
pw.println("mActiveInlineSuggestions: " + mActiveInlineSuggestions.size());
|
||||||
|
for (InlineSuggestionUiImpl impl : mActiveInlineSuggestions.snapshot().keySet()) {
|
||||||
|
pw.printf("ui: [%s] - [%d] [%d]\n", impl, impl.mUserId, impl.mSessionId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public final IBinder onBind(@NonNull Intent intent) {
|
public final IBinder onBind(@NonNull Intent intent) {
|
||||||
@@ -311,11 +341,12 @@ public abstract class InlineSuggestionRenderService extends Service {
|
|||||||
@Override
|
@Override
|
||||||
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, int userId,
|
||||||
|
int sessionId) {
|
||||||
mMainHandler.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, userId, sessionId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -324,6 +355,12 @@ public abstract class InlineSuggestionRenderService extends Service {
|
|||||||
InlineSuggestionRenderService::handleGetInlineSuggestionsRendererInfo,
|
InlineSuggestionRenderService::handleGetInlineSuggestionsRendererInfo,
|
||||||
InlineSuggestionRenderService.this, callback));
|
InlineSuggestionRenderService.this, callback));
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void destroySuggestionViews(int userId, int sessionId) {
|
||||||
|
mMainHandler.sendMessage(obtainMessage(
|
||||||
|
InlineSuggestionRenderService::handleDestroySuggestionViews,
|
||||||
|
InlineSuggestionRenderService.this, userId, sessionId));
|
||||||
|
}
|
||||||
}.asBinder();
|
}.asBinder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ final class RemoteAugmentedAutofillService
|
|||||||
@Nullable InlineSuggestionsRequest inlineSuggestionsRequest,
|
@Nullable InlineSuggestionsRequest inlineSuggestionsRequest,
|
||||||
@Nullable Function<InlineFillUi, Boolean> inlineSuggestionsCallback,
|
@Nullable Function<InlineFillUi, Boolean> inlineSuggestionsCallback,
|
||||||
@NonNull Runnable onErrorCallback,
|
@NonNull Runnable onErrorCallback,
|
||||||
@Nullable RemoteInlineSuggestionRenderService remoteRenderService) {
|
@Nullable RemoteInlineSuggestionRenderService remoteRenderService, int userId) {
|
||||||
long requestTime = SystemClock.elapsedRealtime();
|
long requestTime = SystemClock.elapsedRealtime();
|
||||||
AtomicReference<ICancellationSignal> cancellationRef = new AtomicReference<>();
|
AtomicReference<ICancellationSignal> cancellationRef = new AtomicReference<>();
|
||||||
|
|
||||||
@@ -173,7 +173,7 @@ final class RemoteAugmentedAutofillService
|
|||||||
inlineSuggestionsRequest, inlineSuggestionsData,
|
inlineSuggestionsRequest, inlineSuggestionsData,
|
||||||
clientState, focusedId, focusedValue,
|
clientState, focusedId, focusedValue,
|
||||||
inlineSuggestionsCallback,
|
inlineSuggestionsCallback,
|
||||||
client, onErrorCallback, remoteRenderService);
|
client, onErrorCallback, remoteRenderService, userId);
|
||||||
if (!showingFillWindow) {
|
if (!showingFillWindow) {
|
||||||
requestAutofill.complete(null);
|
requestAutofill.complete(null);
|
||||||
}
|
}
|
||||||
@@ -243,7 +243,8 @@ final class RemoteAugmentedAutofillService
|
|||||||
@NonNull AutofillId focusedId, @Nullable AutofillValue focusedValue,
|
@NonNull AutofillId focusedId, @Nullable AutofillValue focusedValue,
|
||||||
@Nullable Function<InlineFillUi, Boolean> inlineSuggestionsCallback,
|
@Nullable Function<InlineFillUi, Boolean> inlineSuggestionsCallback,
|
||||||
@NonNull IAutoFillManagerClient client, @NonNull Runnable onErrorCallback,
|
@NonNull IAutoFillManagerClient client, @NonNull Runnable onErrorCallback,
|
||||||
@Nullable RemoteInlineSuggestionRenderService remoteRenderService) {
|
@Nullable RemoteInlineSuggestionRenderService remoteRenderService,
|
||||||
|
int userId) {
|
||||||
if (inlineSuggestionsData == null || inlineSuggestionsData.isEmpty()
|
if (inlineSuggestionsData == null || inlineSuggestionsData.isEmpty()
|
||||||
|| inlineSuggestionsCallback == null || request == null
|
|| inlineSuggestionsCallback == null || request == null
|
||||||
|| remoteRenderService == null) {
|
|| remoteRenderService == null) {
|
||||||
@@ -312,7 +313,7 @@ final class RemoteAugmentedAutofillService
|
|||||||
Slog.w(TAG, "RemoteException starting intent sender");
|
Slog.w(TAG, "RemoteException starting intent sender");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, onErrorCallback, remoteRenderService);
|
}, onErrorCallback, remoteRenderService, userId, sessionId);
|
||||||
|
|
||||||
if (inlineSuggestionsCallback.apply(inlineFillUi)) {
|
if (inlineSuggestionsCallback.apply(inlineFillUi)) {
|
||||||
mCallbacks.logAugmentedAutofillShown(sessionId, clientState);
|
mCallbacks.logAugmentedAutofillShown(sessionId, clientState);
|
||||||
|
|||||||
@@ -88,9 +88,9 @@ public final class RemoteInlineSuggestionRenderService extends
|
|||||||
*/
|
*/
|
||||||
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, int userId, int sessionId) {
|
||||||
scheduleAsyncRequest((s) -> s.renderSuggestion(callback, presentation, width, height,
|
scheduleAsyncRequest((s) -> s.renderSuggestion(callback, presentation, width, height,
|
||||||
hostInputToken, displayId));
|
hostInputToken, displayId, userId, sessionId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,6 +100,13 @@ public final class RemoteInlineSuggestionRenderService extends
|
|||||||
scheduleAsyncRequest((s) -> s.getInlineSuggestionsRendererInfo(callback));
|
scheduleAsyncRequest((s) -> s.getInlineSuggestionsRendererInfo(callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroys the remote inline suggestion views associated with the given user id and session id.
|
||||||
|
*/
|
||||||
|
public void destroySuggestionViews(int userId, int sessionId) {
|
||||||
|
scheduleAsyncRequest((s) -> s.destroySuggestionViews(userId, sessionId));
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static ServiceInfo getServiceInfo(Context context, int userId) {
|
private static ServiceInfo getServiceInfo(Context context, int userId) {
|
||||||
final String packageName =
|
final String packageName =
|
||||||
|
|||||||
@@ -155,6 +155,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
*/
|
*/
|
||||||
public final int id;
|
public final int id;
|
||||||
|
|
||||||
|
/** userId the session belongs to */
|
||||||
|
public final int userId;
|
||||||
|
|
||||||
/** uid the session is for */
|
/** uid the session is for */
|
||||||
public final int uid;
|
public final int uid;
|
||||||
|
|
||||||
@@ -823,6 +826,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
}
|
}
|
||||||
id = sessionId;
|
id = sessionId;
|
||||||
mFlags = flags;
|
mFlags = flags;
|
||||||
|
this.userId = userId;
|
||||||
this.taskId = taskId;
|
this.taskId = taskId;
|
||||||
this.uid = uid;
|
this.uid = uid;
|
||||||
mStartTime = SystemClock.elapsedRealtime();
|
mStartTime = SystemClock.elapsedRealtime();
|
||||||
@@ -2986,7 +2990,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
mInlineSessionController.setInlineFillUiLocked(
|
mInlineSessionController.setInlineFillUiLocked(
|
||||||
InlineFillUi.emptyUi(focusedId));
|
InlineFillUi.emptyUi(focusedId));
|
||||||
}
|
}
|
||||||
}, remoteRenderService);
|
}, remoteRenderService, userId, id);
|
||||||
return mInlineSessionController.setInlineFillUiLocked(inlineFillUi);
|
return mInlineSessionController.setInlineFillUiLocked(inlineFillUi);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3296,7 +3300,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
mInlineSessionController.setInlineFillUiLocked(
|
mInlineSessionController.setInlineFillUiLocked(
|
||||||
InlineFillUi.emptyUi(mCurrentViewId));
|
InlineFillUi.emptyUi(mCurrentViewId));
|
||||||
}
|
}
|
||||||
}, mService.getRemoteInlineSuggestionRenderServiceLocked());
|
}, mService.getRemoteInlineSuggestionRenderServiceLocked(), userId);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -3796,6 +3800,12 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
if (mCurrentViewId != null) {
|
if (mCurrentViewId != null) {
|
||||||
mInlineSessionController.destroyLocked(mCurrentViewId);
|
mInlineSessionController.destroyLocked(mCurrentViewId);
|
||||||
}
|
}
|
||||||
|
final RemoteInlineSuggestionRenderService remoteRenderService =
|
||||||
|
mService.getRemoteInlineSuggestionRenderServiceLocked();
|
||||||
|
if (remoteRenderService != null) {
|
||||||
|
remoteRenderService.destroySuggestionViews(userId, id);
|
||||||
|
}
|
||||||
|
|
||||||
mDestroyed = true;
|
mDestroyed = true;
|
||||||
|
|
||||||
// Log metrics
|
// Log metrics
|
||||||
|
|||||||
@@ -105,19 +105,20 @@ public final class InlineFillUi {
|
|||||||
@NonNull AutofillId focusedViewId, @Nullable String filterText,
|
@NonNull AutofillId focusedViewId, @Nullable String filterText,
|
||||||
@NonNull AutoFillUI.AutoFillUiCallback uiCallback,
|
@NonNull AutoFillUI.AutoFillUiCallback uiCallback,
|
||||||
@NonNull Runnable onErrorCallback,
|
@NonNull Runnable onErrorCallback,
|
||||||
@Nullable RemoteInlineSuggestionRenderService remoteRenderService) {
|
@Nullable RemoteInlineSuggestionRenderService remoteRenderService,
|
||||||
|
int userId, int sessionId) {
|
||||||
|
|
||||||
if (InlineSuggestionFactory.responseNeedAuthentication(response)) {
|
if (InlineSuggestionFactory.responseNeedAuthentication(response)) {
|
||||||
InlineSuggestion inlineAuthentication =
|
InlineSuggestion inlineAuthentication =
|
||||||
InlineSuggestionFactory.createInlineAuthentication(request, response,
|
InlineSuggestionFactory.createInlineAuthentication(request, response,
|
||||||
focusedViewId, uiCallback, onErrorCallback, remoteRenderService);
|
uiCallback, onErrorCallback, remoteRenderService, userId, sessionId);
|
||||||
return new InlineFillUi(focusedViewId, inlineAuthentication, filterText);
|
return new InlineFillUi(focusedViewId, inlineAuthentication, filterText);
|
||||||
} else if (response.getDatasets() != null) {
|
} else if (response.getDatasets() != null) {
|
||||||
SparseArray<Pair<Dataset, InlineSuggestion>> inlineSuggestions =
|
SparseArray<Pair<Dataset, InlineSuggestion>> inlineSuggestions =
|
||||||
InlineSuggestionFactory.createAutofillInlineSuggestions(request,
|
InlineSuggestionFactory.createAutofillInlineSuggestions(request,
|
||||||
response.getRequestId(),
|
response.getRequestId(),
|
||||||
response.getDatasets(), focusedViewId, uiCallback, onErrorCallback,
|
response.getDatasets(), focusedViewId, uiCallback, onErrorCallback,
|
||||||
remoteRenderService);
|
remoteRenderService, userId, sessionId);
|
||||||
return new InlineFillUi(focusedViewId, inlineSuggestions, filterText);
|
return new InlineFillUi(focusedViewId, inlineSuggestions, filterText);
|
||||||
}
|
}
|
||||||
return new InlineFillUi(focusedViewId, new SparseArray<>(), filterText);
|
return new InlineFillUi(focusedViewId, new SparseArray<>(), filterText);
|
||||||
@@ -132,11 +133,12 @@ public final class InlineFillUi {
|
|||||||
@NonNull AutofillId focusedViewId, @Nullable String filterText,
|
@NonNull AutofillId focusedViewId, @Nullable String filterText,
|
||||||
@NonNull InlineSuggestionUiCallback uiCallback,
|
@NonNull InlineSuggestionUiCallback uiCallback,
|
||||||
@NonNull Runnable onErrorCallback,
|
@NonNull Runnable onErrorCallback,
|
||||||
@Nullable RemoteInlineSuggestionRenderService remoteRenderService) {
|
@Nullable RemoteInlineSuggestionRenderService remoteRenderService,
|
||||||
|
int userId, int sessionId) {
|
||||||
SparseArray<Pair<Dataset, InlineSuggestion>> inlineSuggestions =
|
SparseArray<Pair<Dataset, InlineSuggestion>> inlineSuggestions =
|
||||||
InlineSuggestionFactory.createAugmentedAutofillInlineSuggestions(request, datasets,
|
InlineSuggestionFactory.createAugmentedAutofillInlineSuggestions(request, datasets,
|
||||||
focusedViewId,
|
focusedViewId,
|
||||||
uiCallback, onErrorCallback, remoteRenderService);
|
uiCallback, onErrorCallback, remoteRenderService, userId, sessionId);
|
||||||
return new InlineFillUi(focusedViewId, inlineSuggestions, filterText);
|
return new InlineFillUi(focusedViewId, inlineSuggestions, filterText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,9 +53,9 @@ final class InlineSuggestionFactory {
|
|||||||
|
|
||||||
public static InlineSuggestion createInlineAuthentication(
|
public static InlineSuggestion createInlineAuthentication(
|
||||||
@NonNull InlineSuggestionsRequest request, @NonNull FillResponse response,
|
@NonNull InlineSuggestionsRequest request, @NonNull FillResponse response,
|
||||||
@NonNull AutofillId autofillId,
|
|
||||||
@NonNull AutoFillUI.AutoFillUiCallback client, @NonNull Runnable onErrorCallback,
|
@NonNull AutoFillUI.AutoFillUiCallback client, @NonNull Runnable onErrorCallback,
|
||||||
@Nullable RemoteInlineSuggestionRenderService remoteRenderService) {
|
@Nullable RemoteInlineSuggestionRenderService remoteRenderService, int userId,
|
||||||
|
int sessionId) {
|
||||||
final BiConsumer<Dataset, Integer> onClickFactory = (dataset, datasetIndex) -> {
|
final BiConsumer<Dataset, Integer> onClickFactory = (dataset, datasetIndex) -> {
|
||||||
client.authenticate(response.getRequestId(),
|
client.authenticate(response.getRequestId(),
|
||||||
datasetIndex, response.getAuthentication(), response.getClientState(),
|
datasetIndex, response.getAuthentication(), response.getClientState(),
|
||||||
@@ -66,7 +66,8 @@ final class InlineSuggestionFactory {
|
|||||||
InlinePresentation inlineAuthentication = response.getInlinePresentation();
|
InlinePresentation inlineAuthentication = response.getInlinePresentation();
|
||||||
return createInlineAuthSuggestion(
|
return createInlineAuthSuggestion(
|
||||||
mergedInlinePresentation(request, 0, inlineAuthentication),
|
mergedInlinePresentation(request, 0, inlineAuthentication),
|
||||||
remoteRenderService, onClickFactory, onErrorCallback, intentSenderConsumer,
|
remoteRenderService, userId, sessionId,
|
||||||
|
onClickFactory, onErrorCallback, intentSenderConsumer,
|
||||||
request.getHostInputToken(), request.getHostDisplayId());
|
request.getHostInputToken(), request.getHostDisplayId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +81,8 @@ final class InlineSuggestionFactory {
|
|||||||
@NonNull List<Dataset> datasets,
|
@NonNull List<Dataset> datasets,
|
||||||
@NonNull AutofillId autofillId,
|
@NonNull AutofillId autofillId,
|
||||||
@NonNull AutoFillUI.AutoFillUiCallback client, @NonNull Runnable onErrorCallback,
|
@NonNull AutoFillUI.AutoFillUiCallback client, @NonNull Runnable onErrorCallback,
|
||||||
@Nullable RemoteInlineSuggestionRenderService remoteRenderService) {
|
@Nullable RemoteInlineSuggestionRenderService remoteRenderService,
|
||||||
|
int userId, int sessionId) {
|
||||||
if (sDebug) Slog.d(TAG, "createInlineSuggestionsResponse called");
|
if (sDebug) Slog.d(TAG, "createInlineSuggestionsResponse called");
|
||||||
final Consumer<IntentSender> intentSenderConsumer = (intentSender) ->
|
final Consumer<IntentSender> intentSenderConsumer = (intentSender) ->
|
||||||
client.startIntentSender(intentSender, new Intent());
|
client.startIntentSender(intentSender, new Intent());
|
||||||
@@ -90,7 +92,8 @@ final class InlineSuggestionFactory {
|
|||||||
|
|
||||||
return createInlineSuggestionsInternal(/* isAugmented= */ false, request,
|
return createInlineSuggestionsInternal(/* isAugmented= */ false, request,
|
||||||
datasets, autofillId,
|
datasets, autofillId,
|
||||||
onErrorCallback, onClickFactory, intentSenderConsumer, remoteRenderService);
|
onErrorCallback, onClickFactory, intentSenderConsumer, remoteRenderService, userId,
|
||||||
|
sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,7 +107,8 @@ final class InlineSuggestionFactory {
|
|||||||
@NonNull AutofillId autofillId,
|
@NonNull AutofillId autofillId,
|
||||||
@NonNull InlineFillUi.InlineSuggestionUiCallback inlineSuggestionUiCallback,
|
@NonNull InlineFillUi.InlineSuggestionUiCallback inlineSuggestionUiCallback,
|
||||||
@NonNull Runnable onErrorCallback,
|
@NonNull Runnable onErrorCallback,
|
||||||
@Nullable RemoteInlineSuggestionRenderService remoteRenderService) {
|
@Nullable RemoteInlineSuggestionRenderService remoteRenderService,
|
||||||
|
int userId, int sessionId) {
|
||||||
if (sDebug) Slog.d(TAG, "createAugmentedInlineSuggestionsResponse called");
|
if (sDebug) Slog.d(TAG, "createAugmentedInlineSuggestionsResponse called");
|
||||||
return createInlineSuggestionsInternal(/* isAugmented= */ true, request,
|
return createInlineSuggestionsInternal(/* isAugmented= */ true, request,
|
||||||
datasets, autofillId, onErrorCallback,
|
datasets, autofillId, onErrorCallback,
|
||||||
@@ -112,7 +116,7 @@ final class InlineSuggestionFactory {
|
|||||||
inlineSuggestionUiCallback.autofill(dataset, datasetIndex),
|
inlineSuggestionUiCallback.autofill(dataset, datasetIndex),
|
||||||
(intentSender) ->
|
(intentSender) ->
|
||||||
inlineSuggestionUiCallback.startIntentSender(intentSender, new Intent()),
|
inlineSuggestionUiCallback.startIntentSender(intentSender, new Intent()),
|
||||||
remoteRenderService);
|
remoteRenderService, userId, sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -121,7 +125,8 @@ final class InlineSuggestionFactory {
|
|||||||
@NonNull List<Dataset> datasets, @NonNull AutofillId autofillId,
|
@NonNull List<Dataset> datasets, @NonNull AutofillId autofillId,
|
||||||
@NonNull Runnable onErrorCallback, @NonNull BiConsumer<Dataset, Integer> onClickFactory,
|
@NonNull Runnable onErrorCallback, @NonNull BiConsumer<Dataset, Integer> onClickFactory,
|
||||||
@NonNull Consumer<IntentSender> intentSenderConsumer,
|
@NonNull Consumer<IntentSender> intentSenderConsumer,
|
||||||
@Nullable RemoteInlineSuggestionRenderService remoteRenderService) {
|
@Nullable RemoteInlineSuggestionRenderService remoteRenderService,
|
||||||
|
int userId, int sessionId) {
|
||||||
SparseArray<Pair<Dataset, InlineSuggestion>> response = new SparseArray<>(datasets.size());
|
SparseArray<Pair<Dataset, InlineSuggestion>> response = new SparseArray<>(datasets.size());
|
||||||
for (int datasetIndex = 0; datasetIndex < datasets.size(); datasetIndex++) {
|
for (int datasetIndex = 0; datasetIndex < datasets.size(); datasetIndex++) {
|
||||||
final Dataset dataset = datasets.get(datasetIndex);
|
final Dataset dataset = datasets.get(datasetIndex);
|
||||||
@@ -139,7 +144,8 @@ final class InlineSuggestionFactory {
|
|||||||
InlineSuggestion inlineSuggestion = createInlineSuggestion(isAugmented, dataset,
|
InlineSuggestion inlineSuggestion = createInlineSuggestion(isAugmented, dataset,
|
||||||
datasetIndex,
|
datasetIndex,
|
||||||
mergedInlinePresentation(request, datasetIndex, inlinePresentation),
|
mergedInlinePresentation(request, datasetIndex, inlinePresentation),
|
||||||
onClickFactory, remoteRenderService, onErrorCallback, intentSenderConsumer,
|
onClickFactory, remoteRenderService, userId, sessionId,
|
||||||
|
onErrorCallback, intentSenderConsumer,
|
||||||
request.getHostInputToken(), request.getHostDisplayId());
|
request.getHostInputToken(), request.getHostDisplayId());
|
||||||
response.append(datasetIndex, Pair.create(dataset, inlineSuggestion));
|
response.append(datasetIndex, Pair.create(dataset, inlineSuggestion));
|
||||||
}
|
}
|
||||||
@@ -151,6 +157,7 @@ final class InlineSuggestionFactory {
|
|||||||
@NonNull InlinePresentation inlinePresentation,
|
@NonNull InlinePresentation inlinePresentation,
|
||||||
@NonNull BiConsumer<Dataset, Integer> onClickFactory,
|
@NonNull BiConsumer<Dataset, Integer> onClickFactory,
|
||||||
@NonNull RemoteInlineSuggestionRenderService remoteRenderService,
|
@NonNull RemoteInlineSuggestionRenderService remoteRenderService,
|
||||||
|
int userId, int sessionId,
|
||||||
@NonNull Runnable onErrorCallback, @NonNull Consumer<IntentSender> intentSenderConsumer,
|
@NonNull Runnable onErrorCallback, @NonNull Consumer<IntentSender> intentSenderConsumer,
|
||||||
@Nullable IBinder hostInputToken,
|
@Nullable IBinder hostInputToken,
|
||||||
int displayId) {
|
int displayId) {
|
||||||
@@ -167,7 +174,8 @@ final class InlineSuggestionFactory {
|
|||||||
final InlineSuggestion inlineSuggestion = new InlineSuggestion(inlineSuggestionInfo,
|
final InlineSuggestion inlineSuggestion = new InlineSuggestion(inlineSuggestionInfo,
|
||||||
createInlineContentProvider(inlinePresentation,
|
createInlineContentProvider(inlinePresentation,
|
||||||
() -> onClickFactory.accept(dataset, datasetIndex), onErrorCallback,
|
() -> onClickFactory.accept(dataset, datasetIndex), onErrorCallback,
|
||||||
intentSenderConsumer, remoteRenderService, hostInputToken, displayId));
|
intentSenderConsumer, remoteRenderService, userId, sessionId,
|
||||||
|
hostInputToken, displayId));
|
||||||
|
|
||||||
return inlineSuggestion;
|
return inlineSuggestion;
|
||||||
}
|
}
|
||||||
@@ -175,6 +183,7 @@ final class InlineSuggestionFactory {
|
|||||||
private static InlineSuggestion createInlineAuthSuggestion(
|
private static InlineSuggestion createInlineAuthSuggestion(
|
||||||
@NonNull InlinePresentation inlinePresentation,
|
@NonNull InlinePresentation inlinePresentation,
|
||||||
@NonNull RemoteInlineSuggestionRenderService remoteRenderService,
|
@NonNull RemoteInlineSuggestionRenderService remoteRenderService,
|
||||||
|
int userId, int sessionId,
|
||||||
@NonNull BiConsumer<Dataset, Integer> onClickFactory, @NonNull Runnable onErrorCallback,
|
@NonNull BiConsumer<Dataset, Integer> onClickFactory, @NonNull Runnable onErrorCallback,
|
||||||
@NonNull Consumer<IntentSender> intentSenderConsumer,
|
@NonNull Consumer<IntentSender> intentSenderConsumer,
|
||||||
@Nullable IBinder hostInputToken, int displayId) {
|
@Nullable IBinder hostInputToken, int displayId) {
|
||||||
@@ -187,8 +196,8 @@ final class InlineSuggestionFactory {
|
|||||||
createInlineContentProvider(inlinePresentation,
|
createInlineContentProvider(inlinePresentation,
|
||||||
() -> onClickFactory.accept(null,
|
() -> onClickFactory.accept(null,
|
||||||
AutofillManager.AUTHENTICATION_ID_DATASET_ID_UNDEFINED),
|
AutofillManager.AUTHENTICATION_ID_DATASET_ID_UNDEFINED),
|
||||||
onErrorCallback, intentSenderConsumer, remoteRenderService, hostInputToken,
|
onErrorCallback, intentSenderConsumer, remoteRenderService, userId,
|
||||||
displayId));
|
sessionId, hostInputToken, displayId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -216,12 +225,13 @@ final class InlineSuggestionFactory {
|
|||||||
@NonNull Runnable onErrorCallback,
|
@NonNull Runnable onErrorCallback,
|
||||||
@NonNull Consumer<IntentSender> intentSenderConsumer,
|
@NonNull Consumer<IntentSender> intentSenderConsumer,
|
||||||
@Nullable RemoteInlineSuggestionRenderService remoteRenderService,
|
@Nullable RemoteInlineSuggestionRenderService remoteRenderService,
|
||||||
|
int userId, int sessionId,
|
||||||
@Nullable IBinder hostInputToken,
|
@Nullable IBinder hostInputToken,
|
||||||
int displayId) {
|
int displayId) {
|
||||||
RemoteInlineSuggestionViewConnector
|
RemoteInlineSuggestionViewConnector
|
||||||
remoteInlineSuggestionViewConnector = new RemoteInlineSuggestionViewConnector(
|
remoteInlineSuggestionViewConnector = new RemoteInlineSuggestionViewConnector(
|
||||||
remoteRenderService, inlinePresentation, hostInputToken, displayId, onClickAction,
|
remoteRenderService, userId, sessionId, inlinePresentation, hostInputToken,
|
||||||
onErrorCallback, intentSenderConsumer);
|
displayId, onClickAction, onErrorCallback, intentSenderConsumer);
|
||||||
InlineContentProviderImpl inlineContentProvider = new InlineContentProviderImpl(
|
InlineContentProviderImpl inlineContentProvider = new InlineContentProviderImpl(
|
||||||
remoteInlineSuggestionViewConnector, null);
|
remoteInlineSuggestionViewConnector, null);
|
||||||
return inlineContentProvider;
|
return inlineContentProvider;
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ final class RemoteInlineSuggestionViewConnector {
|
|||||||
@Nullable
|
@Nullable
|
||||||
private final IBinder mHostInputToken;
|
private final IBinder mHostInputToken;
|
||||||
private final int mDisplayId;
|
private final int mDisplayId;
|
||||||
|
private final int mUserId;
|
||||||
|
private final int mSessionId;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private final Runnable mOnAutofillCallback;
|
private final Runnable mOnAutofillCallback;
|
||||||
@@ -56,6 +58,7 @@ final class RemoteInlineSuggestionViewConnector {
|
|||||||
|
|
||||||
RemoteInlineSuggestionViewConnector(
|
RemoteInlineSuggestionViewConnector(
|
||||||
@Nullable RemoteInlineSuggestionRenderService remoteRenderService,
|
@Nullable RemoteInlineSuggestionRenderService remoteRenderService,
|
||||||
|
int userId, int sessionId,
|
||||||
@NonNull InlinePresentation inlinePresentation,
|
@NonNull InlinePresentation inlinePresentation,
|
||||||
@Nullable IBinder hostInputToken,
|
@Nullable IBinder hostInputToken,
|
||||||
int displayId,
|
int displayId,
|
||||||
@@ -66,6 +69,8 @@ final class RemoteInlineSuggestionViewConnector {
|
|||||||
mInlinePresentation = inlinePresentation;
|
mInlinePresentation = inlinePresentation;
|
||||||
mHostInputToken = hostInputToken;
|
mHostInputToken = hostInputToken;
|
||||||
mDisplayId = displayId;
|
mDisplayId = displayId;
|
||||||
|
mUserId = userId;
|
||||||
|
mSessionId = sessionId;
|
||||||
|
|
||||||
mOnAutofillCallback = onAutofillCallback;
|
mOnAutofillCallback = onAutofillCallback;
|
||||||
mOnErrorCallback = onErrorCallback;
|
mOnErrorCallback = onErrorCallback;
|
||||||
@@ -82,7 +87,7 @@ final class RemoteInlineSuggestionViewConnector {
|
|||||||
if (mRemoteRenderService != null) {
|
if (mRemoteRenderService != null) {
|
||||||
if (sDebug) Slog.d(TAG, "Request to recreate the UI");
|
if (sDebug) Slog.d(TAG, "Request to recreate the UI");
|
||||||
mRemoteRenderService.renderSuggestion(callback, mInlinePresentation, width, height,
|
mRemoteRenderService.renderSuggestion(callback, mInlinePresentation, width, height,
|
||||||
mHostInputToken, mDisplayId);
|
mHostInputToken, mDisplayId, mUserId, mSessionId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user