Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 029f1010 authored by Felipe Leme's avatar Felipe Leme
Browse files

Changed onGetScores() to return null instead of throwing exception.

Callers (Session and AFMShellCommand) already handle null (in fact, the
signature declares it as @Nullable), so there's no point on throwing a
runtime exception...

Bug: 70939974
Test: 'adb shell cmd autofill get fc_score half kale' when service APK was not
      implementing it.

Change-Id: I37da6cd13c40545626332c272759e797b5a25924
parent 0e5f9c8a
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -99,7 +99,9 @@ public abstract class AutofillFieldClassificationService extends Service {
                final String[] userDataValues = (String[]) args.arg5;
                final float[][] scores = onGetScores(algorithmName, algorithmArgs, actualValues,
                        Arrays.asList(userDataValues));
                if (scores != null) {
                    data.putParcelable(EXTRA_SCORES, new Scores(scores));
                }
                break;
            default:
                Log.w(TAG, "Handling unknown message: " + action);
@@ -148,7 +150,8 @@ public abstract class AutofillFieldClassificationService extends Service {
    public float[][] onGetScores(@Nullable String algorithm,
            @Nullable Bundle args, @NonNull List<AutofillValue> actualValues,
            @NonNull List<String> userDataValues) {
        throw new UnsupportedOperationException("Must be implemented by external service");
        Log.e(TAG, "service implementation (" + getClass() + " does not implement onGetScore()");
        return null;
    }

    private final class AutofillFieldClassificationServiceWrapper