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

Commit 4cac1f42 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move TextClassifier.getLocalTextClassifier() API."

parents d17fca2c 324572e7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ public class TextClassifierPerfTest {
        Context context = InstrumentationRegistry.getTargetContext();
        TextClassificationManager textClassificationManager =
                context.getSystemService(TextClassificationManager.class);
        mTextClassifier = textClassificationManager.getLocalTextClassifier();
        mTextClassifier = textClassificationManager.getTextClassifier(TextClassifier.LOCAL);
    }

    @Test
+0 −1
Original line number Diff line number Diff line
@@ -54238,7 +54238,6 @@ 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);
+2 −1
Original line number Diff line number Diff line
@@ -6718,7 +6718,8 @@ 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 static android.view.textclassifier.TextClassifier getDefaultTextClassifierImplementation(@NonNull android.content.Context);
    method @Deprecated public final android.view.textclassifier.TextClassifier getLocalTextClassifier();
    method @Nullable public final android.os.IBinder onBind(android.content.Intent);
    method public abstract void onClassifyText(@Nullable android.view.textclassifier.TextClassificationSessionId, @NonNull android.view.textclassifier.TextClassification.Request, @NonNull android.os.CancellationSignal, @NonNull android.service.textclassifier.TextClassifierService.Callback<android.view.textclassifier.TextClassification>);
    method public void onCreateTextClassificationSession(@NonNull android.view.textclassifier.TextClassificationContext, @NonNull android.view.textclassifier.TextClassificationSessionId);
+13 −1
Original line number Diff line number Diff line
@@ -420,9 +420,21 @@ public abstract class TextClassifierService extends Service {
    /**
     * Returns a TextClassifier that runs in this service's process.
     * If the local TextClassifier is disabled, this returns {@link TextClassifier#NO_OP}.
     *
     * @deprecated Use {@link #getDefaultTextClassifierImplementation(Context)} instead.
     */
    @Deprecated
    public final TextClassifier getLocalTextClassifier() {
        final TextClassificationManager tcm = getSystemService(TextClassificationManager.class);
        // Deprecated: In the future, we may not guarantee that this runs in the service's process.
        return getDefaultTextClassifierImplementation(this);
    }

    /**
     * Returns the platform's default TextClassifier implementation.
     */
    public static TextClassifier getDefaultTextClassifierImplementation(@NonNull Context context) {
        final TextClassificationManager tcm =
                context.getSystemService(TextClassificationManager.class);
        if (tcm != null) {
            return tcm.getTextClassifier(TextClassifier.LOCAL);
        }
+3 −9
Original line number Diff line number Diff line
@@ -75,14 +75,10 @@ public final class TextClassificationManager {
     * 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 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.
     * Note that requests to the TextClassifier may be handled in an OEM-provided process rather
     * than in the calling app's process.
     *
     * @see #setTextClassifier(TextClassifier)
     * @see #getLocalTextClassifier()
     */
    @NonNull
    public TextClassifier getTextClassifier() {
@@ -224,11 +220,9 @@ public final class TextClassificationManager {

    /**
     * Returns a local textclassifier, which is running in this process.
     *
     * @see #getTextClassifier()
     */
    @NonNull
    public TextClassifier getLocalTextClassifier() {
    private TextClassifier getLocalTextClassifier() {
        synchronized (mLock) {
            if (mLocalTextClassifier == null) {
                if (getSettings().isLocalTextClassifierEnabled()) {