Merge "Make autofill requested by augmented autofill service non-manual" into rvc-dev am: 98367aef11
Change-Id: I6b08fe0719dd6436f03a3443b8c98c1d9635bfeb
This commit is contained in:
@@ -163,14 +163,18 @@ public abstract class AugmentedAutofillService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The child class of the service can call this method to initiate an Autofill flow.
|
* The child class of the service can call this method to initiate a new Autofill flow. If all
|
||||||
|
* conditions are met, it will make a request to the client app process to explicitly cancel
|
||||||
|
* the current autofill session and create a new session. For example, an augmented autofill
|
||||||
|
* service may notice some events which make it think a good time to provide updated
|
||||||
|
* augmented autofill suggestions.
|
||||||
*
|
*
|
||||||
* <p> The request would be respected only if the previous augmented autofill request was
|
* <p> The request would be respected only if the previous augmented autofill request was
|
||||||
* made for the same {@code activityComponent} and {@code autofillId}, and the field is
|
* made for the same {@code activityComponent} and {@code autofillId}, and the field is
|
||||||
* currently on focus.
|
* currently on focus.
|
||||||
*
|
*
|
||||||
* <p> The request would start a new autofill flow. It doesn't guarantee that the
|
* <p> The request would cancel the current session and start a new autofill flow.
|
||||||
* {@link AutofillManager} will proceed with the request.
|
* It doesn't guarantee that the {@link AutofillManager} will proceed with the request.
|
||||||
*
|
*
|
||||||
* @param activityComponent the client component for which the autofill is requested for
|
* @param activityComponent the client component for which the autofill is requested for
|
||||||
* @param autofillId the client field id for which the autofill is requested for
|
* @param autofillId the client field id for which the autofill is requested for
|
||||||
@@ -179,8 +183,6 @@ public abstract class AugmentedAutofillService extends Service {
|
|||||||
*/
|
*/
|
||||||
public final boolean requestAutofill(@NonNull ComponentName activityComponent,
|
public final boolean requestAutofill(@NonNull ComponentName activityComponent,
|
||||||
@NonNull AutofillId autofillId) {
|
@NonNull AutofillId autofillId) {
|
||||||
// TODO(b/149531989): revisit this. The request should start a new autofill session
|
|
||||||
// rather than reusing the existing session.
|
|
||||||
final AutofillProxy proxy = mAutofillProxyForLastRequest;
|
final AutofillProxy proxy = mAutofillProxyForLastRequest;
|
||||||
if (proxy == null || !proxy.mComponentName.equals(activityComponent)
|
if (proxy == null || !proxy.mComponentName.equals(activityComponent)
|
||||||
|| !proxy.mFocusedId.equals(autofillId)) {
|
|| !proxy.mFocusedId.equals(autofillId)) {
|
||||||
|
|||||||
@@ -882,6 +882,25 @@ public final class AutofillManager {
|
|||||||
notifyViewEntered(view, FLAG_MANUAL_REQUEST);
|
notifyViewEntered(view, FLAG_MANUAL_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Explicitly cancels the current session and requests a new autofill context.
|
||||||
|
*
|
||||||
|
* <p>Normally, the autofill context is automatically started if necessary when
|
||||||
|
* {@link #notifyViewEntered(View)} is called, but this method should be used in
|
||||||
|
* cases where it must be explicitly started or restarted. Currently, this method should only
|
||||||
|
* be called by
|
||||||
|
* {@link android.service.autofill.augmented.AugmentedAutofillService#requestAutofill(
|
||||||
|
* ComponentName, AutofillId)} to cancel the current session and trigger the autofill flow in
|
||||||
|
* a new session, giving the autofill service or the augmented autofill service a chance to
|
||||||
|
* send updated suggestions.
|
||||||
|
*
|
||||||
|
* @param view view requesting the new autofill context.
|
||||||
|
*/
|
||||||
|
void requestAutofillFromNewSession(@NonNull View view) {
|
||||||
|
cancel();
|
||||||
|
notifyViewEntered(view);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Explicitly requests a new autofill context for virtual views.
|
* Explicitly requests a new autofill context for virtual views.
|
||||||
*
|
*
|
||||||
@@ -1403,7 +1422,7 @@ public final class AutofillManager {
|
|||||||
* methods such as {@link android.app.Activity#finish()}.
|
* methods such as {@link android.app.Activity#finish()}.
|
||||||
*/
|
*/
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
if (sVerbose) Log.v(TAG, "cancel() called by app");
|
if (sVerbose) Log.v(TAG, "cancel() called by app or augmented autofill service");
|
||||||
if (!hasAutofillFeature()) {
|
if (!hasAutofillFeature()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -3484,7 +3503,7 @@ public final class AutofillManager {
|
|||||||
if (sVerbose) {
|
if (sVerbose) {
|
||||||
Log.v(TAG, "requestAutofill() by AugmentedAutofillService.");
|
Log.v(TAG, "requestAutofill() by AugmentedAutofillService.");
|
||||||
}
|
}
|
||||||
afm.post(() -> afm.requestAutofill(view));
|
afm.post(() -> afm.requestAutofillFromNewSession(view));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user