diff options
| author | 2017-03-29 15:09:54 -0700 | |
|---|---|---|
| committer | 2017-03-29 15:20:29 -0700 | |
| commit | 7320ca9f99bb582dd7cb8199cedae30f8b1367a4 (patch) | |
| tree | 4851843d8f0340694f97bb22345466b9610d1fc8 | |
| parent | 94696c5ac52b188ee3d0c01443e61ad18e25cd6b (diff) | |
Adds FillResponse extra to passed to authentication intent.
Test: CtsAutoFillServiceTestCases (with new test) pass
Fixes: 36603378
Change-Id: I3d04a656e50b2b3665405f6c1891ad0379a54ea6
| -rw-r--r-- | api/current.txt | 1 | ||||
| -rw-r--r-- | api/system-current.txt | 1 | ||||
| -rw-r--r-- | api/test-current.txt | 1 | ||||
| -rw-r--r-- | core/java/android/view/autofill/AutofillManager.java | 18 | ||||
| -rw-r--r-- | services/autofill/java/com/android/server/autofill/Session.java | 20 | ||||
| -rw-r--r-- | services/autofill/java/com/android/server/autofill/ui/AutoFillUI.java | 5 |
6 files changed, 34 insertions, 12 deletions
diff --git a/api/current.txt b/api/current.txt index 058743a926b8..425e5c390d6b 100644 --- a/api/current.txt +++ b/api/current.txt @@ -47670,6 +47670,7 @@ package android.view.autofill { 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 c1e3893e9138..ee7df5f23099 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -51128,6 +51128,7 @@ package android.view.autofill { 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 fae1436b39f5..62e5482551b1 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -48053,6 +48053,7 @@ package android.view.autofill { 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 b4d2c6bfe016..3cf6ae9e51c9 100644 --- a/core/java/android/view/autofill/AutofillManager.java +++ b/core/java/android/view/autofill/AutofillManager.java @@ -56,9 +56,9 @@ public final class AutofillManager { /** * 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 @@ public final class AutofillManager { * <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 1093e9e27d93..928502761833 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 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState // 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 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState 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 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState 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 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState 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 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } // ...or handle authentication. - Intent fillInIntent = createAuthFillInIntent(mStructure); + final Intent fillInIntent = createAuthFillInIntent(mStructure, null); startAuthentication(dataset.getAuthentication(), fillInIntent); } } @@ -649,9 +650,12 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState 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 2555cee55aad..832ff9a4435c 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.annotation.Nullable; 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 @@ public final class AutoFillUI { 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 @@ public final class AutoFillUI { log.setType(MetricsProto.MetricsEvent.TYPE_DETAIL); hideFillUiUiThread(); if (mCallback != null) { - mCallback.authenticate(response.getAuthentication()); + mCallback.authenticate(response.getAuthentication(), response.getExtras()); } } |