Merge "Updated SmartSuggestions coordinates when focused field changed."
diff --git a/core/java/android/service/autofill/augmented/AugmentedAutofillService.java b/core/java/android/service/autofill/augmented/AugmentedAutofillService.java
index 9aff281..7683b8a 100644
--- a/core/java/android/service/autofill/augmented/AugmentedAutofillService.java
+++ b/core/java/android/service/autofill/augmented/AugmentedAutofillService.java
@@ -254,6 +254,15 @@
@GuardedBy("mLock")
private AutofillValue mFocusedValue;
+ /**
+ * Id of the last field that cause the Autofill UI to be shown.
+ *
+ * <p>Used to make sure the SmartSuggestionsParams is updated when a new fields is focused.
+ */
+ // TODO(b/111330312): might not be needed when using IME
+ @GuardedBy("mLock")
+ private AutofillId mLastShownId;
+
// Objects used to log metrics
private final long mRequestTime;
private long mOnSuccessTime;
@@ -284,7 +293,7 @@
@NonNull
public SystemPopupPresentationParams getSmartSuggestionParams() {
synchronized (mLock) {
- if (mSmartSuggestion != null) {
+ if (mSmartSuggestion != null && mFocusedId.equals(mLastShownId)) {
return mSmartSuggestion;
}
Rect rect;
@@ -299,6 +308,7 @@
return null;
}
mSmartSuggestion = new SystemPopupPresentationParams(this, rect);
+ mLastShownId = mFocusedId;
return mSmartSuggestion;
}
}
@@ -401,6 +411,9 @@
if (mFocusedValue != null) {
pw.print(prefix); pw.print("focusedValue: "); pw.println(mFocusedValue);
}
+ if (mLastShownId != null) {
+ pw.print(prefix); pw.print("lastShownId: "); pw.println(mLastShownId);
+ }
pw.print(prefix); pw.print("client: "); pw.println(mClient);
final String prefix2 = prefix + " ";
if (mFillWindow != null) {