frameworks/base
Revision | bb1a46a7ae4e5ea620ca5fa33315eaff4a8456db (tree) |
---|---|
Time | 2020-01-09 11:02:58 |
Author | android-build-team Robot <android-build-team-robot@goog...> |
Commiter | android-build-team Robot |
Snap for 6120535 from 9595ad654b547711c1af56a562dbf429e608d176 to qt-qpr2-release
Change-Id: I831b75f3f7350376063409d5c53cd1f96c4e8a24
@@ -71,12 +71,21 @@ public final class FillRequest implements Parcelable { | ||
71 | 71 | */ |
72 | 72 | public static final int FLAG_COMPATIBILITY_MODE_REQUEST = 0x2; |
73 | 73 | |
74 | + /** | |
75 | + * Indicates the request came from a password field. | |
76 | + * | |
77 | + * (TODO: b/141703197) Temporary fix for augmented autofill showing passwords. | |
78 | + * | |
79 | + * @hide | |
80 | + */ | |
81 | + public static final @RequestFlags int FLAG_PASSWORD_INPUT_TYPE = 0x4; | |
82 | + | |
74 | 83 | /** @hide */ |
75 | 84 | public static final int INVALID_REQUEST_ID = Integer.MIN_VALUE; |
76 | 85 | |
77 | 86 | /** @hide */ |
78 | 87 | @IntDef(flag = true, prefix = { "FLAG_" }, value = { |
79 | - FLAG_MANUAL_REQUEST, FLAG_COMPATIBILITY_MODE_REQUEST | |
88 | + FLAG_MANUAL_REQUEST, FLAG_COMPATIBILITY_MODE_REQUEST, FLAG_PASSWORD_INPUT_TYPE | |
80 | 89 | }) |
81 | 90 | @Retention(RetentionPolicy.SOURCE) |
82 | 91 | @interface RequestFlags{} |
@@ -100,7 +109,7 @@ public final class FillRequest implements Parcelable { | ||
100 | 109 | @Nullable Bundle clientState, @RequestFlags int flags) { |
101 | 110 | mId = id; |
102 | 111 | mFlags = Preconditions.checkFlagsArgument(flags, |
103 | - FLAG_MANUAL_REQUEST | FLAG_COMPATIBILITY_MODE_REQUEST); | |
112 | + FLAG_MANUAL_REQUEST | FLAG_COMPATIBILITY_MODE_REQUEST | FLAG_PASSWORD_INPUT_TYPE); | |
104 | 113 | mContexts = Preconditions.checkCollectionElementsNotNull(contexts, "contexts"); |
105 | 114 | mClientState = clientState; |
106 | 115 | } |
@@ -17,6 +17,7 @@ | ||
17 | 17 | package android.view.autofill; |
18 | 18 | |
19 | 19 | import static android.service.autofill.FillRequest.FLAG_MANUAL_REQUEST; |
20 | +import static android.service.autofill.FillRequest.FLAG_PASSWORD_INPUT_TYPE; | |
20 | 21 | import static android.view.autofill.Helper.sDebug; |
21 | 22 | import static android.view.autofill.Helper.sVerbose; |
22 | 23 | import static android.view.autofill.Helper.toList; |
@@ -60,6 +61,7 @@ import android.view.accessibility.AccessibilityManager; | ||
60 | 61 | import android.view.accessibility.AccessibilityNodeInfo; |
61 | 62 | import android.view.accessibility.AccessibilityNodeProvider; |
62 | 63 | import android.view.accessibility.AccessibilityWindowInfo; |
64 | +import android.widget.TextView; | |
63 | 65 | |
64 | 66 | import com.android.internal.annotations.GuardedBy; |
65 | 67 | import com.android.internal.logging.MetricsLogger; |
@@ -966,6 +968,10 @@ public final class AutofillManager { | ||
966 | 968 | if (!isClientDisablingEnterExitEvent()) { |
967 | 969 | final AutofillValue value = view.getAutofillValue(); |
968 | 970 | |
971 | + if (view instanceof TextView && ((TextView) view).isAnyPasswordInputType()) { | |
972 | + flags |= FLAG_PASSWORD_INPUT_TYPE; | |
973 | + } | |
974 | + | |
969 | 975 | if (!isActiveLocked()) { |
970 | 976 | // Starts new session. |
971 | 977 | startSessionLocked(id, null, value, flags); |
@@ -1130,6 +1136,10 @@ public final class AutofillManager { | ||
1130 | 1136 | } else { |
1131 | 1137 | // don't notify entered when Activity is already in background |
1132 | 1138 | if (!isClientDisablingEnterExitEvent()) { |
1139 | + if (view instanceof TextView && ((TextView) view).isAnyPasswordInputType()) { | |
1140 | + flags |= FLAG_PASSWORD_INPUT_TYPE; | |
1141 | + } | |
1142 | + | |
1133 | 1143 | if (!isActiveLocked()) { |
1134 | 1144 | // Starts new session. |
1135 | 1145 | startSessionLocked(id, bounds, null, flags); |
@@ -6582,6 +6582,16 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener | ||
6582 | 6582 | return mTransformation instanceof PasswordTransformationMethod; |
6583 | 6583 | } |
6584 | 6584 | |
6585 | + /** | |
6586 | + * Returns true if the current inputType is any type of password. | |
6587 | + * | |
6588 | + * @hide | |
6589 | + */ | |
6590 | + public boolean isAnyPasswordInputType() { | |
6591 | + final int inputType = getInputType(); | |
6592 | + return isPasswordInputType(inputType) || isVisiblePasswordInputType(inputType); | |
6593 | + } | |
6594 | + | |
6585 | 6595 | static boolean isPasswordInputType(int inputType) { |
6586 | 6596 | final int variation = |
6587 | 6597 | inputType & (EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_MASK_VARIATION); |
@@ -952,7 +952,9 @@ public class ChooserActivity extends ResolverActivity { | ||
952 | 952 | name = pkgRes.getString(nameResId); |
953 | 953 | final int resId = metaData.getInt(CHIP_ICON_METADATA_KEY); |
954 | 954 | icon = pkgRes.getDrawable(resId); |
955 | - } catch (NameNotFoundException ex) { } | |
955 | + } catch (Resources.NotFoundException ex) { | |
956 | + } catch (NameNotFoundException ex) { | |
957 | + } | |
956 | 958 | } |
957 | 959 | if (TextUtils.isEmpty(name)) { |
958 | 960 | name = ri.loadLabel(getPackageManager()); |
@@ -18,6 +18,7 @@ package com.android.server.autofill; | ||
18 | 18 | |
19 | 19 | import static android.service.autofill.AutofillFieldClassificationService.EXTRA_SCORES; |
20 | 20 | import static android.service.autofill.FillRequest.FLAG_MANUAL_REQUEST; |
21 | +import static android.service.autofill.FillRequest.FLAG_PASSWORD_INPUT_TYPE; | |
21 | 22 | import static android.service.autofill.FillRequest.INVALID_REQUEST_ID; |
22 | 23 | import static android.view.autofill.AutofillManager.ACTION_START_SESSION; |
23 | 24 | import static android.view.autofill.AutofillManager.ACTION_VALUE_CHANGED; |
@@ -581,7 +582,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState | ||
581 | 582 | + ", flags=" + flags + ")"); |
582 | 583 | } |
583 | 584 | mForAugmentedAutofillOnly = true; |
584 | - triggerAugmentedAutofillLocked(); | |
585 | + triggerAugmentedAutofillLocked(flags); | |
585 | 586 | return; |
586 | 587 | } |
587 | 588 | viewState.setState(newState); |
@@ -780,7 +781,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState | ||
780 | 781 | id, mCompatMode); |
781 | 782 | } |
782 | 783 | // Although "standard" autofill is disabled, it might still trigger augmented autofill |
783 | - if (triggerAugmentedAutofillLocked() != null) { | |
784 | + if (triggerAugmentedAutofillLocked(requestFlags) != null) { | |
784 | 785 | mForAugmentedAutofillOnly = true; |
785 | 786 | if (sDebug) { |
786 | 787 | Slog.d(TAG, "Service disabled autofill for " + mComponentName |
@@ -2424,7 +2425,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState | ||
2424 | 2425 | if (sDebug) Slog.d(TAG, "updateLocked(" + id + "): augmented-autofillable"); |
2425 | 2426 | |
2426 | 2427 | // ...then trigger the augmented autofill UI |
2427 | - triggerAugmentedAutofillLocked(); | |
2428 | + triggerAugmentedAutofillLocked(flags); | |
2428 | 2429 | return; |
2429 | 2430 | } |
2430 | 2431 |
@@ -2688,8 +2689,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState | ||
2688 | 2689 | |
2689 | 2690 | // The default autofill service cannot fullfill the request, let's check if the augmented |
2690 | 2691 | // autofill service can. |
2691 | - mAugmentedAutofillDestroyer = triggerAugmentedAutofillLocked(); | |
2692 | - if (mAugmentedAutofillDestroyer == null) { | |
2692 | + mAugmentedAutofillDestroyer = triggerAugmentedAutofillLocked(flags); | |
2693 | + if (mAugmentedAutofillDestroyer == null && ((flags & FLAG_PASSWORD_INPUT_TYPE) == 0)) { | |
2693 | 2694 | if (sVerbose) { |
2694 | 2695 | Slog.v(TAG, "canceling session " + id + " when service returned null and it cannot " |
2695 | 2696 | + "be augmented. AutofillableIds: " + autofillableIds); |
@@ -2699,8 +2700,14 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState | ||
2699 | 2700 | removeSelf(); |
2700 | 2701 | } else { |
2701 | 2702 | if (sVerbose) { |
2702 | - Slog.v(TAG, "keeping session " + id + " when service returned null but " | |
2703 | - + "it can be augmented. AutofillableIds: " + autofillableIds); | |
2703 | + if ((flags & FLAG_PASSWORD_INPUT_TYPE) != 0) { | |
2704 | + Slog.v(TAG, "keeping session " + id + " when service returned null and " | |
2705 | + + "augmented service is disabled for password fields. " | |
2706 | + + "AutofillableIds: " + autofillableIds); | |
2707 | + } else { | |
2708 | + Slog.v(TAG, "keeping session " + id + " when service returned null but " | |
2709 | + + "it can be augmented. AutofillableIds: " + autofillableIds); | |
2710 | + } | |
2704 | 2711 | } |
2705 | 2712 | mAugmentedAutofillableIds = autofillableIds; |
2706 | 2713 | try { |
@@ -2719,7 +2726,12 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState | ||
2719 | 2726 | // TODO(b/123099468): might need to call it in other places, like when the service returns a |
2720 | 2727 | // non-null response but without datasets (for example, just SaveInfo) |
2721 | 2728 | @GuardedBy("mLock") |
2722 | - private Runnable triggerAugmentedAutofillLocked() { | |
2729 | + private Runnable triggerAugmentedAutofillLocked(int flags) { | |
2730 | + // (TODO: b/141703197) Fix later by passing info to service. | |
2731 | + if ((flags & FLAG_PASSWORD_INPUT_TYPE) != 0) { | |
2732 | + return null; | |
2733 | + } | |
2734 | + | |
2723 | 2735 | // Check if Smart Suggestions is supported... |
2724 | 2736 | final @SmartSuggestionMode int supportedModes = mService |
2725 | 2737 | .getSupportedSmartSuggestionModesLocked(); |