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

Commit 99222ab9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I32e604ad,I8d56f641 into main

* changes:
  Use ShadeDisplayAware window manager to add the Shade view at first
  Move shade layout params to dagger
parents de146b2d caf78260
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -172,7 +172,8 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase {
                mUserTracker,
                mKosmos.getNotificationShadeWindowModel(),
                mSecureSettings,
                mKosmos::getCommunalInteractor);
                mKosmos::getCommunalInteractor,
                mKosmos.getShadeLayoutParams());
        mNotificationShadeWindowController.setScrimsVisibilityListener((visibility) -> {});
        mNotificationShadeWindowController.fetchWindowRootView();

+22 −41
Original line number Diff line number Diff line
@@ -16,29 +16,25 @@

package com.android.systemui.shade.domain.interactor

import android.content.Context
import android.content.mockedContext
import android.content.res.Configuration
import android.content.res.Resources
import android.content.res.mockResources
import android.view.Display
import android.view.WindowManager
import android.view.WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE
import android.view.mockWindowManager
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.display.data.repository.FakeDisplayWindowPropertiesRepository
import com.android.systemui.display.shared.model.DisplayWindowProperties
import com.android.systemui.scene.ui.view.WindowRootView
import com.android.systemui.shade.data.repository.FakeShadeDisplayRepository
import java.util.Optional
import com.android.systemui.kosmos.testScope
import com.android.systemui.kosmos.useUnconfinedTestDispatcher
import com.android.systemui.scene.ui.view.mockShadeRootView
import com.android.systemui.shade.data.repository.fakeShadeDisplaysRepository
import com.android.systemui.testKosmos
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.UnconfinedTestDispatcher
import kotlinx.coroutines.test.advanceUntilIdle
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito.inOrder
import org.mockito.Mockito.verify
import org.mockito.kotlin.any
import org.mockito.kotlin.eq
import org.mockito.kotlin.mock
@@ -49,26 +45,18 @@ import org.mockito.kotlin.whenever
@RunWith(AndroidJUnit4::class)
@SmallTest
class ShadeDisplaysInteractorTest : SysuiTestCase() {
    val kosmos = testKosmos().useUnconfinedTestDispatcher()

    private val shadeRootview = mock<WindowRootView>()
    private val positionRepository = FakeShadeDisplayRepository()
    private val shadeContext = mock<Context>()
    private val contextStore = FakeDisplayWindowPropertiesRepository(context)
    private val testScope = TestScope(UnconfinedTestDispatcher())
    private val shadeWm = mock<WindowManager>()
    private val resources = mock<Resources>()
    private val shadeRootview = kosmos.mockShadeRootView
    private val positionRepository = kosmos.fakeShadeDisplaysRepository
    private val shadeContext = kosmos.mockedContext
    private val testScope = kosmos.testScope
    private val shadeWm = kosmos.mockWindowManager
    private val resources = kosmos.mockResources
    private val configuration = mock<Configuration>()
    private val display = mock<Display>()

    private val interactor =
        ShadeDisplaysInteractor(
            Optional.of(shadeRootview),
            positionRepository,
            shadeContext,
            shadeWm,
            testScope.backgroundScope,
            testScope.backgroundScope.coroutineContext,
        )
    private val underTest = kosmos.shadeDisplaysInteractor

    @Before
    fun setup() {
@@ -80,23 +68,14 @@ class ShadeDisplaysInteractorTest : SysuiTestCase() {
        whenever(shadeContext.displayId).thenReturn(0)
        whenever(shadeContext.getSystemService(any())).thenReturn(shadeWm)
        whenever(shadeContext.resources).thenReturn(resources)
        contextStore.insert(
            DisplayWindowProperties(
                displayId = 0,
                windowType = TYPE_NOTIFICATION_SHADE,
                context = shadeContext,
                windowManager = shadeWm,
                layoutInflater = mock(),
            )
        )
    }

    @Test
    fun start_shadeInCorrectPosition_notAddedOrRemoved() {
        whenever(display.displayId).thenReturn(0)
        positionRepository.setDisplayId(0)
        interactor.start()
        testScope.advanceUntilIdle()

        underTest.start()

        verifyNoMoreInteractions(shadeWm)
    }
@@ -105,7 +84,8 @@ class ShadeDisplaysInteractorTest : SysuiTestCase() {
    fun start_shadeInWrongPosition_changes() {
        whenever(display.displayId).thenReturn(0)
        positionRepository.setDisplayId(1)
        interactor.start()

        underTest.start()

        inOrder(shadeWm).apply {
            verify(shadeWm).removeView(eq(shadeRootview))
@@ -117,9 +97,10 @@ class ShadeDisplaysInteractorTest : SysuiTestCase() {
    fun start_shadePositionChanges_removedThenAdded() {
        whenever(display.displayId).thenReturn(0)
        positionRepository.setDisplayId(0)
        interactor.start()
        underTest.start()

        positionRepository.setDisplayId(1)
        testScope.advanceUntilIdle()

        inOrder(shadeWm).apply {
            verify(shadeWm).removeView(eq(shadeRootview))
+11 −6
Original line number Diff line number Diff line
@@ -38,10 +38,10 @@ import android.view.IWindowSession;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.view.WindowManagerGlobal;

import com.android.app.viewcapture.ViewCaptureAwareWindowManager;
import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.Dumpable;
import com.android.systemui.Flags;
@@ -102,11 +102,12 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW

    private final Context mContext;
    private final WindowRootViewComponent.Factory mWindowRootViewComponentFactory;
    private final ViewCaptureAwareWindowManager mWindowManager;
    private final WindowManager mWindowManager;
    private final IActivityManager mActivityManager;
    private final DozeParameters mDozeParameters;
    private final KeyguardStateController mKeyguardStateController;
    private final ShadeWindowLogger mLogger;
    private final LayoutParams mShadeWindowLayoutParams;
    private final LayoutParams mLpChanged;
    private final long mLockScreenDisplayTimeout;
    private final float mKeyguardPreferredRefreshRate; // takes precedence over max
@@ -148,7 +149,7 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
    public NotificationShadeWindowControllerImpl(
            @ShadeDisplayAware Context context,
            WindowRootViewComponent.Factory windowRootViewComponentFactory,
            ViewCaptureAwareWindowManager viewCaptureAwareWindowManager,
            @ShadeDisplayAware WindowManager windowManager,
            IActivityManager activityManager,
            DozeParameters dozeParameters,
            StatusBarStateController statusBarStateController,
@@ -167,14 +168,16 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
            UserTracker userTracker,
            NotificationShadeWindowModel notificationShadeWindowModel,
            SecureSettings secureSettings,
            Lazy<CommunalInteractor> communalInteractor) {
            Lazy<CommunalInteractor> communalInteractor,
            @ShadeDisplayAware LayoutParams shadeWindowLayoutParams) {
        mContext = context;
        mWindowRootViewComponentFactory = windowRootViewComponentFactory;
        mWindowManager = viewCaptureAwareWindowManager;
        mWindowManager = windowManager;
        mActivityManager = activityManager;
        mDozeParameters = dozeParameters;
        mKeyguardStateController = keyguardStateController;
        mLogger = logger;
        mShadeWindowLayoutParams = shadeWindowLayoutParams;
        mScreenBrightnessDoze = mDozeParameters.getScreenBrightnessDoze();
        mLpChanged = new LayoutParams();
        mKeyguardViewMediator = keyguardViewMediator;
@@ -271,7 +274,9 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
        // Now that the notification shade encompasses the sliding panel and its
        // translucent backdrop, the entire thing is made TRANSLUCENT and is
        // hardware-accelerated.
        mLp = ShadeWindowLayoutParams.INSTANCE.create(mContext);
        // mLP is assigned here (instead of the constructor) as its null value is also used to check
        // if the shade window has been attached.
        mLp = mShadeWindowLayoutParams;
        mWindowManager.addView(mWindowRootView, mLp);

        // We use BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE here, however, there is special logic in
+8 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.Context
import android.content.res.Resources
import android.view.LayoutInflater
import android.view.WindowManager
import android.view.WindowManager.LayoutParams
import android.view.WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE
import com.android.systemui.CoreStartable
import com.android.systemui.common.ui.ConfigurationState
@@ -77,6 +78,13 @@ object ShadeDisplayAwareModule {
        }
    }

    @Provides
    @ShadeDisplayAware
    @SysUISingleton
    fun provideShadeWindowLayoutParams(@ShadeDisplayAware context: Context): LayoutParams {
        return ShadeWindowLayoutParams.create(context)
    }

    @Provides
    @ShadeDisplayAware
    @SysUISingleton
+2 −4
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.shade.domain.interactor
import android.content.Context
import android.util.Log
import android.view.WindowManager
import android.view.WindowManager.LayoutParams
import androidx.annotation.UiThread
import com.android.app.tracing.coroutines.launchTraced
import com.android.app.tracing.traceSection
@@ -28,7 +29,6 @@ import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.scene.ui.view.WindowRootView
import com.android.systemui.shade.ShadeDisplayAware
import com.android.systemui.shade.ShadeWindowLayoutParams
import com.android.systemui.shade.data.repository.ShadeDisplaysRepository
import com.android.systemui.shade.shared.flag.ShadeWindowGoesAround
import com.android.systemui.util.kotlin.getOrNull
@@ -46,14 +46,12 @@ constructor(
    optionalShadeRootView: Optional<WindowRootView>,
    private val shadePositionRepository: ShadeDisplaysRepository,
    @ShadeDisplayAware private val shadeContext: Context,
    @ShadeDisplayAware private val shadeLayoutParams: LayoutParams,
    @ShadeDisplayAware private val wm: WindowManager,
    @Background private val bgScope: CoroutineScope,
    @Main private val mainThreadContext: CoroutineContext,
) : CoreStartable {

    private val shadeLayoutParams: WindowManager.LayoutParams =
        ShadeWindowLayoutParams.create(shadeContext)

    private val shadeRootView =
        optionalShadeRootView.getOrNull()
            ?: error(
Loading