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

Commit 31ff1351 authored by Tony Mak's avatar Tony Mak
Browse files

Make getLocalTextClassifier public

As suggested by security review, the javadoc should mention that
the requests will be sent to a textclassifier package if system
textclassifier is in use. Make getLocalTextClassifier public so that
developers can use it instead if they want to keep the data local.

BUG: 119631517
Test: atest TextClassificationManagerTest.java
Change-Id: I703c0a26c501c6eacf7c9efc7c21aca835e99fdb
parent daf5dc91
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -53336,6 +53336,7 @@ package android.view.textclassifier {
  public final class TextClassificationManager {
  public final class TextClassificationManager {
    method @NonNull public android.view.textclassifier.TextClassifier createTextClassificationSession(@NonNull android.view.textclassifier.TextClassificationContext);
    method @NonNull public android.view.textclassifier.TextClassifier createTextClassificationSession(@NonNull android.view.textclassifier.TextClassificationContext);
    method @NonNull public android.view.textclassifier.TextClassifier getLocalTextClassifier();
    method @NonNull public android.view.textclassifier.TextClassifier getTextClassifier();
    method @NonNull public android.view.textclassifier.TextClassifier getTextClassifier();
    method public void setTextClassificationSessionFactory(@Nullable android.view.textclassifier.TextClassificationSessionFactory);
    method public void setTextClassificationSessionFactory(@Nullable android.view.textclassifier.TextClassificationSessionFactory);
    method public void setTextClassifier(@Nullable android.view.textclassifier.TextClassifier);
    method public void setTextClassifier(@Nullable android.view.textclassifier.TextClassifier);
+15 −2
Original line number Original line Diff line number Diff line
@@ -73,9 +73,16 @@ public final class TextClassificationManager {
    /**
    /**
     * Returns the text classifier that was set via {@link #setTextClassifier(TextClassifier)}.
     * Returns the text classifier that was set via {@link #setTextClassifier(TextClassifier)}.
     * If this is null, this method returns a default text classifier (i.e. either the system text
     * If this is null, this method returns a default text classifier (i.e. either the system text
     * classifier if one exists, or a local text classifier running in this app.)
     * classifier if one exists, or a local text classifier running in this process.)
     * <p>
     * Note that if system textclassifier is in use, requests will be sent to a textclassifier
     * package provided from OEM. If you want to make sure the requests are handled in your own
     * process, you should consider {@link #getLocalTextClassifier()} instead. However, the local
     * textclassifier may return inferior results to those returned by the system
     * textclassifier.
     *
     *
     * @see #setTextClassifier(TextClassifier)
     * @see #setTextClassifier(TextClassifier)
     * @see #getLocalTextClassifier()
     */
     */
    @NonNull
    @NonNull
    public TextClassifier getTextClassifier() {
    public TextClassifier getTextClassifier() {
@@ -215,7 +222,13 @@ public final class TextClassificationManager {
        return TextClassifier.NO_OP;
        return TextClassifier.NO_OP;
    }
    }


    private TextClassifier getLocalTextClassifier() {
    /**
     * Returns a local textclassifier, which is running in this process.
     *
     * @see #getTextClassifier()
     */
    @NonNull
    public TextClassifier getLocalTextClassifier() {
        synchronized (mLock) {
        synchronized (mLock) {
            if (mLocalTextClassifier == null) {
            if (mLocalTextClassifier == null) {
                if (getSettings().isLocalTextClassifierEnabled()) {
                if (getSettings().isLocalTextClassifierEnabled()) {