summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nick Chameyev <nickchameyev@google.com> 2024-06-11 09:02:07 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-06-11 09:02:07 +0000
commit254568d7287da5fd73a366da3d48e9bcc3bb9588 (patch)
treea6f9598c09e4b157a9c09db95f1ff678fd96df40
parent89595fde2b56b6205bd47818d4987f25e5f67c4d (diff)
parentc0fd24c02b90defae387f6c8cc53304fbd77b80f (diff)
Merge "Include SysUIUnfoldComponent only in phone SystemUI" into main
-rw-r--r--packages/SystemUI/src/com/android/systemui/dagger/CommonSystemUIUnfoldModule.kt53
-rw-r--r--packages/SystemUI/src/com/android/systemui/dagger/ReferenceSysUIComponent.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/unfold/SysUIUnfoldModule.kt10
4 files changed, 67 insertions, 2 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/CommonSystemUIUnfoldModule.kt b/packages/SystemUI/src/com/android/systemui/dagger/CommonSystemUIUnfoldModule.kt
new file mode 100644
index 000000000000..a91ce164ae7f
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/dagger/CommonSystemUIUnfoldModule.kt
@@ -0,0 +1,53 @@
+/*
+ * 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.systemui.dagger
+
+import com.android.systemui.unfold.SysUIUnfoldComponent
+import com.android.systemui.unfold.SysUIUnfoldModule.BoundFromSysUiUnfoldModule
+import dagger.BindsOptionalOf
+import dagger.Module
+import dagger.Provides
+import java.util.Optional
+import kotlin.jvm.optionals.getOrElse
+
+
+/**
+ * Module for foldable-related classes that is available in all SystemUI variants.
+ * Provides `Optional<SysUIUnfoldComponent>` which is present when the device is a foldable
+ * device that has fold/unfold animation enabled.
+ */
+@Module
+abstract class CommonSystemUIUnfoldModule {
+
+ /* Note this will be injected as @BoundFromSysUiUnfoldModule Optional<Optional<...>> */
+ @BindsOptionalOf
+ @BoundFromSysUiUnfoldModule
+ abstract fun optionalSysUiUnfoldComponent(): Optional<SysUIUnfoldComponent>
+
+ companion object {
+ @Provides
+ @SysUISingleton
+ fun sysUiUnfoldComponent(
+ /**
+ * This will be empty when [com.android.systemui.unfold.SysUIUnfoldModule] is not part
+ * of the graph, and contain the optional when it is.
+ */
+ @BoundFromSysUiUnfoldModule
+ optionalOfOptional: Optional<Optional<SysUIUnfoldComponent>>
+ ): Optional<SysUIUnfoldComponent> = optionalOfOptional.getOrElse { Optional.empty() }
+ }
+} \ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/ReferenceSysUIComponent.java b/packages/SystemUI/src/com/android/systemui/dagger/ReferenceSysUIComponent.java
index a431a59fcef6..b71af69b13cb 100644
--- a/packages/SystemUI/src/com/android/systemui/dagger/ReferenceSysUIComponent.java
+++ b/packages/SystemUI/src/com/android/systemui/dagger/ReferenceSysUIComponent.java
@@ -19,6 +19,7 @@ package com.android.systemui.dagger;
import com.android.systemui.keyguard.CustomizationProvider;
import com.android.systemui.statusbar.NotificationInsetsModule;
import com.android.systemui.statusbar.QsFrameTranslateModule;
+import com.android.systemui.unfold.SysUIUnfoldModule;
import dagger.Subcomponent;
@@ -34,6 +35,7 @@ import dagger.Subcomponent;
SystemUIBinder.class,
SystemUIModule.class,
SystemUICoreStartableModule.class,
+ SysUIUnfoldModule.class,
ReferenceSystemUIModule.class})
public interface ReferenceSysUIComponent extends SysUIComponent {
@@ -51,3 +53,4 @@ public interface ReferenceSysUIComponent extends SysUIComponent {
*/
void inject(CustomizationProvider customizationProvider);
}
+
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java
index 2ebb94f8bcf4..a7ff3c36a641 100644
--- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java
+++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java
@@ -143,7 +143,6 @@ import com.android.systemui.statusbar.window.StatusBarWindowModule;
import com.android.systemui.telephony.data.repository.TelephonyRepositoryModule;
import com.android.systemui.temporarydisplay.dagger.TemporaryDisplayModule;
import com.android.systemui.tuner.dagger.TunerModule;
-import com.android.systemui.unfold.SysUIUnfoldModule;
import com.android.systemui.user.UserModule;
import com.android.systemui.user.domain.UserDomainLayerModule;
import com.android.systemui.util.EventLogModule;
@@ -254,7 +253,7 @@ import javax.inject.Named;
SystemPropertiesFlagsModule.class,
SysUIConcurrencyModule.class,
SysUICoroutinesModule.class,
- SysUIUnfoldModule.class,
+ CommonSystemUIUnfoldModule.class,
TelephonyRepositoryModule.class,
TemporaryDisplayModule.class,
TunerModule.class,
diff --git a/packages/SystemUI/src/com/android/systemui/unfold/SysUIUnfoldModule.kt b/packages/SystemUI/src/com/android/systemui/unfold/SysUIUnfoldModule.kt
index 139ac7e4f687..a27989d772c4 100644
--- a/packages/SystemUI/src/com/android/systemui/unfold/SysUIUnfoldModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/unfold/SysUIUnfoldModule.kt
@@ -36,6 +36,7 @@ import dagger.multibindings.IntoMap
import dagger.multibindings.IntoSet
import java.util.Optional
import javax.inject.Named
+import javax.inject.Qualifier
import javax.inject.Scope
@Scope @MustBeDocumented @Retention(AnnotationRetention.RUNTIME) annotation class SysUIUnfoldScope
@@ -54,8 +55,17 @@ import javax.inject.Scope
@Module(subcomponents = [SysUIUnfoldComponent::class])
class SysUIUnfoldModule {
+ /**
+ * Qualifier for dependencies bound in [com.android.systemui.unfold.SysUIUnfoldModule]
+ */
+ @Qualifier
+ @MustBeDocumented
+ @Retention(AnnotationRetention.RUNTIME)
+ annotation class BoundFromSysUiUnfoldModule
+
@Provides
@SysUISingleton
+ @BoundFromSysUiUnfoldModule
fun provideSysUIUnfoldComponent(
provider: Optional<UnfoldTransitionProgressProvider>,
rotationProvider: Optional<NaturalRotationUnfoldProgressProvider>,