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

Commit f2b4b37d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Allow TextClassifierServices to get a hold of a local TextClassifer."

parents 088674c6 25ce3a46
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4697,6 +4697,7 @@ package android.service.textclassifier {

  public abstract class TextClassifierService extends android.app.Service {
    ctor public TextClassifierService();
    method public final android.view.textclassifier.TextClassifier getLocalTextClassifier();
    method public final android.os.IBinder onBind(android.content.Intent);
    method public abstract void onClassifyText(java.lang.CharSequence, int, int, android.view.textclassifier.TextClassification.Options, android.os.CancellationSignal, android.service.textclassifier.TextClassifierService.Callback<android.view.textclassifier.TextClassification>);
    method public abstract void onGenerateLinks(java.lang.CharSequence, android.view.textclassifier.TextLinks.Options, android.os.CancellationSignal, android.service.textclassifier.TextClassifierService.Callback<android.view.textclassifier.TextLinks>);
+14 −1
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.text.TextUtils;
import android.util.Slog;
import android.view.textclassifier.SelectionEvent;
import android.view.textclassifier.TextClassification;
import android.view.textclassifier.TextClassificationManager;
import android.view.textclassifier.TextClassifier;
import android.view.textclassifier.TextLinks;
import android.view.textclassifier.TextSelection;
@@ -48,7 +49,7 @@ import android.view.textclassifier.TextSelection;
 * {@link android.view.textclassifier.TextClassifierImpl} is loaded in the calling app's process.
 *
 * <p>See: {@link TextClassifier}.
 * See: {@link android.view.textclassifier.TextClassificationManager}.
 * See: {@link TextClassificationManager}.
 *
 * <p>Include the following in the manifest:
 *
@@ -252,6 +253,18 @@ public abstract class TextClassifierService extends Service {
     */
    public void onSelectionEvent(@NonNull SelectionEvent event) {}

    /**
     * Returns a TextClassifier that runs in this service's process.
     * If the local TextClassifier is disabled, this returns {@link TextClassifier#NO_OP}.
     */
    public final TextClassifier getLocalTextClassifier() {
        final TextClassificationManager tcm = getSystemService(TextClassificationManager.class);
        if (tcm != null) {
            return tcm.getTextClassifier(TextClassifier.LOCAL);
        }
        return TextClassifier.NO_OP;
    }

    /**
     * Callbacks for TextClassifierService results.
     *