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
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index f95c6f0..210fd47 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -111,6 +111,7 @@
import com.android.server.statusbar.StatusBarManagerService;
import com.android.server.storage.DeviceStorageMonitorService;
import com.android.server.telecom.TelecomLoaderService;
+import com.android.server.textclassifier.TextClassificationManagerService;
import com.android.server.trust.TrustManagerService;
import com.android.server.tv.TvInputManagerService;
import com.android.server.tv.TvRemoteService;
@@ -733,6 +734,8 @@
false);
boolean disableTextServices = SystemProperties.getBoolean("config.disable_textservices",
false);
+ boolean disableSystemTextClassifier = SystemProperties.getBoolean(
+ "config.disable_systemtextclassifier", false);
boolean disableConsumerIr = SystemProperties.getBoolean("config.disable_consumerir", false);
boolean disableVrManager = SystemProperties.getBoolean("config.disable_vrmanager", false);
boolean disableCameraService = SystemProperties.getBoolean("config.disable_cameraservice",
@@ -1066,6 +1069,12 @@
traceEnd();
}
+ if (!disableSystemTextClassifier) {
+ traceBeginAndSlog("StartTextClassificationManagerService");
+ mSystemServiceManager.startService(TextClassificationManagerService.Lifecycle.class);
+ traceEnd();
+ }
+
traceBeginAndSlog("StartNetworkScoreService");
try {
networkScore = new NetworkScoreService(context);