From aa1949639a8bc62f1d5ce942ff636d2079766761 Mon Sep 17 00:00:00 2001 From: Joanne Chung Date: Tue, 22 Dec 2020 23:13:51 +0800 Subject: [PATCH] Register translation service. Bug: 173243538 Test: manual. Make sure device can boot to home and we can get the TranslationManager successfully. Change-Id: Ib0e733d6b8f3792431d71f9791b5b2e43a029a7b --- core/java/android/app/SystemServiceRegistry.java | 16 ++++++++++++++++ .../java/com/android/server/SystemServer.java | 9 +++++++++ 2 files changed, 25 insertions(+) diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java index 050d194c40944..dd016a2cf78e3 100644 --- a/core/java/android/app/SystemServiceRegistry.java +++ b/core/java/android/app/SystemServiceRegistry.java @@ -209,6 +209,8 @@ import android.view.contentcapture.IContentCaptureManager; import android.view.inputmethod.InputMethodManager; import android.view.textclassifier.TextClassificationManager; import android.view.textservice.TextServicesManager; +import android.view.translation.ITranslationManager; +import android.view.translation.TranslationManager; import com.android.internal.app.IAppOpsService; import com.android.internal.app.IBatteryStats; @@ -1172,6 +1174,20 @@ public final class SystemServiceRegistry { return null; }}); + registerService(Context.TRANSLATION_MANAGER_SERVICE, TranslationManager.class, + new CachedServiceFetcher() { + @Override + public TranslationManager createService(ContextImpl ctx) + throws ServiceNotFoundException { + IBinder b = ServiceManager.getService(Context.TRANSLATION_MANAGER_SERVICE); + ITranslationManager service = ITranslationManager.Stub.asInterface(b); + // Service is null when not provided by OEM. + if (service != null) { + return new TranslationManager(ctx.getOuterContext(), service); + } + return null; + }}); + registerService(Context.SEARCH_UI_SERVICE, SearchUiManager.class, new CachedServiceFetcher() { @Override diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index d9350f39ee586..eb7162fada60a 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -299,6 +299,8 @@ public final class SystemServer implements Dumpable { "com.android.server.autofill.AutofillManagerService"; private static final String CONTENT_CAPTURE_MANAGER_SERVICE_CLASS = "com.android.server.contentcapture.ContentCaptureManagerService"; + private static final String TRANSLATION_MANAGER_SERVICE_CLASS = + "com.android.server.translation.TranslationManagerService"; private static final String MUSIC_RECOGNITION_MANAGER_SERVICE_CLASS = "com.android.server.musicrecognition.MusicRecognitionManagerService"; private static final String SYSTEM_CAPTIONS_MANAGER_SERVICE_CLASS = @@ -2291,6 +2293,13 @@ public final class SystemServer implements Dumpable { t.traceEnd(); } + // Translation manager service + if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_TRANSLATION)) { + t.traceBegin("StartTranslationManagerService"); + mSystemServiceManager.startService(TRANSLATION_MANAGER_SERVICE_CLASS); + t.traceEnd(); + } + // NOTE: ClipboardService depends on ContentCapture and Autofill t.traceBegin("StartClipboardService"); mSystemServiceManager.startService(ClipboardService.class);