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:
Abodunrinwa Toki
2018-03-06 18:18:30 +00:00
parent 15e91e6f3a
commit e6d974a567
2 changed files with 15 additions and 1 deletions

View File

@@ -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>);

View File

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