Merge "Make getLocalTextClassifier public"

This commit is contained in:
TreeHugger Robot
2019-01-24 20:24:10 +00:00
committed by Android (Google) Code Review
2 changed files with 16 additions and 2 deletions

View File

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

View File

@@ -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.)
* <p>
* 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()) {