Revert "Fixed FieldClassificationStrategy that gets data from the package info."
This reverts commit cfa0d49be5.
Bug: 112776204
Test: atest FieldsClassificationTest#testGetAlgorithm
This commit is contained in:
@@ -4545,11 +4545,9 @@ package android.service.autofill {
|
||||
public abstract class AutofillFieldClassificationService extends android.app.Service {
|
||||
method public android.os.IBinder onBind(android.content.Intent);
|
||||
method public float[][] onGetScores(java.lang.String, android.os.Bundle, java.util.List<android.view.autofill.AutofillValue>, java.util.List<java.lang.String>);
|
||||
field public static final java.lang.String RESOURCE_AVAILABLE_ALGORITHMS = "autofill_field_classification_available_algorithms";
|
||||
field public static final java.lang.String RESOURCE_DEFAULT_ALGORITHM = "autofill_field_classification_default_algorithm";
|
||||
field public static final java.lang.String SERVICE_INTERFACE = "android.service.autofill.AutofillFieldClassificationService";
|
||||
field public static final deprecated java.lang.String SERVICE_META_DATA_KEY_AVAILABLE_ALGORITHMS = "android.autofill.field_classification.available_algorithms";
|
||||
field public static final deprecated java.lang.String SERVICE_META_DATA_KEY_DEFAULT_ALGORITHM = "android.autofill.field_classification.default_algorithm";
|
||||
field public static final java.lang.String SERVICE_META_DATA_KEY_AVAILABLE_ALGORITHMS = "android.autofill.field_classification.available_algorithms";
|
||||
field public static final java.lang.String SERVICE_META_DATA_KEY_DEFAULT_ALGORITHM = "android.autofill.field_classification.default_algorithm";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -65,36 +65,16 @@ public abstract class AutofillFieldClassificationService extends Service {
|
||||
/**
|
||||
* Manifest metadata key for the resource string containing the name of the default field
|
||||
* classification algorithm.
|
||||
*
|
||||
* @deprecated Use {@link #RESOURCE_DEFAULT_ALGORITHM} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String SERVICE_META_DATA_KEY_DEFAULT_ALGORITHM =
|
||||
"android.autofill.field_classification.default_algorithm";
|
||||
|
||||
/**
|
||||
* Manifest metadata key for the resource string array containing the names of all field
|
||||
* classification algorithms provided by the service.
|
||||
*
|
||||
* @deprecated Use {@link #RESOURCE_AVAILABLE_ALGORITHMS} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String SERVICE_META_DATA_KEY_AVAILABLE_ALGORITHMS =
|
||||
"android.autofill.field_classification.available_algorithms";
|
||||
|
||||
/**
|
||||
* Name of the resource string containing the name of the default field
|
||||
* classification algorithm.
|
||||
*/
|
||||
public static final String RESOURCE_DEFAULT_ALGORITHM =
|
||||
"autofill_field_classification_default_algorithm";
|
||||
|
||||
/**
|
||||
* Name of the resource string array containing the names of all field
|
||||
* classification algorithms provided by the service.
|
||||
*/
|
||||
public static final String RESOURCE_AVAILABLE_ALGORITHMS =
|
||||
"autofill_field_classification_available_algorithms";
|
||||
|
||||
/** {@hide} **/
|
||||
public static final String EXTRA_SCORES = "scores";
|
||||
|
||||
@@ -1413,7 +1413,7 @@ public final class AutofillManager {
|
||||
try {
|
||||
mService.getAvailableFieldClassificationAlgorithms(receiver);
|
||||
final String[] algorithms = receiver
|
||||
.getObjectResult(SyncResultReceiver.TYPE_STRING_ARRAY);
|
||||
.getObjectResult(SyncResultReceiver.TYPE_STRING_ARRAY);
|
||||
return algorithms != null ? Arrays.asList(algorithms) : Collections.emptyList();
|
||||
} catch (RemoteException e) {
|
||||
e.rethrowFromSystemServer();
|
||||
|
||||
@@ -55,6 +55,12 @@
|
||||
<intent-filter>
|
||||
<action android:name="android.service.autofill.AutofillFieldClassificationService" />
|
||||
</intent-filter>
|
||||
<meta-data
|
||||
android:name="android.autofill.field_classification.default_algorithm"
|
||||
android:resource="@string/autofill_field_classification_default_algorithm" />
|
||||
<meta-data
|
||||
android:name="android.autofill.field_classification.available_algorithms"
|
||||
android:resource="@array/autofill_field_classification_available_algorithms" />
|
||||
</service>
|
||||
|
||||
<library android:name="android.ext.services"/>
|
||||
|
||||
@@ -17,8 +17,8 @@ package com.android.server.autofill;
|
||||
|
||||
import static com.android.server.autofill.Helper.sDebug;
|
||||
import static com.android.server.autofill.Helper.sVerbose;
|
||||
import static android.service.autofill.AutofillFieldClassificationService.RESOURCE_AVAILABLE_ALGORITHMS;
|
||||
import static android.service.autofill.AutofillFieldClassificationService.RESOURCE_DEFAULT_ALGORITHM;
|
||||
import static android.service.autofill.AutofillFieldClassificationService.SERVICE_META_DATA_KEY_AVAILABLE_ALGORITHMS;
|
||||
import static android.service.autofill.AutofillFieldClassificationService.SERVICE_META_DATA_KEY_DEFAULT_ALGORITHM;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.MainThread;
|
||||
@@ -226,7 +226,7 @@ final class FieldClassificationStrategy {
|
||||
*/
|
||||
@Nullable
|
||||
String[] getAvailableAlgorithms() {
|
||||
return getMetadataValue(RESOURCE_AVAILABLE_ALGORITHMS, "array",
|
||||
return getMetadataValue(SERVICE_META_DATA_KEY_AVAILABLE_ALGORITHMS,
|
||||
(res, id) -> res.getStringArray(id));
|
||||
}
|
||||
|
||||
@@ -235,12 +235,11 @@ final class FieldClassificationStrategy {
|
||||
*/
|
||||
@Nullable
|
||||
String getDefaultAlgorithm() {
|
||||
return getMetadataValue(RESOURCE_DEFAULT_ALGORITHM, "string",
|
||||
(res, id) -> res.getString(id));
|
||||
return getMetadataValue(SERVICE_META_DATA_KEY_DEFAULT_ALGORITHM, (res, id) -> res.getString(id));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private <T> T getMetadataValue(String field, String type, MetadataParser<T> parser) {
|
||||
private <T> T getMetadataValue(String field, MetadataParser<T> parser) {
|
||||
final ServiceInfo serviceInfo = getServiceInfo();
|
||||
if (serviceInfo == null) return null;
|
||||
|
||||
@@ -254,7 +253,7 @@ final class FieldClassificationStrategy {
|
||||
return null;
|
||||
}
|
||||
|
||||
final int resourceId = res.getIdentifier(field, type, serviceInfo.packageName);
|
||||
final int resourceId = serviceInfo.metaData.getInt(field);
|
||||
return parser.get(res, resourceId);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user