Merge "eutofill For All Apps - add in multiline filter" into udc-dev
This commit is contained in:
@@ -193,6 +193,14 @@ public class AutofillFeatureFlags {
|
||||
public static final String DEVICE_CONFIG_SHOULD_ENABLE_AUTOFILL_ON_ALL_VIEW_TYPES =
|
||||
"should_enable_autofill_on_all_view_types";
|
||||
|
||||
/**
|
||||
* Whether to enable multi-line filter when checking if view is autofillable
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final String DEVICE_CONFIG_MULTILINE_FILTER_ENABLED =
|
||||
"multiline_filter_enabled";
|
||||
|
||||
/**
|
||||
* Whether include all autofill type not none views in assist structure
|
||||
*
|
||||
@@ -439,6 +447,17 @@ public class AutofillFeatureFlags {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Whether should enable multi-line filter
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static boolean shouldEnableMultilineFilter() {
|
||||
return DeviceConfig.getBoolean(
|
||||
DeviceConfig.NAMESPACE_AUTOFILL,
|
||||
DEVICE_CONFIG_MULTILINE_FILTER_ENABLED, false);
|
||||
}
|
||||
|
||||
// START AUTOFILL PCC CLASSIFICATION FUNCTIONS
|
||||
|
||||
/**
|
||||
|
||||
@@ -707,6 +707,9 @@ public final class AutofillManager {
|
||||
// An allowed activity set read from device config
|
||||
private Set<String> mAllowedActivitySet = new ArraySet<>();
|
||||
|
||||
// Whether to enable multi-line check when checking whether view is autofillable
|
||||
private boolean mShouldEnableMultilineFilter;
|
||||
|
||||
// Indicate whether should include all view with autofill type not none in assist structure
|
||||
private boolean mShouldIncludeAllViewsWithAutofillTypeNotNoneInAssistStructure;
|
||||
|
||||
@@ -889,6 +892,9 @@ public final class AutofillManager {
|
||||
mNonAutofillableImeActionIdSet =
|
||||
AutofillFeatureFlags.getNonAutofillableImeActionIdSetFromFlag();
|
||||
|
||||
mShouldEnableMultilineFilter =
|
||||
AutofillFeatureFlags.shouldEnableMultilineFilter();
|
||||
|
||||
final String denyListString = AutofillFeatureFlags.getDenylistStringFromFlag();
|
||||
final String allowlistString = AutofillFeatureFlags.getAllowlistStringFromFlag();
|
||||
|
||||
@@ -948,9 +954,8 @@ public final class AutofillManager {
|
||||
/**
|
||||
* Whether view passes the imeAction check
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public boolean isPassingImeActionCheck(EditText editText) {
|
||||
private boolean isPassingImeActionCheck(EditText editText) {
|
||||
final int actionId = editText.getImeOptions();
|
||||
if (mNonAutofillableImeActionIdSet.contains(String.valueOf(actionId))) {
|
||||
Log.d(TAG, "view not autofillable - not passing ime action check");
|
||||
@@ -959,6 +964,21 @@ public final class AutofillManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the view passed in is not multiline text
|
||||
*
|
||||
* @param editText the view that passed to this check
|
||||
* @return true if the view input is not multiline, false otherwise
|
||||
*/
|
||||
private boolean isPassingMultilineCheck(EditText editText) {
|
||||
// check if min line is set to be greater than 1
|
||||
if (editText.getMinLines() > 1) {
|
||||
Log.d(TAG, "view not autofillable - has multiline input type");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isPackageFullyAllowedOrDeniedForAutofill(
|
||||
@NonNull String listString, @NonNull String packageName) {
|
||||
// If "PackageName:;" is in the string, then it the package is fully denied or allowed for
|
||||
@@ -1103,6 +1123,9 @@ public final class AutofillManager {
|
||||
}
|
||||
|
||||
if (view instanceof EditText) {
|
||||
if (mShouldEnableMultilineFilter && !isPassingMultilineCheck((EditText) view)) {
|
||||
return false;
|
||||
}
|
||||
return isPassingImeActionCheck((EditText) view);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user