From 146dc70ac64e094bfeaa9c61487c3f48a11cd804 Mon Sep 17 00:00:00 2001 From: Chen Bai Date: Wed, 24 May 2023 18:58:02 -0700 Subject: [PATCH] boot ac: make AmbientContextManagerService optional - Based on the overlay config, device may not load AmbientContextManagerService Test: atest CtsAmbientContextServiceTestCases BUG: 284076411 Change-Id: Ia6775e54a0354ac3795d8dc94cad05daaafc112a --- .../java/com/android/server/SystemServer.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index 09ff5feec0481..a6f04d48b23a2 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -106,7 +106,6 @@ import com.android.internal.util.FrameworkStatsLog; import com.android.internal.widget.ILockSettings; import com.android.internal.widget.LockSettingsInternal; import com.android.server.am.ActivityManagerService; -import com.android.server.ambientcontext.AmbientContextManagerService; import com.android.server.appbinding.AppBindingService; import com.android.server.appop.AppOpMigrationHelper; import com.android.server.appop.AppOpMigrationHelperImpl; @@ -356,6 +355,8 @@ public final class SystemServer implements Dumpable { "com.android.server.selectiontoolbar.SelectionToolbarManagerService"; private static final String MUSIC_RECOGNITION_MANAGER_SERVICE_CLASS = "com.android.server.musicrecognition.MusicRecognitionManagerService"; + private static final String AMBIENT_CONTEXT_MANAGER_SERVICE_CLASS = + "com.android.server.ambientcontext.AmbientContextManagerService"; private static final String SYSTEM_CAPTIONS_MANAGER_SERVICE_CLASS = "com.android.server.systemcaptions.SystemCaptionsManagerService"; private static final String TEXT_TO_SPEECH_MANAGER_SERVICE_CLASS = @@ -1908,9 +1909,17 @@ public final class SystemServer implements Dumpable { startRotationResolverService(context, t); startSystemCaptionsManagerService(context, t); startTextToSpeechManagerService(context, t); - startAmbientContextService(t); startWearableSensingService(t); + if (deviceHasConfigString( + context, R.string.config_defaultAmbientContextDetectionService)) { + t.traceBegin("StartAmbientContextService"); + mSystemServiceManager.startService(AMBIENT_CONTEXT_MANAGER_SERVICE_CLASS); + t.traceEnd(); + } else { + Slog.d(TAG, "AmbientContextManagerService not defined by OEM or disabled by flag"); + } + // System Speech Recognition Service t.traceBegin("StartSpeechRecognitionManagerService"); mSystemServiceManager.startService(SPEECH_RECOGNITION_MANAGER_SERVICE_CLASS); @@ -3311,12 +3320,6 @@ public final class SystemServer implements Dumpable { } - private void startAmbientContextService(@NonNull TimingsTraceAndSlog t) { - t.traceBegin("StartAmbientContextService"); - mSystemServiceManager.startService(AmbientContextManagerService.class); - t.traceEnd(); - } - private void startWearableSensingService(@NonNull TimingsTraceAndSlog t) { t.traceBegin("startWearableSensingService"); mSystemServiceManager.startService(WearableSensingManagerService.class);