From 23668c560e06dd22e46ab13082d59a76d119eb5d Mon Sep 17 00:00:00 2001 From: Joanne Chung Date: Thu, 17 Mar 2022 16:36:28 +0800 Subject: [PATCH] Allow AutofillService can identify if fill dialog presentation is needed. If the fill dialog is available for the field, the FillRequest flags will contain FLAG_ACIVITY_START. The field is hidden originally but it needs to be get from AutofillService to avoid creating unnessary fill dialog presentation. Rename the flag because the it's not clear to combine the relationship with fill dialog. Bug: 223472039 Test: manual. Build and boot pass. Change-Id: I52c367e75100f6af2ab782f58755bc5727b1dd72 --- core/api/current.txt | 1 + .../android/service/autofill/FillRequest.java | 30 +++++++++++-------- .../view/autofill/AutofillManager.java | 4 +-- .../com/android/server/autofill/Session.java | 10 +++---- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index e2a7f8761a115..18a7a2b0ead1c 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -38225,6 +38225,7 @@ package android.service.autofill { field @NonNull public static final android.os.Parcelable.Creator CREATOR; field public static final int FLAG_COMPATIBILITY_MODE_REQUEST = 2; // 0x2 field public static final int FLAG_MANUAL_REQUEST = 1; // 0x1 + field public static final int FLAG_SUPPORTS_FILL_DIALOG = 64; // 0x40 } public final class FillResponse implements android.os.Parcelable { diff --git a/core/java/android/service/autofill/FillRequest.java b/core/java/android/service/autofill/FillRequest.java index e4d3732361ed5..c73ebed3c368a 100644 --- a/core/java/android/service/autofill/FillRequest.java +++ b/core/java/android/service/autofill/FillRequest.java @@ -100,10 +100,10 @@ public final class FillRequest implements Parcelable { // The flag value 0x20 has been defined in AutofillManager. /** - * Indicates the request is coming from the activity just started. - * @hide + * Indicates the request supports fill dialog presentation for the fields, the + * system will send the request when the activity just started. */ - public static final @RequestFlags int FLAG_ACTIVITY_START = 0x40; + public static final @RequestFlags int FLAG_SUPPORTS_FILL_DIALOG = 0x40; /** @hide */ public static final int INVALID_REQUEST_ID = Integer.MIN_VALUE; @@ -140,8 +140,10 @@ public final class FillRequest implements Parcelable { /** * Gets the flags associated with this request. * - * @return any combination of {@link #FLAG_MANUAL_REQUEST} and + * @return any combination of {@link #FLAG_MANUAL_REQUEST}, + * {@link #FLAG_SUPPORTS_FILL_DIALOG} and * {@link #FLAG_COMPATIBILITY_MODE_REQUEST}. + * */ private final @RequestFlags int mFlags; @@ -199,7 +201,7 @@ public final class FillRequest implements Parcelable { FLAG_COMPATIBILITY_MODE_REQUEST, FLAG_PASSWORD_INPUT_TYPE, FLAG_VIEW_NOT_FOCUSED, - FLAG_ACTIVITY_START + FLAG_SUPPORTS_FILL_DIALOG }) @Retention(RetentionPolicy.SOURCE) @DataClass.Generated.Member @@ -223,8 +225,8 @@ public final class FillRequest implements Parcelable { return "FLAG_PASSWORD_INPUT_TYPE"; case FLAG_VIEW_NOT_FOCUSED: return "FLAG_VIEW_NOT_FOCUSED"; - case FLAG_ACTIVITY_START: - return "FLAG_ACTIVITY_START"; + case FLAG_SUPPORTS_FILL_DIALOG: + return "FLAG_SUPPORTS_FILL_DIALOG"; default: return Integer.toHexString(value); } } @@ -253,7 +255,8 @@ public final class FillRequest implements Parcelable { * @param flags * Gets the flags associated with this request. * - * @return any combination of {@link #FLAG_MANUAL_REQUEST} and + * @return any combination of {@link #FLAG_MANUAL_REQUEST}, + * {@link #FLAG_SUPPORTS_FILL_DIALOG} and * {@link #FLAG_COMPATIBILITY_MODE_REQUEST}. * @param inlineSuggestionsRequest * Gets the {@link InlineSuggestionsRequest} associated @@ -299,7 +302,7 @@ public final class FillRequest implements Parcelable { | FLAG_COMPATIBILITY_MODE_REQUEST | FLAG_PASSWORD_INPUT_TYPE | FLAG_VIEW_NOT_FOCUSED - | FLAG_ACTIVITY_START); + | FLAG_SUPPORTS_FILL_DIALOG); this.mInlineSuggestionsRequest = inlineSuggestionsRequest; this.mDelayedFillIntentSender = delayedFillIntentSender; @@ -347,7 +350,8 @@ public final class FillRequest implements Parcelable { /** * Gets the flags associated with this request. * - * @return any combination of {@link #FLAG_MANUAL_REQUEST} and + * @return any combination of {@link #FLAG_MANUAL_REQUEST}, + * {@link #FLAG_SUPPORTS_FILL_DIALOG} and * {@link #FLAG_COMPATIBILITY_MODE_REQUEST}. */ @DataClass.Generated.Member @@ -458,7 +462,7 @@ public final class FillRequest implements Parcelable { | FLAG_COMPATIBILITY_MODE_REQUEST | FLAG_PASSWORD_INPUT_TYPE | FLAG_VIEW_NOT_FOCUSED - | FLAG_ACTIVITY_START); + | FLAG_SUPPORTS_FILL_DIALOG); this.mInlineSuggestionsRequest = inlineSuggestionsRequest; this.mDelayedFillIntentSender = delayedFillIntentSender; @@ -480,10 +484,10 @@ public final class FillRequest implements Parcelable { }; @DataClass.Generated( - time = 1643386870464L, + time = 1647644111186L, codegenVersion = "1.0.23", sourceFile = "frameworks/base/core/java/android/service/autofill/FillRequest.java", - inputSignatures = "public static final @android.service.autofill.FillRequest.RequestFlags int FLAG_MANUAL_REQUEST\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_COMPATIBILITY_MODE_REQUEST\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_PASSWORD_INPUT_TYPE\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_VIEW_NOT_FOCUSED\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_ACTIVITY_START\npublic static final int INVALID_REQUEST_ID\nprivate final int mId\nprivate final @android.annotation.NonNull java.util.List mFillContexts\nprivate final @android.annotation.Nullable android.os.Bundle mClientState\nprivate final @android.service.autofill.FillRequest.RequestFlags int mFlags\nprivate final @android.annotation.Nullable android.view.inputmethod.InlineSuggestionsRequest mInlineSuggestionsRequest\nprivate final @android.annotation.Nullable android.content.IntentSender mDelayedFillIntentSender\nprivate void onConstructed()\nclass FillRequest extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genHiddenConstructor=true, genHiddenConstDefs=true)") + inputSignatures = "public static final @android.service.autofill.FillRequest.RequestFlags int FLAG_MANUAL_REQUEST\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_COMPATIBILITY_MODE_REQUEST\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_PASSWORD_INPUT_TYPE\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_VIEW_NOT_FOCUSED\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_SUPPORTS_FILL_DIALOG\npublic static final int INVALID_REQUEST_ID\nprivate final int mId\nprivate final @android.annotation.NonNull java.util.List mFillContexts\nprivate final @android.annotation.Nullable android.os.Bundle mClientState\nprivate final @android.service.autofill.FillRequest.RequestFlags int mFlags\nprivate final @android.annotation.Nullable android.view.inputmethod.InlineSuggestionsRequest mInlineSuggestionsRequest\nprivate final @android.annotation.Nullable android.content.IntentSender mDelayedFillIntentSender\nprivate void onConstructed()\nclass FillRequest extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genHiddenConstructor=true, genHiddenConstDefs=true)") @Deprecated private void __metadata() {} diff --git a/core/java/android/view/autofill/AutofillManager.java b/core/java/android/view/autofill/AutofillManager.java index 3c5007b5b7284..2c81eb1ae3065 100644 --- a/core/java/android/view/autofill/AutofillManager.java +++ b/core/java/android/view/autofill/AutofillManager.java @@ -16,9 +16,9 @@ package android.view.autofill; -import static android.service.autofill.FillRequest.FLAG_ACTIVITY_START; import static android.service.autofill.FillRequest.FLAG_MANUAL_REQUEST; import static android.service.autofill.FillRequest.FLAG_PASSWORD_INPUT_TYPE; +import static android.service.autofill.FillRequest.FLAG_SUPPORTS_FILL_DIALOG; import static android.service.autofill.FillRequest.FLAG_VIEW_NOT_FOCUSED; import static android.view.ContentInfo.SOURCE_AUTOFILL; import static android.view.autofill.Helper.sDebug; @@ -1118,7 +1118,7 @@ public final class AutofillManager { return; } - int flags = FLAG_ACTIVITY_START; + int flags = FLAG_SUPPORTS_FILL_DIALOG; flags |= FLAG_VIEW_NOT_FOCUSED; notifyViewEntered(view, flags); } diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java index e0fa67f64c4c7..0d334e5882146 100644 --- a/services/autofill/java/com/android/server/autofill/Session.java +++ b/services/autofill/java/com/android/server/autofill/Session.java @@ -18,9 +18,9 @@ package com.android.server.autofill; import static android.service.autofill.AutofillFieldClassificationService.EXTRA_SCORES; import static android.service.autofill.AutofillService.EXTRA_FILL_RESPONSE; -import static android.service.autofill.FillRequest.FLAG_ACTIVITY_START; import static android.service.autofill.FillRequest.FLAG_MANUAL_REQUEST; import static android.service.autofill.FillRequest.FLAG_PASSWORD_INPUT_TYPE; +import static android.service.autofill.FillRequest.FLAG_SUPPORTS_FILL_DIALOG; import static android.service.autofill.FillRequest.FLAG_VIEW_NOT_FOCUSED; import static android.service.autofill.FillRequest.INVALID_REQUEST_ID; import static android.view.autofill.AutofillManager.ACTION_RESPONSE_EXPIRED; @@ -965,7 +965,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState mService.getRemoteInlineSuggestionRenderServiceLocked(); if ((mSessionFlags.mInlineSupportedByService || mSessionFlags.mClientSuggestionsEnabled) && remoteRenderService != null - && (isViewFocusedLocked(flags) || (isRequestFromActivityStarted(flags)))) { + && (isViewFocusedLocked(flags) || (isRequestSupportFillDialog(flags)))) { final Consumer inlineSuggestionsRequestConsumer; if (mSessionFlags.mClientSuggestionsEnabled) { final int finalRequestId = requestId; @@ -1011,8 +1011,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState requestAssistStructureLocked(requestId, flags); } - private boolean isRequestFromActivityStarted(int flags) { - return (flags & FLAG_ACTIVITY_START) != 0; + private boolean isRequestSupportFillDialog(int flags) { + return (flags & FLAG_SUPPORTS_FILL_DIALOG) != 0; } @GuardedBy("mLock") @@ -3002,7 +3002,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState // View is triggering autofill. mCurrentViewId = viewState.id; viewState.update(value, virtualBounds, flags); - if (!isRequestFromActivityStarted(flags)) { + if (!isRequestSupportFillDialog(flags)) { mSessionFlags.mFillDialogDisabled = true; } requestNewFillResponseLocked(viewState, ViewState.STATE_STARTED_SESSION, flags);