Merge "Temporary fix to disable augmented autofill requests coming from password fields." into rvc-dev am: f5589a71e0 am: 09822e4df1 am: 687787a9c9

Change-Id: I884bfd01d25923e4af7a258d100141ac47c1950b
This commit is contained in:
Automerger Merge Worker
2020-03-11 22:22:36 +00:00
4 changed files with 59 additions and 13 deletions

View File

@@ -77,6 +77,15 @@ public final class FillRequest implements Parcelable {
*/ */
public static final @RequestFlags int FLAG_COMPATIBILITY_MODE_REQUEST = 0x2; public static final @RequestFlags int FLAG_COMPATIBILITY_MODE_REQUEST = 0x2;
/**
* Indicates the request came from a password field.
*
* (TODO: b/141703197) Temporary fix for augmented autofill showing passwords.
*
* @hide
*/
public static final @RequestFlags int FLAG_PASSWORD_INPUT_TYPE = 0x4;
/** @hide */ /** @hide */
public static final int INVALID_REQUEST_ID = Integer.MIN_VALUE; public static final int INVALID_REQUEST_ID = Integer.MIN_VALUE;
@@ -149,7 +158,8 @@ public final class FillRequest implements Parcelable {
/** @hide */ /** @hide */
@IntDef(flag = true, prefix = "FLAG_", value = { @IntDef(flag = true, prefix = "FLAG_", value = {
FLAG_MANUAL_REQUEST, FLAG_MANUAL_REQUEST,
FLAG_COMPATIBILITY_MODE_REQUEST FLAG_COMPATIBILITY_MODE_REQUEST,
FLAG_PASSWORD_INPUT_TYPE
}) })
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@DataClass.Generated.Member @DataClass.Generated.Member
@@ -169,6 +179,8 @@ public final class FillRequest implements Parcelable {
return "FLAG_MANUAL_REQUEST"; return "FLAG_MANUAL_REQUEST";
case FLAG_COMPATIBILITY_MODE_REQUEST: case FLAG_COMPATIBILITY_MODE_REQUEST:
return "FLAG_COMPATIBILITY_MODE_REQUEST"; return "FLAG_COMPATIBILITY_MODE_REQUEST";
case FLAG_PASSWORD_INPUT_TYPE:
return "FLAG_PASSWORD_INPUT_TYPE";
default: return Integer.toHexString(value); default: return Integer.toHexString(value);
} }
} }
@@ -223,7 +235,8 @@ public final class FillRequest implements Parcelable {
Preconditions.checkFlagsArgument( Preconditions.checkFlagsArgument(
mFlags, mFlags,
FLAG_MANUAL_REQUEST FLAG_MANUAL_REQUEST
| FLAG_COMPATIBILITY_MODE_REQUEST); | FLAG_COMPATIBILITY_MODE_REQUEST
| FLAG_PASSWORD_INPUT_TYPE);
this.mInlineSuggestionsRequest = inlineSuggestionsRequest; this.mInlineSuggestionsRequest = inlineSuggestionsRequest;
onConstructed(); onConstructed();
@@ -352,7 +365,8 @@ public final class FillRequest implements Parcelable {
Preconditions.checkFlagsArgument( Preconditions.checkFlagsArgument(
mFlags, mFlags,
FLAG_MANUAL_REQUEST FLAG_MANUAL_REQUEST
| FLAG_COMPATIBILITY_MODE_REQUEST); | FLAG_COMPATIBILITY_MODE_REQUEST
| FLAG_PASSWORD_INPUT_TYPE);
this.mInlineSuggestionsRequest = inlineSuggestionsRequest; this.mInlineSuggestionsRequest = inlineSuggestionsRequest;
onConstructed(); onConstructed();
@@ -373,10 +387,10 @@ public final class FillRequest implements Parcelable {
}; };
@DataClass.Generated( @DataClass.Generated(
time = 1575928271155L, time = 1583196707026L,
codegenVersion = "1.0.14", codegenVersion = "1.0.14",
sourceFile = "frameworks/base/core/java/android/service/autofill/FillRequest.java", sourceFile = "frameworks/base/core/java/android/service/autofill/FillRequest.java",
inputSignatures = "public static final @android.service.autofill.FillRequest.RequestFlags int FLAG_MANUAL_REQUEST\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_COMPATIBILITY_MODE_REQUEST\npublic static final int INVALID_REQUEST_ID\nprivate final int mId\nprivate final @android.annotation.NonNull java.util.List<android.service.autofill.FillContext> mFillContexts\nprivate final @android.annotation.Nullable android.os.Bundle mClientState\nprivate final @android.service.autofill.FillRequest.RequestFlags int mFlags\nprivate final @android.annotation.Nullable android.view.inputmethod.InlineSuggestionsRequest mInlineSuggestionsRequest\nprivate void onConstructed()\nclass FillRequest extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genHiddenConstructor=true, genHiddenConstDefs=true)") inputSignatures = "public static final @android.service.autofill.FillRequest.RequestFlags int FLAG_MANUAL_REQUEST\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_COMPATIBILITY_MODE_REQUEST\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_PASSWORD_INPUT_TYPE\npublic static final int INVALID_REQUEST_ID\nprivate final int mId\nprivate final @android.annotation.NonNull java.util.List<android.service.autofill.FillContext> mFillContexts\nprivate final @android.annotation.Nullable android.os.Bundle mClientState\nprivate final @android.service.autofill.FillRequest.RequestFlags int mFlags\nprivate final @android.annotation.Nullable android.view.inputmethod.InlineSuggestionsRequest mInlineSuggestionsRequest\nprivate void onConstructed()\nclass FillRequest extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genHiddenConstructor=true, genHiddenConstDefs=true)")
@Deprecated @Deprecated
private void __metadata() {} private void __metadata() {}

View File

@@ -17,6 +17,7 @@
package android.view.autofill; package android.view.autofill;
import static android.service.autofill.FillRequest.FLAG_MANUAL_REQUEST; import static android.service.autofill.FillRequest.FLAG_MANUAL_REQUEST;
import static android.service.autofill.FillRequest.FLAG_PASSWORD_INPUT_TYPE;
import static android.view.autofill.Helper.sDebug; import static android.view.autofill.Helper.sDebug;
import static android.view.autofill.Helper.sVerbose; import static android.view.autofill.Helper.sVerbose;
import static android.view.autofill.Helper.toList; import static android.view.autofill.Helper.toList;
@@ -63,6 +64,7 @@ import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeProvider; import android.view.accessibility.AccessibilityNodeProvider;
import android.view.accessibility.AccessibilityWindowInfo; import android.view.accessibility.AccessibilityWindowInfo;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView;
import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.GuardedBy;
import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.MetricsLogger;
@@ -983,6 +985,10 @@ public final class AutofillManager {
if (!isClientDisablingEnterExitEvent()) { if (!isClientDisablingEnterExitEvent()) {
final AutofillValue value = view.getAutofillValue(); final AutofillValue value = view.getAutofillValue();
if (view instanceof TextView && ((TextView) view).isAnyPasswordInputType()) {
flags |= FLAG_PASSWORD_INPUT_TYPE;
}
if (!isActiveLocked()) { if (!isActiveLocked()) {
// Starts new session. // Starts new session.
startSessionLocked(id, null, value, flags); startSessionLocked(id, null, value, flags);
@@ -1149,6 +1155,10 @@ public final class AutofillManager {
} else { } else {
// don't notify entered when Activity is already in background // don't notify entered when Activity is already in background
if (!isClientDisablingEnterExitEvent()) { if (!isClientDisablingEnterExitEvent()) {
if (view instanceof TextView && ((TextView) view).isAnyPasswordInputType()) {
flags |= FLAG_PASSWORD_INPUT_TYPE;
}
if (!isActiveLocked()) { if (!isActiveLocked()) {
// Starts new session. // Starts new session.
startSessionLocked(id, bounds, null, flags); startSessionLocked(id, bounds, null, flags);

View File

@@ -6607,6 +6607,16 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
return mTransformation instanceof PasswordTransformationMethod; return mTransformation instanceof PasswordTransformationMethod;
} }
/**
* Returns true if the current inputType is any type of password.
*
* @hide
*/
public boolean isAnyPasswordInputType() {
final int inputType = getInputType();
return isPasswordInputType(inputType) || isVisiblePasswordInputType(inputType);
}
static boolean isPasswordInputType(int inputType) { static boolean isPasswordInputType(int inputType) {
final int variation = final int variation =
inputType & (EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_MASK_VARIATION); inputType & (EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_MASK_VARIATION);

View File

@@ -18,6 +18,7 @@ package com.android.server.autofill;
import static android.service.autofill.AutofillFieldClassificationService.EXTRA_SCORES; import static android.service.autofill.AutofillFieldClassificationService.EXTRA_SCORES;
import static android.service.autofill.FillRequest.FLAG_MANUAL_REQUEST; import static android.service.autofill.FillRequest.FLAG_MANUAL_REQUEST;
import static android.service.autofill.FillRequest.FLAG_PASSWORD_INPUT_TYPE;
import static android.service.autofill.FillRequest.INVALID_REQUEST_ID; import static android.service.autofill.FillRequest.INVALID_REQUEST_ID;
import static android.view.autofill.AutofillManager.ACTION_RESPONSE_EXPIRED; import static android.view.autofill.AutofillManager.ACTION_RESPONSE_EXPIRED;
import static android.view.autofill.AutofillManager.ACTION_START_SESSION; import static android.view.autofill.AutofillManager.ACTION_START_SESSION;
@@ -624,7 +625,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
+ ", flags=" + flags + ")"); + ", flags=" + flags + ")");
} }
mForAugmentedAutofillOnly = true; mForAugmentedAutofillOnly = true;
triggerAugmentedAutofillLocked(); triggerAugmentedAutofillLocked(flags);
return; return;
} }
@@ -834,7 +835,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
} }
// Although "standard" autofill is disabled, it might still trigger augmented autofill // Although "standard" autofill is disabled, it might still trigger augmented autofill
if (triggerAugmentedAutofillLocked() != null) { if (triggerAugmentedAutofillLocked(requestFlags) != null) {
mForAugmentedAutofillOnly = true; mForAugmentedAutofillOnly = true;
if (sDebug) { if (sDebug) {
Slog.d(TAG, "Service disabled autofill for " + mComponentName Slog.d(TAG, "Service disabled autofill for " + mComponentName
@@ -2465,7 +2466,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
// triggered augmented autofill // triggered augmented autofill
if (!isSameViewEntered) { if (!isSameViewEntered) {
if (sDebug) Slog.d(TAG, "trigger augmented autofill."); if (sDebug) Slog.d(TAG, "trigger augmented autofill.");
triggerAugmentedAutofillLocked(); triggerAugmentedAutofillLocked(flags);
} else { } else {
if (sDebug) Slog.d(TAG, "skip augmented autofill for same view."); if (sDebug) Slog.d(TAG, "skip augmented autofill for same view.");
} }
@@ -2863,8 +2864,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
// The default autofill service cannot fullfill the request, let's check if the augmented // The default autofill service cannot fullfill the request, let's check if the augmented
// autofill service can. // autofill service can.
mAugmentedAutofillDestroyer = triggerAugmentedAutofillLocked(); mAugmentedAutofillDestroyer = triggerAugmentedAutofillLocked(flags);
if (mAugmentedAutofillDestroyer == null) { if (mAugmentedAutofillDestroyer == null && ((flags & FLAG_PASSWORD_INPUT_TYPE) == 0)) {
if (sVerbose) { if (sVerbose) {
Slog.v(TAG, "canceling session " + id + " when service returned null and it cannot " Slog.v(TAG, "canceling session " + id + " when service returned null and it cannot "
+ "be augmented. AutofillableIds: " + autofillableIds); + "be augmented. AutofillableIds: " + autofillableIds);
@@ -2874,9 +2875,15 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
removeSelf(); removeSelf();
} else { } else {
if (sVerbose) { if (sVerbose) {
if ((flags & FLAG_PASSWORD_INPUT_TYPE) != 0) {
Slog.v(TAG, "keeping session " + id + " when service returned null and "
+ "augmented service is disabled for password fields. "
+ "AutofillableIds: " + autofillableIds);
} else {
Slog.v(TAG, "keeping session " + id + " when service returned null but " Slog.v(TAG, "keeping session " + id + " when service returned null but "
+ "it can be augmented. AutofillableIds: " + autofillableIds); + "it can be augmented. AutofillableIds: " + autofillableIds);
} }
}
mAugmentedAutofillableIds = autofillableIds; mAugmentedAutofillableIds = autofillableIds;
try { try {
mClient.setState(AutofillManager.SET_STATE_FLAG_FOR_AUTOFILL_ONLY); mClient.setState(AutofillManager.SET_STATE_FLAG_FOR_AUTOFILL_ONLY);
@@ -2894,7 +2901,12 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
// TODO(b/123099468): might need to call it in other places, like when the service returns a // TODO(b/123099468): might need to call it in other places, like when the service returns a
// non-null response but without datasets (for example, just SaveInfo) // non-null response but without datasets (for example, just SaveInfo)
@GuardedBy("mLock") @GuardedBy("mLock")
private Runnable triggerAugmentedAutofillLocked() { private Runnable triggerAugmentedAutofillLocked(int flags) {
// (TODO: b/141703197) Fix later by passing info to service.
if ((flags & FLAG_PASSWORD_INPUT_TYPE) != 0) {
return null;
}
// Check if Smart Suggestions is supported... // Check if Smart Suggestions is supported...
final @SmartSuggestionMode int supportedModes = mService final @SmartSuggestionMode int supportedModes = mService
.getSupportedSmartSuggestionModesLocked(); .getSupportedSmartSuggestionModesLocked();