Loading packages/SystemUI/multivalentTests/src/com/android/systemui/topwindoweffects/TopLevelWindowEffectsTest.kt +3 −2 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.view.WindowManager import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.concurrency.fakeExecutor import com.android.systemui.jank.interactionJankMonitor import com.android.systemui.keyevent.data.repository.fakeKeyEventRepository import com.android.systemui.keyevent.domain.interactor.KeyEventInteractor Loading @@ -43,7 +44,6 @@ import com.android.systemui.topwindoweffects.ui.viewmodel.SqueezeEffectViewModel import java.util.Optional import kotlin.time.Duration import kotlin.time.Duration.Companion.milliseconds import kotlinx.coroutines.test.StandardTestDispatcher import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading Loading @@ -71,7 +71,7 @@ class TopLevelWindowEffectsTest : SysuiTestCase() { Kosmos.Fixture { TopLevelWindowEffects( context = mContext, mainDispatcher = StandardTestDispatcher(testScope.testScheduler), mainExecutor = kosmos.fakeExecutor, topLevelWindowEffectsScope = testScope.backgroundScope, windowManager = windowManager, viewModelFactory = viewModelFactory, Loading Loading @@ -256,6 +256,7 @@ class TopLevelWindowEffectsTest : SysuiTestCase() { verify(kosmos.mockTopUiController, mode) .setRequestTopUi(true, TopLevelWindowEffects.TAG) } else { kosmos.fakeExecutor.runAllReady() verify(kosmos.notificationShadeWindowController, mode) .setRequestTopUi(true, TopLevelWindowEffects.TAG) } Loading packages/SystemUI/src/com/android/systemui/topwindoweffects/TopLevelWindowEffects.kt +17 −14 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.systemui.topwindoweffects import android.content.Context import android.graphics.PixelFormat import android.util.Log import android.view.Gravity import android.view.View import android.view.WindowInsets Loading @@ -38,20 +39,19 @@ import com.android.systemui.topwindoweffects.ui.compose.EffectsWindowRoot import com.android.systemui.topwindoweffects.ui.viewmodel.SqueezeEffectViewModel import com.android.wm.shell.appzoomout.AppZoomOut import java.util.Optional import java.util.concurrent.Executor import javax.inject.Inject import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.delay import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch import kotlinx.coroutines.withContext @SysUISingleton class TopLevelWindowEffects @Inject constructor( @Application private val context: Context, @Main private val mainDispatcher: CoroutineDispatcher, @Main private val mainExecutor: Executor, @TopLevelWindowEffectsThread private val topLevelWindowEffectsScope: CoroutineScope, private val windowManager: WindowManager, private val squeezeEffectInteractor: SqueezeEffectInteractor, Loading Loading @@ -92,7 +92,7 @@ constructor( } } private suspend fun addWindow( private fun addWindow( @DrawableRes topRoundedCornerId: Int, @DrawableRes bottomRoundedCornerId: Int, physicalPixelDisplaySizeRatio: Float, Loading @@ -102,6 +102,7 @@ constructor( } if (root != null) { Log.i(TAG, "addWindow: remove previous window") removeWindow() } Loading @@ -120,29 +121,31 @@ constructor( .apply { visibility = View.GONE } root?.let { rootView -> runOnMainThread { notificationShadeWindowController.setRequestTopUi(true, TAG) } setRequestTopUi(true) windowManager.addView(rootView, getWindowManagerLayoutParams()) rootView.post { rootView.visibility = View.VISIBLE } } } private suspend fun removeWindow() { if (root?.isAttachedToWindow == true) { private fun removeWindow() { if (root != null) { windowManager.removeView(root) root = null } root = null isInvocationEffectHappening = false setRequestTopUi(false) } private fun setRequestTopUi(requestTopUi: Boolean) { if (TopUiControllerRefactor.isEnabled) { topUiController.setRequestTopUi(false, TAG) topUiController.setRequestTopUi(requestTopUi, TAG) } else { runOnMainThread { notificationShadeWindowController.setRequestTopUi(false, TAG) } mainExecutor.execute { notificationShadeWindowController.setRequestTopUi(requestTopUi, TAG) } } private suspend fun runOnMainThread(block: () -> Unit) { withContext(mainDispatcher) { block() } } private fun getWindowManagerLayoutParams(): WindowManager.LayoutParams { Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/topwindoweffects/TopLevelWindowEffectsTest.kt +3 −2 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.view.WindowManager import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.concurrency.fakeExecutor import com.android.systemui.jank.interactionJankMonitor import com.android.systemui.keyevent.data.repository.fakeKeyEventRepository import com.android.systemui.keyevent.domain.interactor.KeyEventInteractor Loading @@ -43,7 +44,6 @@ import com.android.systemui.topwindoweffects.ui.viewmodel.SqueezeEffectViewModel import java.util.Optional import kotlin.time.Duration import kotlin.time.Duration.Companion.milliseconds import kotlinx.coroutines.test.StandardTestDispatcher import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading Loading @@ -71,7 +71,7 @@ class TopLevelWindowEffectsTest : SysuiTestCase() { Kosmos.Fixture { TopLevelWindowEffects( context = mContext, mainDispatcher = StandardTestDispatcher(testScope.testScheduler), mainExecutor = kosmos.fakeExecutor, topLevelWindowEffectsScope = testScope.backgroundScope, windowManager = windowManager, viewModelFactory = viewModelFactory, Loading Loading @@ -256,6 +256,7 @@ class TopLevelWindowEffectsTest : SysuiTestCase() { verify(kosmos.mockTopUiController, mode) .setRequestTopUi(true, TopLevelWindowEffects.TAG) } else { kosmos.fakeExecutor.runAllReady() verify(kosmos.notificationShadeWindowController, mode) .setRequestTopUi(true, TopLevelWindowEffects.TAG) } Loading
packages/SystemUI/src/com/android/systemui/topwindoweffects/TopLevelWindowEffects.kt +17 −14 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.systemui.topwindoweffects import android.content.Context import android.graphics.PixelFormat import android.util.Log import android.view.Gravity import android.view.View import android.view.WindowInsets Loading @@ -38,20 +39,19 @@ import com.android.systemui.topwindoweffects.ui.compose.EffectsWindowRoot import com.android.systemui.topwindoweffects.ui.viewmodel.SqueezeEffectViewModel import com.android.wm.shell.appzoomout.AppZoomOut import java.util.Optional import java.util.concurrent.Executor import javax.inject.Inject import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.delay import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch import kotlinx.coroutines.withContext @SysUISingleton class TopLevelWindowEffects @Inject constructor( @Application private val context: Context, @Main private val mainDispatcher: CoroutineDispatcher, @Main private val mainExecutor: Executor, @TopLevelWindowEffectsThread private val topLevelWindowEffectsScope: CoroutineScope, private val windowManager: WindowManager, private val squeezeEffectInteractor: SqueezeEffectInteractor, Loading Loading @@ -92,7 +92,7 @@ constructor( } } private suspend fun addWindow( private fun addWindow( @DrawableRes topRoundedCornerId: Int, @DrawableRes bottomRoundedCornerId: Int, physicalPixelDisplaySizeRatio: Float, Loading @@ -102,6 +102,7 @@ constructor( } if (root != null) { Log.i(TAG, "addWindow: remove previous window") removeWindow() } Loading @@ -120,29 +121,31 @@ constructor( .apply { visibility = View.GONE } root?.let { rootView -> runOnMainThread { notificationShadeWindowController.setRequestTopUi(true, TAG) } setRequestTopUi(true) windowManager.addView(rootView, getWindowManagerLayoutParams()) rootView.post { rootView.visibility = View.VISIBLE } } } private suspend fun removeWindow() { if (root?.isAttachedToWindow == true) { private fun removeWindow() { if (root != null) { windowManager.removeView(root) root = null } root = null isInvocationEffectHappening = false setRequestTopUi(false) } private fun setRequestTopUi(requestTopUi: Boolean) { if (TopUiControllerRefactor.isEnabled) { topUiController.setRequestTopUi(false, TAG) topUiController.setRequestTopUi(requestTopUi, TAG) } else { runOnMainThread { notificationShadeWindowController.setRequestTopUi(false, TAG) } mainExecutor.execute { notificationShadeWindowController.setRequestTopUi(requestTopUi, TAG) } } private suspend fun runOnMainThread(block: () -> Unit) { withContext(mainDispatcher) { block() } } private fun getWindowManagerLayoutParams(): WindowManager.LayoutParams { Loading