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

Commit e6d974a5 authored by Abodunrinwa Toki's avatar Abodunrinwa Toki
Browse files

Allow TextClassifierServices to get a hold of a local TextClassifer.

Test: builds
Bug: 74466564
Bug: 72747726
Merged-In: Idb108f2b3d95393a051f9f19b0c04fc4e3ed2b33
Change-Id: Idb108f2b3d95393a051f9f19b0c04fc4e3ed2b33
parent 15e91e6f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4703,6 +4703,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
@@ -34,6 +34,7 @@ import android.os.RemoteException;
import android.text.TextUtils;
import android.util.Slog;
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;
@@ -47,7 +48,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:
 *
@@ -236,6 +237,18 @@ public abstract class TextClassifierService extends Service {
            @NonNull CancellationSignal cancellationSignal,
            @NonNull Callback<TextLinks> callback);

    /**
     * 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.
     *