Added a new AutofillCallback.EVENT_INPUT_UNAVAILABLE event.

This event is called when:

- After notifyViewEntered() when autofill is disabled.
- After service returns an "empty" FillResponse to FillCallback.onSuccess().

BUG: 36056207

Test: LoginActivityTest.testAutofillCallbackDisabled
Test: LoginActivityTest.testAutofillCallbackNoDatasets
Test: VirtualContainerActivityTest.testAutofillCallbackDisabled
Test: VirtualContainerActivityTest.testAutofillCallbackNoDatasets

Change-Id: I7b8636473f738bf600aa96b28c77827b2cc78815
This commit is contained in:
Felipe Leme
2017-03-15 12:33:01 -07:00
parent e6ccc3e816
commit 24aae15218
5 changed files with 39 additions and 1 deletions

View File

@@ -47604,6 +47604,7 @@ package android.view.autofill {
method public void onAutofillEventVirtual(android.view.View, int, int);
field public static final int EVENT_INPUT_HIDDEN = 2; // 0x2
field public static final int EVENT_INPUT_SHOWN = 1; // 0x1
field public static final int EVENT_INPUT_UNAVAILABLE = 3; // 0x3
}
public final class AutofillValue implements android.os.Parcelable {

View File

@@ -51070,6 +51070,7 @@ package android.view.autofill {
method public void onAutofillEventVirtual(android.view.View, int, int);
field public static final int EVENT_INPUT_HIDDEN = 2; // 0x2
field public static final int EVENT_INPUT_SHOWN = 1; // 0x1
field public static final int EVENT_INPUT_UNAVAILABLE = 3; // 0x3
}
public final class AutofillValue implements android.os.Parcelable {

View File

@@ -47973,6 +47973,7 @@ package android.view.autofill {
method public void onAutofillEventVirtual(android.view.View, int, int);
field public static final int EVENT_INPUT_HIDDEN = 2; // 0x2
field public static final int EVENT_INPUT_SHOWN = 1; // 0x1
field public static final int EVENT_INPUT_UNAVAILABLE = 3; // 0x3
}
public final class AutofillValue implements android.os.Parcelable {

View File

@@ -196,6 +196,9 @@ public final class AutofillManager {
ensureServiceClientAddedIfNeeded();
if (!mEnabled) {
if (mCallback != null) {
mCallback.onAutofillEvent(view, AutofillCallback.EVENT_INPUT_UNAVAILABLE);
}
return;
}
@@ -241,6 +244,10 @@ public final class AutofillManager {
ensureServiceClientAddedIfNeeded();
if (!mEnabled) {
if (mCallback != null) {
mCallback.onAutofillEventVirtual(view, childId,
AutofillCallback.EVENT_INPUT_UNAVAILABLE);
}
return;
}
@@ -538,6 +545,15 @@ public final class AutofillManager {
*/
public static final int EVENT_INPUT_HIDDEN = 2;
/**
* The auto-fill input UI affordance associated with the view won't be shown because
* autofill is not available.
*
* <p>If the view provides its own auto-complete UI affordance but was not displaying it
* to avoid flickering, it could shown it upon receiving this event.
*/
public static final int EVENT_INPUT_UNAVAILABLE = 3;
/**
* Called after a change in the autofill state associated with a view.
*

View File

@@ -69,6 +69,8 @@ import android.view.autofill.AutofillId;
import android.view.autofill.AutofillManager;
import android.view.autofill.AutofillValue;
import android.view.autofill.IAutoFillManagerClient;
import android.view.autofill.AutofillManager.AutofillCallback;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto;
@@ -674,9 +676,17 @@ final class AutofillManagerServiceImpl {
public void onFillRequestSuccess(@Nullable FillResponse response,
@NonNull String servicePackageName) {
if (response == null) {
// Nothing to be done, but need to notify client.
notifyUnavailableToClient();
removeSelf();
return;
}
if ((response.getDatasets() == null || response.getDatasets().isEmpty())
&& response.getAuthentication() == null) {
// Response is "empty" from an UI point of view, need to notify client.
notifyUnavailableToClient();
}
synchronized (mLock) {
processResponseLocked(response);
}
@@ -1091,6 +1101,15 @@ final class AutofillManagerServiceImpl {
}
}
private void notifyUnavailableToClient() {
if (mCurrentViewState == null) {
// TODO(b/33197203): temporary sanity check; should never happen
Slog.w(TAG, "notifyUnavailable(): mCurrentViewState is null");
return;
}
notifyChangeToClient(mCurrentViewState.mId, AutofillCallback.EVENT_INPUT_UNAVAILABLE);
}
private void processResponseLocked(FillResponse response) {
if (DEBUG) {
Slog.d(TAG, "processResponseLocked(auth=" + response.getAuthentication()
@@ -1099,7 +1118,7 @@ final class AutofillManagerServiceImpl {
if (mCurrentViewState == null) {
// TODO(b/33197203): temporary sanity check; should never happen
Slog.w(TAG, "processResponseLocked(): mCurrentResponse is null");
Slog.w(TAG, "processResponseLocked(): mCurrentViewState is null");
return;
}