summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2017-05-31 20:43:14 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2017-05-31 20:43:20 +0000
commitd8d9758363524f454cfa1b39a460e461005c84a3 (patch)
treeb9ad7e8174b9aa8facb8839593439191a940a4af
parentfd5129b978dde02e3233696ea52d0d477afad417 (diff)
parent8697a31d3c32f212cee48b4d0576e8783c6c9d5f (diff)
Merge "Don't automatically autofill when manual request returned just 1 dataset." into oc-dev
-rw-r--r--core/java/android/view/autofill/AutofillPopupWindow.java6
-rw-r--r--services/autofill/java/com/android/server/autofill/Session.java44
-rw-r--r--services/autofill/java/com/android/server/autofill/ViewState.java9
-rw-r--r--services/autofill/java/com/android/server/autofill/ui/FillUi.java3
4 files changed, 23 insertions, 39 deletions
diff --git a/core/java/android/view/autofill/AutofillPopupWindow.java b/core/java/android/view/autofill/AutofillPopupWindow.java
index cd16a245c9b4..5f476380b1c3 100644
--- a/core/java/android/view/autofill/AutofillPopupWindow.java
+++ b/core/java/android/view/autofill/AutofillPopupWindow.java
@@ -16,6 +16,8 @@
package android.view.autofill;
+import static android.view.autofill.Helper.sVerbose;
+
import android.annotation.NonNull;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
@@ -186,6 +188,10 @@ public class AutofillPopupWindow extends PopupWindow {
@Override
public void showAsDropDown(View anchor, int xoff, int yoff, int gravity) {
+ if (sVerbose) {
+ Log.v(TAG, "showAsDropDown(): anchor=" + anchor + ", xoff=" + xoff + ", yoff=" + yoff
+ + ", isShowing(): " + isShowing());
+ }
if (isShowing()) {
return;
}
diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java
index 6a444c92079a..980a7d41200f 100644
--- a/services/autofill/java/com/android/server/autofill/Session.java
+++ b/services/autofill/java/com/android/server/autofill/Session.java
@@ -419,7 +419,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
notifyUnavailableToClient();
}
synchronized (mLock) {
- processResponseLocked(response);
+ processResponseLocked(response, requestFlags);
}
final LogMaker log = (new LogMaker(MetricsEvent.AUTOFILL_REQUEST))
@@ -1026,7 +1026,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
case ACTION_START_SESSION:
// View is triggering autofill.
mCurrentViewId = viewState.id;
- viewState.update(value, virtualBounds);
+ viewState.update(value, virtualBounds, flags);
viewState.setState(ViewState.STATE_STARTED_SESSION);
requestNewFillResponseLocked(flags);
break;
@@ -1065,7 +1065,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
}
// If the ViewState is ready to be displayed, onReady() will be called.
- viewState.update(value, virtualBounds);
+ viewState.update(value, virtualBounds, flags);
break;
case ACTION_VIEW_EXITED:
if (mCurrentViewId == viewState.id) {
@@ -1204,10 +1204,10 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
// Replace the old response
mResponses.put(newResponse.getRequestId(), newResponse);
// Now process the new response
- processResponseLocked(newResponse);
+ processResponseLocked(newResponse, 0);
}
- private void processResponseLocked(@NonNull FillResponse newResponse) {
+ private void processResponseLocked(@NonNull FillResponse newResponse, int flags) {
// Make sure we are hiding the UI which will be shown
// only if handling the current response requires it.
hideAllUiIfOwnedByMe();
@@ -1215,7 +1215,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
final int requestId = newResponse.getRequestId();
if (sVerbose) {
Slog.v(TAG, "processResponseLocked(): mCurrentViewId=" + mCurrentViewId
- + ", reqId=" + requestId + ", resp=" + newResponse);
+ + ",flags=" + flags + ", reqId=" + requestId + ", resp=" + newResponse);
}
if (mResponses == null) {
@@ -1231,21 +1231,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
return;
}
- final ArrayList<Dataset> datasets = newResponse.getDatasets();
-
- if (datasets != null && datasets.size() == 1) {
- // Check if it its a single response for a manual request, in which case it should
- // be automatically filled
- final FillContext context = getFillContextByRequestIdLocked(requestId);
- if (context != null && (context.getStructure().getFlags() & FLAG_MANUAL_REQUEST) != 0) {
- Slog.d(TAG, "autofilling manual request directly");
- autoFill(requestId, 0, datasets.get(0));
- return;
- }
- }
// Updates the UI, if necessary.
final ViewState currentView = mViewStates.get(mCurrentViewId);
- currentView.maybeCallOnFillReady();
+ currentView.maybeCallOnFillReady(flags);
}
/**
@@ -1331,20 +1319,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
return viewState;
}
- /**
- * Resets the given state from all existing views in the given dataset.
- */
- private void resetViewStatesLocked(@NonNull Dataset dataset, int state) {
- final ArrayList<AutofillId> ids = dataset.getFieldIds();
- for (int j = 0; j < ids.size(); j++) {
- final AutofillId id = ids.get(j);
- final ViewState viewState = mViewStates.get(id);
- if (viewState != null) {
- viewState.resetState(state);
- }
- }
- }
-
void autoFill(int requestId, int datasetIndex, Dataset dataset) {
synchronized (mLock) {
if (mDestroyed) {
@@ -1452,8 +1426,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
return;
}
try {
- if (sDebug) Slog.d(TAG, "autoFillApp(): the buck is on the app: " + dataset);
-
// Skip null values as a null values means no change
final int entryCount = dataset.getFieldIds().size();
final List<AutofillId> ids = new ArrayList<>(entryCount);
@@ -1480,6 +1452,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
if (waitingDatasetAuth) {
hideFillUiIfOwnedByMe();
}
+ if (sDebug) Slog.d(TAG, "autoFillApp(): the buck is on the app: " + dataset);
+
mClient.autofill(id, ids, values);
setViewStatesLocked(null, dataset, ViewState.STATE_AUTOFILLED, false);
}
diff --git a/services/autofill/java/com/android/server/autofill/ViewState.java b/services/autofill/java/com/android/server/autofill/ViewState.java
index 8a52c965345c..cd8f4a59526f 100644
--- a/services/autofill/java/com/android/server/autofill/ViewState.java
+++ b/services/autofill/java/com/android/server/autofill/ViewState.java
@@ -16,6 +16,7 @@
package com.android.server.autofill;
+import static android.service.autofill.FillRequest.FLAG_MANUAL_REQUEST;
import static com.android.server.autofill.Helper.sDebug;
import static com.android.server.autofill.Helper.sVerbose;
@@ -157,7 +158,7 @@ final class ViewState {
// TODO: refactor / rename / document this method (and maybeCallOnFillReady) to make it clear
// that it can change the value and update the UI; similarly, should replace code that
// directly sets mAutofillValue to use encapsulation.
- void update(@Nullable AutofillValue autofillValue, @Nullable Rect virtualBounds) {
+ void update(@Nullable AutofillValue autofillValue, @Nullable Rect virtualBounds, int flags) {
if (autofillValue != null) {
mCurrentValue = autofillValue;
}
@@ -165,7 +166,7 @@ final class ViewState {
mVirtualBounds = virtualBounds;
}
- maybeCallOnFillReady();
+ maybeCallOnFillReady(flags);
}
/**
@@ -173,8 +174,8 @@ final class ViewState {
* Listener#onFillReady(FillResponse, AutofillId, AutofillValue)} if the
* fill UI is ready to be displayed (i.e. when response and bounds are set).
*/
- void maybeCallOnFillReady() {
- if ((mState & STATE_AUTOFILLED) != 0) {
+ void maybeCallOnFillReady(int flags) {
+ if ((mState & STATE_AUTOFILLED) != 0 && (flags & FLAG_MANUAL_REQUEST) == 0) {
if (sDebug) Slog.d(TAG, "Ignoring UI for " + id + " on " + getStateAsString());
return;
}
diff --git a/services/autofill/java/com/android/server/autofill/ui/FillUi.java b/services/autofill/java/com/android/server/autofill/ui/FillUi.java
index d315b3d7b70f..d566d3d608b4 100644
--- a/services/autofill/java/com/android/server/autofill/ui/FillUi.java
+++ b/services/autofill/java/com/android/server/autofill/ui/FillUi.java
@@ -158,6 +158,7 @@ final class FillUi {
final RemoteViews presentation = dataset.getFieldPresentation(index);
final View view;
try {
+ if (sVerbose) Slog.v(TAG, "setting remote view for " + focusedViewId);
view = presentation.apply(context, null, interceptionHandler);
} catch (RuntimeException e) {
Slog.e(TAG, "Error inflating remote views", e);
@@ -203,6 +204,7 @@ final class FillUi {
return;
}
if (count <= 0) {
+ if (sDebug) Slog.d(TAG, "No dataset matches filter: " + mFilterText);
mCallback.requestHideFillUi();
} else {
if (updateContentSize()) {
@@ -382,6 +384,7 @@ final class FillUi {
* Shows the window.
*/
public void show(WindowManager.LayoutParams params) {
+ if (sVerbose) Slog.v(TAG, "show(): showing=" + mShowing + ", params="+ params);
try {
if (!mShowing) {
params.accessibilityTitle = mContentView.getContext()