Allow TextClassifierServices to get a hold of a local TextClassifer.
Test: builds Bug: 74466564 Bug: 72747726 Merged-In: Idb108f2b3d95393a051f9f19b0c04fc4e3ed2b33 Change-Id: Idb108f2b3d95393a051f9f19b0c04fc4e3ed2b33
This commit is contained in:
@@ -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>);
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user