Merge "Adds FillResponse extra to passed to authentication intent." into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
fb4a74f26b
@@ -47674,6 +47674,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
|
||||
}
|
||||
|
||||
|
||||
@@ -51133,6 +51133,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
|
||||
}
|
||||
|
||||
|
||||
@@ -48057,6 +48057,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
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user