Adds FillResponse extra to passed to authentication intent.
Test: CtsAutoFillServiceTestCases (with new test) pass
Fixes: 36603378
Change-Id: I3d04a656e50b2b3665405f6c1891ad0379a54ea6
diff --git a/api/current.txt b/api/current.txt
index 058743a..425e5c3 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -47670,6 +47670,7 @@
method public void unregisterCallback(android.view.autofill.AutofillManager.AutofillCallback);
field public static final java.lang.String EXTRA_ASSIST_STRUCTURE = "android.view.autofill.extra.ASSIST_STRUCTURE";
field public static final java.lang.String EXTRA_AUTHENTICATION_RESULT = "android.view.autofill.extra.AUTHENTICATION_RESULT";
+ field public static final java.lang.String EXTRA_DATA_EXTRAS = "android.view.autofill.extra.DATA_EXTRAS";
field public static final int FLAG_MANUAL_REQUEST = 1; // 0x1
}
diff --git a/api/system-current.txt b/api/system-current.txt
index c1e3893..ee7df5f 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -51128,6 +51128,7 @@
method public void unregisterCallback(android.view.autofill.AutofillManager.AutofillCallback);
field public static final java.lang.String EXTRA_ASSIST_STRUCTURE = "android.view.autofill.extra.ASSIST_STRUCTURE";
field public static final java.lang.String EXTRA_AUTHENTICATION_RESULT = "android.view.autofill.extra.AUTHENTICATION_RESULT";
+ field public static final java.lang.String EXTRA_DATA_EXTRAS = "android.view.autofill.extra.DATA_EXTRAS";
field public static final int FLAG_MANUAL_REQUEST = 1; // 0x1
}
diff --git a/api/test-current.txt b/api/test-current.txt
index fae1436..62e5482 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -48053,6 +48053,7 @@
method public void unregisterCallback(android.view.autofill.AutofillManager.AutofillCallback);
field public static final java.lang.String EXTRA_ASSIST_STRUCTURE = "android.view.autofill.extra.ASSIST_STRUCTURE";
field public static final java.lang.String EXTRA_AUTHENTICATION_RESULT = "android.view.autofill.extra.AUTHENTICATION_RESULT";
+ field public static final java.lang.String EXTRA_DATA_EXTRAS = "android.view.autofill.extra.DATA_EXTRAS";
field public static final int FLAG_MANUAL_REQUEST = 1; // 0x1
}
diff --git a/core/java/android/view/autofill/AutofillManager.java b/core/java/android/view/autofill/AutofillManager.java
index b4d2c6b..3cf6ae9 100644
--- a/core/java/android/view/autofill/AutofillManager.java
+++ b/core/java/android/view/autofill/AutofillManager.java
@@ -56,9 +56,9 @@
/**
* Intent extra: The assist structure which captures the filled screen.
+ *
* <p>
* Type: {@link android.app.assist.AssistStructure}
- * </p>
*/
public static final String EXTRA_ASSIST_STRUCTURE =
"android.view.autofill.extra.ASSIST_STRUCTURE";
@@ -72,11 +72,25 @@
* <p>
* Type: {@link android.service.autofill.FillResponse} or a
* {@link android.service.autofill.Dataset}
- * </p>
*/
public static final String EXTRA_AUTHENTICATION_RESULT =
"android.view.autofill.extra.AUTHENTICATION_RESULT";
+ /**
+ * Intent extra: The optional extras provided by the
+ * {@link android.service.autofill.AutofillService}.
+ *
+ * <p>For example, when the service responds to a {@link
+ * android.service.autofill.FillCallback#onSuccess(android.service.autofill.FillResponse)} with
+ * a {@code FillResponse} that requires authentication, the Intent that launches the
+ * service authentication will contain the Bundle set by
+ * {@link android.service.autofill.FillResponse.Builder#setExtras(Bundle)} on this extra.
+ *
+ * <p>
+ * Type: {@link android.os.Bundle}
+ */
+ public static final String EXTRA_DATA_EXTRAS = "android.view.autofill.extra.DATA_EXTRAS";
+
// Public flags start from the lowest bit
/**
* Indicates autofill was explicitly requested by the user.
diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java
index 1093e9e..9285027 100644
--- a/services/autofill/java/com/android/server/autofill/Session.java
+++ b/services/autofill/java/com/android/server/autofill/Session.java
@@ -244,10 +244,10 @@
// FillServiceCallbacks
@Override
- public void authenticate(IntentSender intent) {
+ public void authenticate(IntentSender intent, Bundle extras) {
final Intent fillInIntent;
synchronized (mLock) {
- fillInIntent = createAuthFillInIntent(mStructure);
+ fillInIntent = createAuthFillInIntent(mStructure, extras);
}
mHandlerCaller.getHandler().post(() -> startAuthentication(intent, fillInIntent));
}
@@ -313,7 +313,7 @@
if (mCurrentResponse == null || data == null) {
removeSelf();
} else {
- Parcelable result = data.getParcelable(
+ final Parcelable result = data.getParcelable(
AutofillManager.EXTRA_AUTHENTICATION_RESULT);
if (result instanceof FillResponse) {
mMetricsLogger.action(MetricsEvent.AUTOFILL_AUTHENTICATED, mPackageName);
@@ -321,7 +321,7 @@
mCurrentResponse = (FillResponse) result;
processResponseLocked(mCurrentResponse);
} else if (result instanceof Dataset) {
- Dataset dataset = (Dataset) result;
+ final Dataset dataset = (Dataset) result;
final int index = mCurrentResponse.getDatasets().indexOf(mAutoFilledDataset);
if (index >= 0) {
mCurrentResponse.getDatasets().set(index, dataset);
@@ -614,7 +614,8 @@
if (mCurrentResponse.getAuthentication() != null) {
// Handle authentication.
- final Intent fillInIntent = createAuthFillInIntent(mStructure);
+ final Intent fillInIntent = createAuthFillInIntent(mStructure,
+ mCurrentResponse.getExtras());
mCurrentViewState.setResponse(mCurrentResponse, fillInIntent);
return;
}
@@ -640,7 +641,7 @@
}
// ...or handle authentication.
- Intent fillInIntent = createAuthFillInIntent(mStructure);
+ final Intent fillInIntent = createAuthFillInIntent(mStructure, null);
startAuthentication(dataset.getAuthentication(), fillInIntent);
}
}
@@ -649,9 +650,12 @@
return mService.getServiceName();
}
- private Intent createAuthFillInIntent(AssistStructure structure) {
- Intent fillInIntent = new Intent();
+ private Intent createAuthFillInIntent(AssistStructure structure, Bundle extras) {
+ final Intent fillInIntent = new Intent();
fillInIntent.putExtra(AutofillManager.EXTRA_ASSIST_STRUCTURE, structure);
+ if (extras != null) {
+ fillInIntent.putExtra(AutofillManager.EXTRA_DATA_EXTRAS, extras);
+ }
return fillInIntent;
}
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 2555cee..832ff9a 100644
--- a/services/autofill/java/com/android/server/autofill/ui/AutoFillUI.java
+++ b/services/autofill/java/com/android/server/autofill/ui/AutoFillUI.java
@@ -22,6 +22,7 @@
import android.content.Context;
import android.content.IntentSender;
import android.metrics.LogMaker;
+import android.os.Bundle;
import android.os.Handler;
import android.service.autofill.Dataset;
import android.service.autofill.FillResponse;
@@ -63,7 +64,7 @@
private final MetricsLogger mMetricsLogger = new MetricsLogger();
public interface AutoFillUiCallback {
- void authenticate(@NonNull IntentSender intent);
+ void authenticate(@NonNull IntentSender intent, @Nullable Bundle extras);
void fill(@NonNull Dataset dataset);
void save();
void cancelSave();
@@ -156,7 +157,7 @@
log.setType(MetricsProto.MetricsEvent.TYPE_DETAIL);
hideFillUiUiThread();
if (mCallback != null) {
- mCallback.authenticate(response.getAuthentication());
+ mCallback.authenticate(response.getAuthentication(), response.getExtras());
}
}