summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/dream/lowlight/res/values/config.xml2
-rw-r--r--libs/dream/lowlight/src/com/android/dream/lowlight/dagger/LowLightDreamComponent.kt34
-rw-r--r--libs/dream/lowlight/src/com/android/dream/lowlight/dagger/LowLightDreamModule.kt26
-rw-r--r--packages/SystemUI/res/values/config.xml4
-rw-r--r--packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java40
6 files changed, 78 insertions, 32 deletions
diff --git a/libs/dream/lowlight/res/values/config.xml b/libs/dream/lowlight/res/values/config.xml
index 78fefbf41141..2b8fe029d842 100644
--- a/libs/dream/lowlight/res/values/config.xml
+++ b/libs/dream/lowlight/res/values/config.xml
@@ -15,8 +15,6 @@
~ limitations under the License.
-->
<resources>
- <!-- The dream component used when the device is low light environment. -->
- <string translatable="false" name="config_lowLightDreamComponent"/>
<!-- The max number of milliseconds to wait for the low light transition before setting
the system dream component -->
<integer name="config_lowLightTransitionTimeoutMs">2000</integer>
diff --git a/libs/dream/lowlight/src/com/android/dream/lowlight/dagger/LowLightDreamComponent.kt b/libs/dream/lowlight/src/com/android/dream/lowlight/dagger/LowLightDreamComponent.kt
new file mode 100644
index 000000000000..2314f9490829
--- /dev/null
+++ b/libs/dream/lowlight/src/com/android/dream/lowlight/dagger/LowLightDreamComponent.kt
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2024 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 com.android.dream.lowlight.dagger
+
+import android.app.DreamManager
+import android.content.ComponentName
+import dagger.BindsInstance
+import dagger.Subcomponent
+import javax.inject.Named
+
+@Subcomponent(modules = [LowLightDreamModule::class])
+interface LowLightDreamComponent {
+ @Subcomponent.Factory
+ interface Factory {
+ fun create(@BindsInstance dreamManager: DreamManager,
+ @Named(LowLightDreamModule.LOW_LIGHT_DREAM_COMPONENT)
+ @BindsInstance lowLightDreamComponent: ComponentName?
+ ): LowLightDreamComponent
+ }
+} \ No newline at end of file
diff --git a/libs/dream/lowlight/src/com/android/dream/lowlight/dagger/LowLightDreamModule.kt b/libs/dream/lowlight/src/com/android/dream/lowlight/dagger/LowLightDreamModule.kt
index dd274bd9d509..0161eef1260f 100644
--- a/libs/dream/lowlight/src/com/android/dream/lowlight/dagger/LowLightDreamModule.kt
+++ b/libs/dream/lowlight/src/com/android/dream/lowlight/dagger/LowLightDreamModule.kt
@@ -15,8 +15,6 @@
*/
package com.android.dream.lowlight.dagger
-import android.app.DreamManager
-import android.content.ComponentName
import android.content.Context
import com.android.dream.lowlight.R
import com.android.dream.lowlight.dagger.qualifiers.Application
@@ -35,30 +33,6 @@ import javax.inject.Named
*/
@Module
object LowLightDreamModule {
- /**
- * Provides dream manager.
- */
- @Provides
- fun providesDreamManager(context: Context): DreamManager {
- return requireNotNull(context.getSystemService(DreamManager::class.java))
- }
-
- /**
- * Provides the component name of the low light dream, or null if not configured.
- */
- @Provides
- @Named(LOW_LIGHT_DREAM_COMPONENT)
- fun providesLowLightDreamComponent(context: Context): ComponentName? {
- val lowLightDreamComponent = context.resources.getString(
- R.string.config_lowLightDreamComponent
- )
- return if (lowLightDreamComponent.isEmpty()) {
- null
- } else {
- ComponentName.unflattenFromString(lowLightDreamComponent)
- }
- }
-
@Provides
@Named(LOW_LIGHT_TRANSITION_TIMEOUT_MS)
fun providesLowLightTransitionTimeout(context: Context): Long {
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index 113f3d2bc35e..940e87d3d163 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -1103,4 +1103,8 @@
Whether the user switching can only happen by logging out and going through the system user (login screen).
-->
<bool name="config_userSwitchingMustGoThroughLoginScreen">false</bool>
+
+
+ <!-- The dream component used when the device is low light environment. -->
+ <string translatable="false" name="config_lowLightDreamComponent"/>
</resources>
diff --git a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java
index 571b37f43fd4..edfbfdc136a5 100644
--- a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java
+++ b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java
@@ -48,7 +48,6 @@ import androidx.lifecycle.ViewModelStore;
import com.android.app.viewcapture.ViewCaptureAwareWindowManager;
import com.android.compose.animation.scene.SceneKey;
-import com.android.dream.lowlight.dagger.LowLightDreamModule;
import com.android.internal.logging.UiEvent;
import com.android.internal.logging.UiEventLogger;
import com.android.internal.policy.PhoneWindow;
@@ -66,6 +65,7 @@ import com.android.systemui.communal.shared.model.CommunalTransitionKeys;
import com.android.systemui.complication.dagger.ComplicationComponent;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dreams.complication.dagger.DreamComplicationComponent;
+import com.android.systemui.dreams.dagger.DreamModule;
import com.android.systemui.dreams.dagger.DreamOverlayComponent;
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor;
import com.android.systemui.navigationbar.gestural.domain.GestureInteractor;
@@ -389,7 +389,7 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ
SystemDialogsCloser systemDialogsCloser,
UiEventLogger uiEventLogger,
@Named(DREAM_TOUCH_INSET_MANAGER) TouchInsetManager touchInsetManager,
- @Nullable @Named(LowLightDreamModule.LOW_LIGHT_DREAM_COMPONENT)
+ @Nullable @Named(DreamModule.LOW_LIGHT_DREAM_SERVICE)
ComponentName lowLightDreamComponent,
@Nullable @Named(HOME_CONTROL_PANEL_DREAM_COMPONENT)
ComponentName homeControlPanelDreamComponent,
diff --git a/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java b/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java
index 216cb86f8865..2bc91d3c6799 100644
--- a/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java
+++ b/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java
@@ -17,13 +17,14 @@
package com.android.systemui.dreams.dagger;
import android.annotation.Nullable;
+import android.app.DreamManager;
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
-import com.android.dream.lowlight.dagger.LowLightDreamModule;
+import com.android.dream.lowlight.dagger.LowLightDreamComponent;
import com.android.settingslib.dream.DreamBackend;
import com.android.systemui.ambient.touch.scrim.dagger.ScrimModule;
import com.android.systemui.complication.dagger.RegisteredComplicationsModule;
@@ -53,6 +54,7 @@ import dagger.multibindings.ClassKey;
import dagger.multibindings.IntoMap;
import dagger.multibindings.StringKey;
+import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.Executor;
@@ -63,7 +65,6 @@ import javax.inject.Named;
*/
@Module(includes = {
RegisteredComplicationsModule.class,
- LowLightDreamModule.class,
ScrimModule.class,
HomeControlsDataSourceModule.class,
},
@@ -71,6 +72,7 @@ import javax.inject.Named;
DreamComplicationComponent.class,
DreamOverlayComponent.class,
HomeControlsRemoteServiceComponent.class,
+ LowLightDreamComponent.class,
})
public interface DreamModule {
String DREAM_ONLY_ENABLED_FOR_DOCK_USER = "dream_only_enabled_for_dock_user";
@@ -81,6 +83,7 @@ public interface DreamModule {
String DREAM_OVERLAY_WINDOW_TITLE = "dream_overlay_window_title";
String HOME_CONTROL_PANEL_DREAM_COMPONENT = "home_control_panel_dream_component";
String DREAM_TILE_SPEC = "dream";
+ String LOW_LIGHT_DREAM_SERVICE = "low_light_dream_component";
/**
* Provides the dream component
@@ -214,4 +217,37 @@ public interface DreamModule {
QSTilePolicy.NoRestrictions.INSTANCE
);
}
+
+ /**
+ * Provides dream manager.
+ */
+ @Provides
+ static DreamManager providesDreamManager(Context context) {
+ return Objects.requireNonNull(context.getSystemService(DreamManager.class));
+ }
+
+ /**
+ * Provides the component name of the low light dream, or null if not configured.
+ */
+ @Provides
+ @Nullable
+ @Named(LOW_LIGHT_DREAM_SERVICE)
+ static ComponentName providesLowLightDreamService(Context context) {
+ String lowLightDreamComponent = context.getResources().getString(
+ R.string.config_lowLightDreamComponent
+ );
+ return lowLightDreamComponent.isEmpty()
+ ? null : ComponentName.unflattenFromString(lowLightDreamComponent);
+ }
+
+ /**
+ * Provides Dagger component for low light dependencies.
+ */
+ @Provides
+ @SysUISingleton
+ static LowLightDreamComponent providesLowLightDreamComponent(
+ LowLightDreamComponent.Factory factory, DreamManager dreamManager,
+ @Named(LOW_LIGHT_DREAM_SERVICE) ComponentName lowLightDreamService) {
+ return factory.create(dreamManager, lowLightDreamService);
+ }
}