Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 254568d7 authored by Nick Chameyev's avatar Nick Chameyev Committed by Android (Google) Code Review
Browse files

Merge "Include SysUIUnfoldComponent only in phone SystemUI" into main

parents 89595fde c0fd24c0
Loading
Loading
Loading
Loading
+53 −0
Original line number Diff line number Diff line
/*
 * 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
+3 −0
Original line number Diff line number Diff line
@@ -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);
}
+1 −2
Original line number Diff line number Diff line
@@ -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,
+10 −0
Original line number Diff line number Diff line
@@ -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>,