Merge "Pass InlineSuggestionsRequest via autofill auth intent extras" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
10c0b8a7ae
@@ -50924,6 +50924,7 @@ package android.view.autofill {
|
|||||||
field public static final String EXTRA_AUTHENTICATION_RESULT = "android.view.autofill.extra.AUTHENTICATION_RESULT";
|
field public static final String EXTRA_AUTHENTICATION_RESULT = "android.view.autofill.extra.AUTHENTICATION_RESULT";
|
||||||
field public static final String EXTRA_AUTHENTICATION_RESULT_EPHEMERAL_DATASET = "android.view.autofill.extra.AUTHENTICATION_RESULT_EPHEMERAL_DATASET";
|
field public static final String EXTRA_AUTHENTICATION_RESULT_EPHEMERAL_DATASET = "android.view.autofill.extra.AUTHENTICATION_RESULT_EPHEMERAL_DATASET";
|
||||||
field public static final String EXTRA_CLIENT_STATE = "android.view.autofill.extra.CLIENT_STATE";
|
field public static final String EXTRA_CLIENT_STATE = "android.view.autofill.extra.CLIENT_STATE";
|
||||||
|
field public static final String EXTRA_INLINE_SUGGESTIONS_REQUEST = "android.view.autofill.extra.INLINE_SUGGESTIONS_REQUEST";
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract static class AutofillManager.AutofillCallback {
|
public abstract static class AutofillManager.AutofillCallback {
|
||||||
|
|||||||
@@ -249,6 +249,18 @@ public final class AutofillManager {
|
|||||||
public static final String EXTRA_CLIENT_STATE =
|
public static final String EXTRA_CLIENT_STATE =
|
||||||
"android.view.autofill.extra.CLIENT_STATE";
|
"android.view.autofill.extra.CLIENT_STATE";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Intent extra: the {@link android.view.inputmethod.InlineSuggestionsRequest} in the
|
||||||
|
* autofill request.
|
||||||
|
*
|
||||||
|
* <p>This is filled in the authentication intent so the
|
||||||
|
* {@link android.service.autofill.AutofillService} can use it to create the inline
|
||||||
|
* suggestion {@link android.service.autofill.Dataset} in the response, if the original autofill
|
||||||
|
* request contains the {@link android.view.inputmethod.InlineSuggestionsRequest}.
|
||||||
|
*/
|
||||||
|
public static final String EXTRA_INLINE_SUGGESTIONS_REQUEST =
|
||||||
|
"android.view.autofill.extra.INLINE_SUGGESTIONS_REQUEST";
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public static final String EXTRA_RESTORE_SESSION_TOKEN =
|
public static final String EXTRA_RESTORE_SESSION_TOKEN =
|
||||||
"android.view.autofill.extra.RESTORE_SESSION_TOKEN";
|
"android.view.autofill.extra.RESTORE_SESSION_TOKEN";
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ import android.util.ArrayMap;
|
|||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
import android.util.LocalLog;
|
import android.util.LocalLog;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.util.Pair;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import android.util.TimeUtils;
|
import android.util.TimeUtils;
|
||||||
@@ -221,6 +222,13 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
private final ArrayMap<AutofillId, ViewState> mViewStates = new ArrayMap<>();
|
private final ArrayMap<AutofillId, ViewState> mViewStates = new ArrayMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tracks the most recent IME inline request and the corresponding request id, for regular
|
||||||
|
* autofill.
|
||||||
|
*/
|
||||||
|
@GuardedBy("mLock")
|
||||||
|
@Nullable private Pair<Integer, InlineSuggestionsRequest> mLastInlineSuggestionsRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Id of the View currently being displayed.
|
* Id of the View currently being displayed.
|
||||||
*/
|
*/
|
||||||
@@ -330,7 +338,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
private ArrayList<AutofillId> mAugmentedAutofillableIds;
|
private ArrayList<AutofillId> mAugmentedAutofillableIds;
|
||||||
|
|
||||||
@Nullable
|
@NonNull
|
||||||
private final AutofillInlineSessionController mInlineSessionController;
|
private final AutofillInlineSessionController mInlineSessionController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -821,11 +829,14 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
/* isInlineRequest= */ true);
|
/* isInlineRequest= */ true);
|
||||||
if (inlineSuggestionsRequestConsumer != null) {
|
if (inlineSuggestionsRequestConsumer != null) {
|
||||||
final AutofillId focusedId = mCurrentViewId;
|
final AutofillId focusedId = mCurrentViewId;
|
||||||
|
final int requestIdCopy = requestId;
|
||||||
remoteRenderService.getInlineSuggestionsRendererInfo(
|
remoteRenderService.getInlineSuggestionsRendererInfo(
|
||||||
new RemoteCallback((extras) -> {
|
new RemoteCallback((extras) -> {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
mInlineSessionController.onCreateInlineSuggestionsRequestLocked(
|
mInlineSessionController.onCreateInlineSuggestionsRequestLocked(
|
||||||
focusedId, inlineSuggestionsRequestConsumer, extras);
|
focusedId, inlineSuggestionsRequestCacheDecorator(
|
||||||
|
inlineSuggestionsRequestConsumer, requestIdCopy),
|
||||||
|
extras);
|
||||||
}
|
}
|
||||||
}, mHandler)
|
}, mHandler)
|
||||||
);
|
);
|
||||||
@@ -3668,11 +3679,27 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
requestId, mContexts);
|
requestId, mContexts);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (mLastInlineSuggestionsRequest != null
|
||||||
|
&& mLastInlineSuggestionsRequest.first == requestId) {
|
||||||
|
fillInIntent.putExtra(AutofillManager.EXTRA_INLINE_SUGGESTIONS_REQUEST,
|
||||||
|
mLastInlineSuggestionsRequest.second);
|
||||||
|
}
|
||||||
fillInIntent.putExtra(AutofillManager.EXTRA_ASSIST_STRUCTURE, context.getStructure());
|
fillInIntent.putExtra(AutofillManager.EXTRA_ASSIST_STRUCTURE, context.getStructure());
|
||||||
fillInIntent.putExtra(AutofillManager.EXTRA_CLIENT_STATE, extras);
|
fillInIntent.putExtra(AutofillManager.EXTRA_CLIENT_STATE, extras);
|
||||||
return fillInIntent;
|
return fillInIntent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
private Consumer<InlineSuggestionsRequest> inlineSuggestionsRequestCacheDecorator(
|
||||||
|
@NonNull Consumer<InlineSuggestionsRequest> consumer, int requestId) {
|
||||||
|
return inlineSuggestionsRequest -> {
|
||||||
|
consumer.accept(inlineSuggestionsRequest);
|
||||||
|
synchronized (mLock) {
|
||||||
|
mLastInlineSuggestionsRequest = Pair.create(requestId, inlineSuggestionsRequest);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private void startAuthentication(int authenticationId, IntentSender intent,
|
private void startAuthentication(int authenticationId, IntentSender intent,
|
||||||
Intent fillInIntent, boolean authenticateInline) {
|
Intent fillInIntent, boolean authenticateInline) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user