diff options
| -rw-r--r-- | core/java/android/service/autofill/FillCallback.java | 39 | ||||
| -rw-r--r-- | core/java/android/service/autofill/SaveCallback.java | 13 |
2 files changed, 42 insertions, 10 deletions
diff --git a/core/java/android/service/autofill/FillCallback.java b/core/java/android/service/autofill/FillCallback.java index 1695c1306824..818ffde44297 100644 --- a/core/java/android/service/autofill/FillCallback.java +++ b/core/java/android/service/autofill/FillCallback.java @@ -39,13 +39,20 @@ public final class FillCallback { } /** - * Notifies the Android System that an - * {@link AutofillService#onFillRequest(FillRequest, android.os.CancellationSignal, - * FillCallback)} was successfully fulfilled by the service. + * Notifies the Android System that a fill request + * ({@link AutofillService#onFillRequest(FillRequest, android.os.CancellationSignal, + * FillCallback)}) was successfully fulfilled by the service. + * + * <p>This method should always be called, even if the service doesn't have the heuristics to + * fulfill the request (in which case it should be called with {@code null}). + * + * <p>See the main {@link AutofillService} documentation for more details and examples. + * + * @param response autofill information for that activity, or {@code null} when the service + * cannot autofill the activity. * - * @param response autofill information for that activity, or {@code null} when the activity - * cannot be autofilled (for example, if it only contains read-only fields). See - * {@link FillResponse} for examples. + * @throws IllegalStateException if this method or {@link #onFailure(CharSequence)} was already + * called. */ public void onSuccess(@Nullable FillResponse response) { assertNotCalled(); @@ -63,11 +70,25 @@ public final class FillCallback { } /** - * Notifies the Android System that an + * Notifies the Android System that a fill request ( * {@link AutofillService#onFillRequest(FillRequest, android.os.CancellationSignal, - * FillCallback)} could not be fulfilled by the service. + * FillCallback)}) could not be fulfilled by the service (for example, because the user data was + * not available yet), so the request could be retried later. + * + * <p><b>Note: </b>this method should not be used when the service didn't have the heursitics to + * fulfill the request; in this case, the service should call {@link #onSuccess(FillResponse) + * onSuccess(null)} instead. + * + * <p><b>Note: </b>on Android versions up to {@link android.os.Build.VERSION_CODES#P}, this + * method is not working as intended, and the service should call + * {@link #onSuccess(FillResponse) onSuccess(null)} instead. + * + * @param message error message to be displayed to the user. <b>Note: </b> this message is + * displayed on {@code logcat} logs and should not contain PII (Personally Identifiable + * Information, such as username or email address). * - * @param message error message to be displayed to the user. + * @throws IllegalStateException if this method or {@link #onSuccess(FillResponse)} was already + * called. */ public void onFailure(@Nullable CharSequence message) { assertNotCalled(); diff --git a/core/java/android/service/autofill/SaveCallback.java b/core/java/android/service/autofill/SaveCallback.java index 855981a544fd..a98a2492f694 100644 --- a/core/java/android/service/autofill/SaveCallback.java +++ b/core/java/android/service/autofill/SaveCallback.java @@ -41,6 +41,9 @@ public final class SaveCallback { * Notifies the Android System that an * {@link AutofillService#onSaveRequest(SaveRequest, SaveCallback)} was successfully handled * by the service. + * + * @throws IllegalStateException if this method, {@link #onSuccess(IntentSender)}, or + * {@link #onFailure(CharSequence)} was already called. */ public void onSuccess() { onSuccessInternal(null); @@ -58,6 +61,9 @@ public final class SaveCallback { * * @param intentSender intent that will be launched from the context of activity being * autofilled. + * + * @throws IllegalStateException if this method, {@link #onSuccess()}, + * or {@link #onFailure(CharSequence)} was already called. */ public void onSuccess(@NonNull IntentSender intentSender) { onSuccessInternal(Preconditions.checkNotNull(intentSender)); @@ -86,7 +92,12 @@ public final class SaveCallback { * you prefer to show your own message, call {@link #onSuccess()} or * {@link #onSuccess(IntentSender)} instead. * - * @param message error message to be displayed to the user. + * @param message error message to be displayed to the user. <b>Note: </b> this message is + * displayed on {@code logcat} logs and should not contain PII (Personally Identifiable + * Information, such as username or email address). + * + * @throws IllegalStateException if this method, {@link #onSuccess()}, + * or {@link #onSuccess(IntentSender)} was already called. */ public void onFailure(CharSequence message) { assertNotCalled(); |