summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2017-11-27 21:06:52 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-11-27 21:06:52 +0000
commit41499dfe188cbd038005b8a07cc31ce2bca8cf5e (patch)
treef573a727475f1a061e4d3a68ea86f73b1d34946c /core/java/android
parent6fc14c85ee2cfed2222e2587782c981e20fdc4ee (diff)
parent4bcb01a3b588fe17717cb95ed1aa1ddd297c6ad0 (diff)
Merge "New Autofill API: SaveCallback.onSuccess(IntentSender)."
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/service/autofill/ISaveCallback.aidl4
-rw-r--r--core/java/android/service/autofill/SaveCallback.java37
2 files changed, 31 insertions, 10 deletions
diff --git a/core/java/android/service/autofill/ISaveCallback.aidl b/core/java/android/service/autofill/ISaveCallback.aidl
index e260c7375cc5..a9364fe5ccba 100644
--- a/core/java/android/service/autofill/ISaveCallback.aidl
+++ b/core/java/android/service/autofill/ISaveCallback.aidl
@@ -16,12 +16,14 @@
package android.service.autofill;
+import android.content.IntentSender;
+
/**
* Interface to receive the result of a save request.
*
* @hide
*/
interface ISaveCallback {
- void onSuccess();
+ void onSuccess(in IntentSender intentSender);
void onFailure(CharSequence message);
}
diff --git a/core/java/android/service/autofill/SaveCallback.java b/core/java/android/service/autofill/SaveCallback.java
index 7207f1df3ee5..855981a544fd 100644
--- a/core/java/android/service/autofill/SaveCallback.java
+++ b/core/java/android/service/autofill/SaveCallback.java
@@ -16,9 +16,14 @@
package android.service.autofill;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.app.Activity;
+import android.content.IntentSender;
import android.os.RemoteException;
+import com.android.internal.util.Preconditions;
+
/**
* Handles save requests from the {@link AutofillService} into the {@link Activity} being
* autofilled.
@@ -36,18 +41,33 @@ public final class SaveCallback {
* Notifies the Android System that an
* {@link AutofillService#onSaveRequest(SaveRequest, SaveCallback)} was successfully handled
* by the service.
+ */
+ public void onSuccess() {
+ onSuccessInternal(null);
+ }
+
+ /**
+ * Notifies the Android System that an
+ * {@link AutofillService#onSaveRequest(SaveRequest, SaveCallback)} was successfully handled
+ * by the service.
*
- * <p>If the service could not handle the request right away&mdash;for example, because it must
- * launch an activity asking the user to authenticate first or because the network is
- * down&mdash;it should still call {@link #onSuccess()}.
+ * <p>This method is useful when the service requires extra work&mdash;for example, launching an
+ * activity asking the user to authenticate first &mdash;before it can process the request,
+ * as the intent will be launched from the context of the activity being autofilled and hence
+ * will be part of that activity's stack.
*
- * @throws RuntimeException if an error occurred while calling the Android System.
+ * @param intentSender intent that will be launched from the context of activity being
+ * autofilled.
*/
- public void onSuccess() {
+ public void onSuccess(@NonNull IntentSender intentSender) {
+ onSuccessInternal(Preconditions.checkNotNull(intentSender));
+ }
+
+ private void onSuccessInternal(@Nullable IntentSender intentSender) {
assertNotCalled();
mCalled = true;
try {
- mCallback.onSuccess();
+ mCallback.onSuccess(intentSender);
} catch (RemoteException e) {
e.rethrowAsRuntimeException();
}
@@ -63,11 +83,10 @@ public final class SaveCallback {
* the {@link SaveRequest} and call {@link #onSuccess()} instead.
*
* <p><b>Note:</b> The Android System displays an UI with the supplied error message; if
- * you prefer to show your own message, call {@link #onSuccess()} instead.
+ * 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.
- *
- * @throws RuntimeException if an error occurred while calling the Android System.
*/
public void onFailure(CharSequence message) {
assertNotCalled();