diff --git a/api/current.txt b/api/current.txt index fc580aa9cd1a8..8b8380366dd66 100644 --- a/api/current.txt +++ b/api/current.txt @@ -53495,6 +53495,7 @@ package android.view.textclassifier { public final class TextClassificationManager { 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 public void setTextClassificationSessionFactory(@Nullable android.view.textclassifier.TextClassificationSessionFactory); method public void setTextClassifier(@Nullable android.view.textclassifier.TextClassifier); diff --git a/core/java/android/view/textclassifier/TextClassificationManager.java b/core/java/android/view/textclassifier/TextClassificationManager.java index ed862064be67c..10c7adef28fd7 100644 --- a/core/java/android/view/textclassifier/TextClassificationManager.java +++ b/core/java/android/view/textclassifier/TextClassificationManager.java @@ -73,9 +73,16 @@ public final class TextClassificationManager { /** * 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 - * 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.) + *
+ * 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 #getLocalTextClassifier() */ @NonNull public TextClassifier getTextClassifier() { @@ -215,7 +222,13 @@ public final class TextClassificationManager { 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) { if (mLocalTextClassifier == null) { if (getSettings().isLocalTextClassifierEnabled()) {