From c7ed8c395bfe3f173b54a0dde683a2ce4cb98fa2 Mon Sep 17 00:00:00 2001 From: Felipe Leme Date: Wed, 5 Apr 2017 17:11:01 -0700 Subject: [PATCH] Shows a Toast when manual autofill request cannot be fulfilled. Bug: 35708229 Test: manual verification Change-Id: If4fa6556dd94a805727329f0aebc4b37f548b3a1 --- core/res/res/values/strings.xml | 3 +++ core/res/res/values/symbols.xml | 1 + .../autofill/java/com/android/server/autofill/Session.java | 4 ++++ .../java/com/android/server/autofill/ui/AutoFillUI.java | 7 +++++++ 4 files changed, 15 insertions(+) diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 459b48fc54236..ae28797c32aad 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -4585,6 +4585,9 @@ Autofill options + + Contents can\u2019t be autofilled + Save to %1$s? diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index fa13fbf93267b..741115c6f1353 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -2874,6 +2874,7 @@ + diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java index 801769cc42e12..b02db18a4c86e 100644 --- a/services/autofill/java/com/android/server/autofill/Session.java +++ b/services/autofill/java/com/android/server/autofill/Session.java @@ -56,6 +56,7 @@ import android.view.autofill.AutofillValue; import android.view.autofill.IAutoFillManagerClient; import android.view.autofill.IAutofillWindowPresenter; +import com.android.internal.R; import com.android.internal.annotations.GuardedBy; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; @@ -181,6 +182,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState public void onFillRequestSuccess(@Nullable FillResponse response, @NonNull String servicePackageName) { if (response == null) { + if ((mFlags & FLAG_MANUAL_REQUEST) != 0) { + getUiForShowing().showError(R.string.autofill_error_cannot_autofill); + } // Nothing to be done, but need to notify client. notifyUnavailableToClient(); removeSelf(); diff --git a/services/autofill/java/com/android/server/autofill/ui/AutoFillUI.java b/services/autofill/java/com/android/server/autofill/ui/AutoFillUI.java index 832ff9a4435c3..257256dc58e74 100644 --- a/services/autofill/java/com/android/server/autofill/ui/AutoFillUI.java +++ b/services/autofill/java/com/android/server/autofill/ui/AutoFillUI.java @@ -86,6 +86,13 @@ public final class AutoFillUI { }); } + /** + * Displays an error message to the user. + */ + public void showError(int resId) { + showError(mContext.getString(resId)); + } + /** * Displays an error message to the user. */