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

Commit d32906c2 authored by Abodunrinwa Toki's avatar Abodunrinwa Toki
Browse files

Introduce a TextClassifierManagerService.

Apps wanting to use a TextClassifier service (instead of an
in-app-process TextClassifier) bind to this service. The service
binds to and reroutes calls to a configured system TextClassifierService.

TextClassifierManagerService manages the lifecycle of the configured
TextClassifierService and binds/unbinds to preserve system health.

A configurable TextClassifierService extends TextClassifierService,
declares an android.textclassifier.TextClassifierService intent, and
requires a permission that is only granted to the system so only the
system may bind to it.

The TextClassifierManagerService implements a similar interface to
TextClassifierService (i.e. ITextClassifierService) but doesn't have to.
This is done for simplicity sake and things may change in the future.

The configuration of the default service is in config.xml.
OEMs may change this with a config overlay.
If no TextClassifierService is specified, the default in app process
TextClassifierImpl is used.

Bug: 67609167
Test: bit FrameworksCoreTests:android.view.textclassifier.TextClassificationManagerTest
Test: tbd
Change-Id: I8e7bd6d12aa1a772897529c3b12f47f48757cfe6
parent 7933daec
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -319,6 +319,10 @@ java_library {
        "core/java/android/service/chooser/IChooserTargetResult.aidl",
        "core/java/android/service/resolver/IResolverRankerService.aidl",
        "core/java/android/service/resolver/IResolverRankerResult.aidl",
        "core/java/android/service/textclassifier/ITextClassificationCallback.aidl",
        "core/java/android/service/textclassifier/ITextClassifierService.aidl",
        "core/java/android/service/textclassifier/ITextLinksCallback.aidl",
        "core/java/android/service/textclassifier/ITextSelectionCallback.aidl",
        "core/java/android/view/accessibility/IAccessibilityInteractionConnection.aidl",
        "core/java/android/view/accessibility/IAccessibilityInteractionConnectionCallback.aidl",
        "core/java/android/view/accessibility/IAccessibilityManager.aidl",
+8 −2
Original line number Diff line number Diff line
@@ -49983,7 +49983,8 @@ package android.view.inputmethod {
package android.view.textclassifier {
  public final class TextClassification {
  public final class TextClassification implements android.os.Parcelable {
    method public int describeContents();
    method public float getConfidenceScore(java.lang.String);
    method public java.lang.String getEntity(int);
    method public int getEntityCount();
@@ -49997,6 +49998,8 @@ package android.view.textclassifier {
    method public java.lang.CharSequence getSecondaryLabel(int);
    method public java.lang.String getSignature();
    method public java.lang.String getText();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.view.textclassifier.TextClassification> CREATOR;
  }
  public static final class TextClassification.Builder {
@@ -50102,13 +50105,16 @@ package android.view.textclassifier {
    field public static final android.os.Parcelable.Creator<android.view.textclassifier.TextLinks.TextLink> CREATOR;
  }
  public final class TextSelection {
  public final class TextSelection implements android.os.Parcelable {
    method public int describeContents();
    method public float getConfidenceScore(java.lang.String);
    method public java.lang.String getEntity(int);
    method public int getEntityCount();
    method public int getSelectionEndIndex();
    method public int getSelectionStartIndex();
    method public java.lang.String getSignature();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.view.textclassifier.TextSelection> CREATOR;
  }
  public static final class TextSelection.Builder {
+19 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ package android {
    field public static final java.lang.String BIND_RESOLVER_RANKER_SERVICE = "android.permission.BIND_RESOLVER_RANKER_SERVICE";
    field public static final java.lang.String BIND_RUNTIME_PERMISSION_PRESENTER_SERVICE = "android.permission.BIND_RUNTIME_PERMISSION_PRESENTER_SERVICE";
    field public static final java.lang.String BIND_SETTINGS_SUGGESTIONS_SERVICE = "android.permission.BIND_SETTINGS_SUGGESTIONS_SERVICE";
    field public static final java.lang.String BIND_TEXTCLASSIFIER_SERVICE = "android.permission.BIND_TEXTCLASSIFIER_SERVICE";
    field public static final java.lang.String BIND_TRUST_AGENT = "android.permission.BIND_TRUST_AGENT";
    field public static final java.lang.String BIND_TV_REMOTE_SERVICE = "android.permission.BIND_TV_REMOTE_SERVICE";
    field public static final java.lang.String BLUETOOTH_PRIVILEGED = "android.permission.BLUETOOTH_PRIVILEGED";
@@ -4438,6 +4439,24 @@ package android.service.settings.suggestions {

}

package android.service.textclassifier {

  public abstract class TextClassifierService extends android.app.Service {
    ctor public TextClassifierService();
    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>);
    method public abstract void onSuggestSelection(java.lang.CharSequence, int, int, android.view.textclassifier.TextSelection.Options, android.os.CancellationSignal, android.service.textclassifier.TextClassifierService.Callback<android.view.textclassifier.TextSelection>);
    field public static final java.lang.String SERVICE_INTERFACE = "android.service.textclassifier.TextClassifierService";
  }

  public static abstract interface TextClassifierService.Callback<T> {
    method public abstract void onFailure(java.lang.CharSequence);
    method public abstract void onSuccess(T);
  }

}

package android.service.trust {

  public class TrustAgentService extends android.app.Service {
+28 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.service.textclassifier;

import android.view.textclassifier.TextClassification;

/**
 * Callback for a TextClassification request.
 * @hide
 */
oneway interface ITextClassificationCallback {
    void onSuccess(in TextClassification classification);
    void onFailure();
}
+47 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.service.textclassifier;

import android.service.textclassifier.ITextClassificationCallback;
import android.service.textclassifier.ITextLinksCallback;
import android.service.textclassifier.ITextSelectionCallback;
import android.view.textclassifier.TextClassification;
import android.view.textclassifier.TextLinks;
import android.view.textclassifier.TextSelection;

/**
 * TextClassifierService binder interface.
 * See TextClassifier for interface documentation.
 * {@hide}
 */
oneway interface ITextClassifierService {

    void onSuggestSelection(
            in CharSequence text, int selectionStartIndex, int selectionEndIndex,
            in TextSelection.Options options,
            in ITextSelectionCallback c);

    void onClassifyText(
            in CharSequence text, int startIndex, int endIndex,
            in TextClassification.Options options,
            in ITextClassificationCallback c);

    void onGenerateLinks(
            in CharSequence text,
            in TextLinks.Options options,
            in ITextLinksCallback c);
}
Loading