Merge "Rollback dropdown or inline suggestions when cancel fill dialog" into tm-dev am: d2c53f65f6

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17937857

Change-Id: I101694e77692123c22144d0a94f0e3b258bbf2c7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2022-05-06 02:15:36 +00:00
committed by Automerger Merge Worker
3 changed files with 53 additions and 20 deletions

View File

@@ -1559,9 +1559,18 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
Slog.e(TAG, "Error sending input show up notification", e); Slog.e(TAG, "Error sending input show up notification", e);
} }
} }
}
// AutoFillUiCallback
@Override
public void requestFallbackFromFillDialog() {
setFillDialogDisabled();
synchronized (mLock) { synchronized (mLock) {
// stop to show fill dialog if (mCurrentViewId == null) {
mSessionFlags.mFillDialogDisabled = true; return;
}
final ViewState currentView = mViewStates.get(mCurrentViewId);
currentView.maybeCallOnFillReady(mFlags);
} }
} }
@@ -3208,6 +3217,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
return; return;
} }
final AutofillId[] ids = response.getFillDialogTriggerIds();
if (ids != null && ArrayUtils.contains(ids, filledId)) {
if (requestShowFillDialog(response, filledId, filterText, flags)) { if (requestShowFillDialog(response, filledId, filterText, flags)) {
synchronized (mLock) { synchronized (mLock) {
final ViewState currentView = mViewStates.get(mCurrentViewId); final ViewState currentView = mViewStates.get(mCurrentViewId);
@@ -3215,9 +3226,10 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
mService.logDatasetShown(id, mClientState, UI_TYPE_DIALOG); mService.logDatasetShown(id, mClientState, UI_TYPE_DIALOG);
} }
return; return;
} } else {
setFillDialogDisabled(); setFillDialogDisabled();
}
}
if (response.supportsInlineSuggestions()) { if (response.supportsInlineSuggestions()) {
synchronized (mLock) { synchronized (mLock) {
@@ -3324,15 +3336,11 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
return false; return false;
} }
final AutofillId[] ids = response.getFillDialogTriggerIds();
if (ids == null || !ArrayUtils.contains(ids, filledId)) {
return false;
}
final Drawable serviceIcon = getServiceIcon(); final Drawable serviceIcon = getServiceIcon();
getUiForShowing().showFillDialog(filledId, response, filterText, getUiForShowing().showFillDialog(filledId, response, filterText,
mService.getServicePackageName(), mComponentName, serviceIcon, this); mService.getServicePackageName(), mComponentName, serviceIcon, this,
id, mCompatMode);
return true; return true;
} }

View File

@@ -97,6 +97,7 @@ public final class AutoFillUI {
void dispatchUnhandledKey(AutofillId id, KeyEvent keyEvent); void dispatchUnhandledKey(AutofillId id, KeyEvent keyEvent);
void cancelSession(); void cancelSession();
void requestShowSoftInput(AutofillId id); void requestShowSoftInput(AutofillId id);
void requestFallbackFromFillDialog();
} }
public AutoFillUI(@NonNull Context context) { public AutoFillUI(@NonNull Context context) {
@@ -388,13 +389,19 @@ public final class AutoFillUI {
public void showFillDialog(@NonNull AutofillId focusedId, @NonNull FillResponse response, public void showFillDialog(@NonNull AutofillId focusedId, @NonNull FillResponse response,
@Nullable String filterText, @Nullable String servicePackageName, @Nullable String filterText, @Nullable String servicePackageName,
@NonNull ComponentName componentName, @Nullable Drawable serviceIcon, @NonNull ComponentName componentName, @Nullable Drawable serviceIcon,
@NonNull AutoFillUiCallback callback) { @NonNull AutoFillUiCallback callback, int sessionId, boolean compatMode) {
if (sVerbose) { if (sVerbose) {
Slog.v(TAG, "showFillDialog for " Slog.v(TAG, "showFillDialog for "
+ componentName.toShortString() + ": " + response); + 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(() -> { mHandler.post(() -> {
if (callback != mCallback) { if (callback != mCallback) {
@@ -406,6 +413,7 @@ public final class AutoFillUI {
mUiModeMgr.isNightMode(), new DialogFillUi.UiCallback() { mUiModeMgr.isNightMode(), new DialogFillUi.UiCallback() {
@Override @Override
public void onResponsePicked(FillResponse response) { public void onResponsePicked(FillResponse response) {
log(MetricsEvent.TYPE_DETAIL);
hideFillDialogUiThread(callback); hideFillDialogUiThread(callback);
if (mCallback != null) { if (mCallback != null) {
mCallback.authenticate(response.getRequestId(), mCallback.authenticate(response.getRequestId(),
@@ -417,6 +425,7 @@ public final class AutoFillUI {
@Override @Override
public void onDatasetPicked(Dataset dataset) { public void onDatasetPicked(Dataset dataset) {
log(MetricsEvent.TYPE_ACTION);
hideFillDialogUiThread(callback); hideFillDialogUiThread(callback);
if (mCallback != null) { if (mCallback != null) {
final int datasetIndex = response.getDatasets().indexOf(dataset); final int datasetIndex = response.getDatasets().indexOf(dataset);
@@ -426,15 +435,29 @@ public final class AutoFillUI {
} }
@Override @Override
public void onCanceled() { public void onDismissed() {
log(MetricsEvent.TYPE_DISMISS);
hideFillDialogUiThread(callback); hideFillDialogUiThread(callback);
callback.requestShowSoftInput(focusedId); callback.requestShowSoftInput(focusedId);
} }
@Override
public void onCanceled() {
log(MetricsEvent.TYPE_CLOSE);
hideFillDialogUiThread(callback);
callback.requestShowSoftInput(focusedId);
callback.requestFallbackFromFillDialog();
}
@Override @Override
public void startIntentSender(IntentSender intentSender) { public void startIntentSender(IntentSender intentSender) {
mCallback.startIntentSenderAndFinishSession(intentSender); mCallback.startIntentSenderAndFinishSession(intentSender);
} }
private void log(int type) {
log.setType(type);
mMetricsLogger.write(log);
}
}); });
}); });
} }

View File

@@ -81,6 +81,7 @@ final class DialogFillUi {
interface UiCallback { interface UiCallback {
void onResponsePicked(@NonNull FillResponse response); void onResponsePicked(@NonNull FillResponse response);
void onDatasetPicked(@NonNull Dataset dataset); void onDatasetPicked(@NonNull Dataset dataset);
void onDismissed();
void onCanceled(); void onCanceled();
void startIntentSender(IntentSender intentSender); void startIntentSender(IntentSender intentSender);
} }
@@ -144,6 +145,7 @@ final class DialogFillUi {
mDialog = new Dialog(mContext, mThemeId); mDialog = new Dialog(mContext, mThemeId);
mDialog.setContentView(decor); mDialog.setContentView(decor);
setDialogParamsAsBottomSheet(); setDialogParamsAsBottomSheet();
mDialog.setOnCancelListener((d) -> mCallback.onCanceled());
show(); show();
} }
@@ -220,7 +222,7 @@ final class DialogFillUi {
final TextView noButton = decor.findViewById(R.id.autofill_dialog_no); final TextView noButton = decor.findViewById(R.id.autofill_dialog_no);
// set "No thinks" by default // set "No thinks" by default
noButton.setText(R.string.autofill_save_no); 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) { private void setContinueButton(View decor, View.OnClickListener listener) {