diff options
| author | 2020-01-16 11:18:12 +0000 | |
|---|---|---|
| committer | 2020-01-16 11:18:12 +0000 | |
| commit | f70990753d0de343d8d5ad2481fcb4f526bee3c7 (patch) | |
| tree | 02cfd52fd26d794c09d037ba092c8577bc6ad508 | |
| parent | b4075aabd078cc3b975e5df096a9fe05674a3da3 (diff) | |
| parent | 8839835d27217713c051b65c9ca19f44c98ca086 (diff) | |
Merge "Starts a new request on switching back to the existing app"
| -rw-r--r-- | core/java/android/app/Activity.java | 3 | ||||
| -rw-r--r-- | core/java/android/view/autofill/AutofillManager.java | 11 | ||||
| -rw-r--r-- | services/autofill/java/com/android/server/autofill/Session.java | 39 |
3 files changed, 47 insertions, 6 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 070a4f80d4e2..d952be5218a4 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -2539,7 +2539,8 @@ public class Activity extends ContextThemeWrapper mCalled = true; if (mAutoFillResetNeeded) { - getAutofillManager().onInvisibleForAutofill(); + // If stopped without changing the configurations, the response should expire. + getAutofillManager().onInvisibleForAutofill(!mChangingConfigurations); } else if (mIntent != null && mIntent.hasExtra(AutofillManager.EXTRA_RESTORE_SESSION_TOKEN) && mIntent.hasExtra(AutofillManager.EXTRA_RESTORE_CROSS_ACTIVITY)) { diff --git a/core/java/android/view/autofill/AutofillManager.java b/core/java/android/view/autofill/AutofillManager.java index 9c04b392b9d3..c159f89cf2ac 100644 --- a/core/java/android/view/autofill/AutofillManager.java +++ b/core/java/android/view/autofill/AutofillManager.java @@ -230,6 +230,7 @@ public final class AutofillManager { /** @hide */ public static final int ACTION_VIEW_ENTERED = 2; /** @hide */ public static final int ACTION_VIEW_EXITED = 3; /** @hide */ public static final int ACTION_VALUE_CHANGED = 4; + /** @hide */ public static final int ACTION_RESPONSE_EXPIRED = 5; /** @hide */ public static final int NO_LOGGING = 0; /** @hide */ public static final int FLAG_ADD_CLIENT_ENABLED = 0x1; @@ -776,11 +777,19 @@ public final class AutofillManager { * * @see AutofillClient#autofillClientIsVisibleForAutofill() * + * @param isExpiredResponse The response has expired or not + * * {@hide} */ - public void onInvisibleForAutofill() { + public void onInvisibleForAutofill(boolean isExpiredResponse) { synchronized (mLock) { mOnInvisibleCalled = true; + + if (isExpiredResponse) { + // Notify service the response has expired. + updateSessionLocked(/* id= */ null, /* bounds= */ null, /* value= */ null, + ACTION_RESPONSE_EXPIRED, /* flags= */ 0); + } } } diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java index 7d354d20cb67..cdd75107db24 100644 --- a/services/autofill/java/com/android/server/autofill/Session.java +++ b/services/autofill/java/com/android/server/autofill/Session.java @@ -19,6 +19,7 @@ package com.android.server.autofill; import static android.service.autofill.AutofillFieldClassificationService.EXTRA_SCORES; import static android.service.autofill.FillRequest.FLAG_MANUAL_REQUEST; import static android.service.autofill.FillRequest.INVALID_REQUEST_ID; +import static android.view.autofill.AutofillManager.ACTION_RESPONSE_EXPIRED; import static android.view.autofill.AutofillManager.ACTION_START_SESSION; import static android.view.autofill.AutofillManager.ACTION_VALUE_CHANGED; import static android.view.autofill.AutofillManager.ACTION_VIEW_ENTERED; @@ -269,6 +270,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState @GuardedBy("mLock") private final LocalLog mWtfHistory; + @GuardedBy("mLock") + private boolean mExpiredResponse; + /** * Map of {@link MetricsEvent#AUTOFILL_REQUEST} metrics, keyed by fill request id. */ @@ -690,6 +694,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState @GuardedBy("mLock") private void requestNewFillResponseLocked(@NonNull ViewState viewState, int newState, int flags) { + mExpiredResponse = false; if (mForAugmentedAutofillOnly || mRemoteFillService == null) { if (sVerbose) { Slog.v(TAG, "requestNewFillResponse(): triggering augmented autofill instead " @@ -1307,6 +1312,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } } + // The client becomes invisible for the authentication, the response is effective. + mExpiredResponse = false; + final Parcelable result = data.getParcelable(AutofillManager.EXTRA_AUTHENTICATION_RESULT); final Bundle newClientState = data.getBundle(AutofillManager.EXTRA_CLIENT_STATE); if (sDebug) { @@ -2322,16 +2330,18 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState * @param id The id of the view that is entered. * @param viewState The view that is entered. * @param flags The flag that was passed by the AutofillManager. + * + * @return {@code true} if a new fill response is requested. */ @GuardedBy("mLock") - private void requestNewFillResponseOnViewEnteredIfNecessaryLocked(@NonNull AutofillId id, + private boolean requestNewFillResponseOnViewEnteredIfNecessaryLocked(@NonNull AutofillId id, @NonNull ViewState viewState, int flags) { if ((flags & FLAG_MANUAL_REQUEST) != 0) { mForAugmentedAutofillOnly = false; if (sDebug) Slog.d(TAG, "Re-starting session on view " + id + " and flags " + flags); maybeRequestInlineSuggestionsRequestThenFillLocked(viewState, ViewState.STATE_RESTARTED_SESSION, flags); - return; + return true; } // If it's not, then check if it it should start a partition. @@ -2342,12 +2352,14 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } maybeRequestInlineSuggestionsRequestThenFillLocked(viewState, ViewState.STATE_STARTED_PARTITION, flags); + return true; } else { if (sVerbose) { Slog.v(TAG, "Not starting new partition for view " + id + ": " + viewState.getStateAsString()); } } + return false; } /** @@ -2355,7 +2367,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState * * @param id The id of the view that is entered * - * @return {@code true} iff a new partition should be started + * @return {@code true} if a new partition should be started */ @GuardedBy("mLock") private boolean shouldStartNewPartitionLocked(@NonNull AutofillId id) { @@ -2363,6 +2375,13 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState return true; } + if (mExpiredResponse) { + if (sDebug) { + Slog.d(TAG, "Starting a new partition because the response has expired."); + } + return true; + } + final int numResponses = mResponses.size(); if (numResponses >= AutofillManagerService.getPartitionMaxCount()) { Slog.e(TAG, "Not starting a new partition on " + id + " because session " + this.id @@ -2414,6 +2433,14 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState + id + " destroyed"); return; } + if (action == ACTION_RESPONSE_EXPIRED) { + mExpiredResponse = true; + if (sDebug) { + Slog.d(TAG, "Set the response has expired."); + } + return; + } + id.setSessionId(this.id); if (sVerbose) { Slog.v(TAG, "updateLocked(" + this.id + "): id=" + id + ", action=" @@ -2577,7 +2604,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState return; } - requestNewFillResponseOnViewEnteredIfNecessaryLocked(id, viewState, flags); + if (requestNewFillResponseOnViewEnteredIfNecessaryLocked(id, viewState, flags)) { + return; + } if (isSameViewEntered) { return; @@ -3678,6 +3707,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState return "VIEW_EXITED"; case ACTION_VALUE_CHANGED: return "VALUE_CHANGED"; + case ACTION_RESPONSE_EXPIRED: + return "RESPONSE_EXPIRED"; default: return "UNKNOWN_" + action; } |