Rollback dropdown or inline suggestions when cancel fill dialog
When tap outside the fill dialog to cancel, rollback to the dropdown or inline suggestions. Add more log for show, select, dismiss and close actions on the fill dialog. Bug: 227378451 Test: atest android.autofillservice.cts.dialog.LoginActivityTest Change-Id: Ibd844a4729f67ad2d55fc5e027950a11ab48bf59
This commit is contained in:
@@ -1558,9 +1558,18 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
||||
Slog.e(TAG, "Error sending input show up notification", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AutoFillUiCallback
|
||||
@Override
|
||||
public void requestFallbackFromFillDialog() {
|
||||
setFillDialogDisabled();
|
||||
synchronized (mLock) {
|
||||
// stop to show fill dialog
|
||||
mSessionFlags.mFillDialogDisabled = true;
|
||||
if (mCurrentViewId == null) {
|
||||
return;
|
||||
}
|
||||
final ViewState currentView = mViewStates.get(mCurrentViewId);
|
||||
currentView.maybeCallOnFillReady(mFlags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3207,17 +3216,20 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
||||
return;
|
||||
}
|
||||
|
||||
if (requestShowFillDialog(response, filledId, filterText, flags)) {
|
||||
synchronized (mLock) {
|
||||
final ViewState currentView = mViewStates.get(mCurrentViewId);
|
||||
currentView.setState(ViewState.STATE_FILL_DIALOG_SHOWN);
|
||||
mService.logDatasetShown(id, mClientState, UI_TYPE_DIALOG);
|
||||
final AutofillId[] ids = response.getFillDialogTriggerIds();
|
||||
if (ids != null && ArrayUtils.contains(ids, filledId)) {
|
||||
if (requestShowFillDialog(response, filledId, filterText, flags)) {
|
||||
synchronized (mLock) {
|
||||
final ViewState currentView = mViewStates.get(mCurrentViewId);
|
||||
currentView.setState(ViewState.STATE_FILL_DIALOG_SHOWN);
|
||||
mService.logDatasetShown(id, mClientState, UI_TYPE_DIALOG);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
setFillDialogDisabled();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
setFillDialogDisabled();
|
||||
|
||||
if (response.supportsInlineSuggestions()) {
|
||||
synchronized (mLock) {
|
||||
if (requestShowInlineSuggestionsLocked(response, filterText)) {
|
||||
@@ -3323,15 +3335,11 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
||||
return false;
|
||||
}
|
||||
|
||||
final AutofillId[] ids = response.getFillDialogTriggerIds();
|
||||
if (ids == null || !ArrayUtils.contains(ids, filledId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Drawable serviceIcon = getServiceIcon();
|
||||
|
||||
getUiForShowing().showFillDialog(filledId, response, filterText,
|
||||
mService.getServicePackageName(), mComponentName, serviceIcon, this);
|
||||
mService.getServicePackageName(), mComponentName, serviceIcon, this,
|
||||
id, mCompatMode);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,6 +92,7 @@ public final class AutoFillUI {
|
||||
void dispatchUnhandledKey(AutofillId id, KeyEvent keyEvent);
|
||||
void cancelSession();
|
||||
void requestShowSoftInput(AutofillId id);
|
||||
void requestFallbackFromFillDialog();
|
||||
}
|
||||
|
||||
public AutoFillUI(@NonNull Context context) {
|
||||
@@ -382,13 +383,19 @@ public final class AutoFillUI {
|
||||
public void showFillDialog(@NonNull AutofillId focusedId, @NonNull FillResponse response,
|
||||
@Nullable String filterText, @Nullable String servicePackageName,
|
||||
@NonNull ComponentName componentName, @Nullable Drawable serviceIcon,
|
||||
@NonNull AutoFillUiCallback callback) {
|
||||
@NonNull AutoFillUiCallback callback, int sessionId, boolean compatMode) {
|
||||
if (sVerbose) {
|
||||
Slog.v(TAG, "showFillDialog for "
|
||||
+ componentName.toShortString() + ": " + response);
|
||||
}
|
||||
|
||||
// TODO: enable LogMaker
|
||||
final LogMaker log = Helper
|
||||
.newLogMaker(MetricsEvent.AUTOFILL_FILL_UI, componentName, servicePackageName,
|
||||
sessionId, compatMode)
|
||||
.addTaggedData(MetricsEvent.FIELD_AUTOFILL_FILTERTEXT_LEN,
|
||||
filterText == null ? 0 : filterText.length())
|
||||
.addTaggedData(MetricsEvent.FIELD_AUTOFILL_NUM_DATASETS,
|
||||
response.getDatasets() == null ? 0 : response.getDatasets().size());
|
||||
|
||||
mHandler.post(() -> {
|
||||
if (callback != mCallback) {
|
||||
@@ -400,6 +407,7 @@ public final class AutoFillUI {
|
||||
mUiModeMgr.isNightMode(), new DialogFillUi.UiCallback() {
|
||||
@Override
|
||||
public void onResponsePicked(FillResponse response) {
|
||||
log(MetricsEvent.TYPE_DETAIL);
|
||||
hideFillDialogUiThread(callback);
|
||||
if (mCallback != null) {
|
||||
mCallback.authenticate(response.getRequestId(),
|
||||
@@ -411,6 +419,7 @@ public final class AutoFillUI {
|
||||
|
||||
@Override
|
||||
public void onDatasetPicked(Dataset dataset) {
|
||||
log(MetricsEvent.TYPE_ACTION);
|
||||
hideFillDialogUiThread(callback);
|
||||
if (mCallback != null) {
|
||||
final int datasetIndex = response.getDatasets().indexOf(dataset);
|
||||
@@ -419,15 +428,29 @@ public final class AutoFillUI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCanceled() {
|
||||
public void onDismissed() {
|
||||
log(MetricsEvent.TYPE_DISMISS);
|
||||
hideFillDialogUiThread(callback);
|
||||
callback.requestShowSoftInput(focusedId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCanceled() {
|
||||
log(MetricsEvent.TYPE_CLOSE);
|
||||
hideFillDialogUiThread(callback);
|
||||
callback.requestShowSoftInput(focusedId);
|
||||
callback.requestFallbackFromFillDialog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startIntentSender(IntentSender intentSender) {
|
||||
mCallback.startIntentSenderAndFinishSession(intentSender);
|
||||
}
|
||||
|
||||
private void log(int type) {
|
||||
log.setType(type);
|
||||
mMetricsLogger.write(log);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -81,6 +81,7 @@ final class DialogFillUi {
|
||||
interface UiCallback {
|
||||
void onResponsePicked(@NonNull FillResponse response);
|
||||
void onDatasetPicked(@NonNull Dataset dataset);
|
||||
void onDismissed();
|
||||
void onCanceled();
|
||||
void startIntentSender(IntentSender intentSender);
|
||||
}
|
||||
@@ -144,6 +145,7 @@ final class DialogFillUi {
|
||||
mDialog = new Dialog(mContext, mThemeId);
|
||||
mDialog.setContentView(decor);
|
||||
setDialogParamsAsBottomSheet();
|
||||
mDialog.setOnCancelListener((d) -> mCallback.onCanceled());
|
||||
|
||||
show();
|
||||
}
|
||||
@@ -220,7 +222,7 @@ final class DialogFillUi {
|
||||
final TextView noButton = decor.findViewById(R.id.autofill_dialog_no);
|
||||
// set "No thinks" by default
|
||||
noButton.setText(R.string.autofill_save_no);
|
||||
noButton.setOnClickListener((v) -> mCallback.onCanceled());
|
||||
noButton.setOnClickListener((v) -> mCallback.onDismissed());
|
||||
}
|
||||
|
||||
private void setContinueButton(View decor, View.OnClickListener listener) {
|
||||
|
||||
Reference in New Issue
Block a user