Merge "Injrect WindowContext into RecentsWindowManager" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
bb2b582e7f
@@ -21,6 +21,7 @@ import android.hardware.display.DisplayManager
|
||||
import android.os.Handler
|
||||
import android.util.Log
|
||||
import android.view.Display.DEFAULT_DISPLAY
|
||||
import android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
|
||||
import com.android.app.displaylib.DefaultDisplayOnlyInstanceRepositoryImpl
|
||||
import com.android.app.displaylib.DisplayLibBackground
|
||||
import com.android.app.displaylib.DisplayLibComponent
|
||||
@@ -178,6 +179,39 @@ object PerDisplayRepositoriesModule {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Provides
|
||||
@LauncherAppSingleton
|
||||
@WindowContext
|
||||
fun provideWindowContext(
|
||||
repositoryFactory: PerDisplayInstanceRepositoryImpl.Factory<Context>,
|
||||
displayRepository: DisplayRepository,
|
||||
@ApplicationContext context: Context,
|
||||
): PerDisplayRepository<Context> {
|
||||
return if (enableOverviewOnConnectedDisplays()) {
|
||||
repositoryFactory.create(
|
||||
"DisplayContextRepo",
|
||||
{ displayId ->
|
||||
displayRepository.getDisplay(displayId)?.let {
|
||||
context.createWindowContext(
|
||||
it,
|
||||
TYPE_APPLICATION_OVERLAY,
|
||||
/* options=*/ null,
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
} else {
|
||||
SingleInstanceRepositoryImpl(
|
||||
"DisplayContextRepo",
|
||||
context.createWindowContext(
|
||||
displayRepository.getDisplay(DEFAULT_DISPLAY)!!,
|
||||
TYPE_APPLICATION_OVERLAY,
|
||||
/* options=*/ null,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,7 +31,6 @@ import android.view.RemoteAnimationTarget
|
||||
import android.view.SurfaceControl
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
|
||||
import android.window.RemoteTransition
|
||||
import com.android.app.displaylib.PerDisplayInstanceProviderWithTeardown
|
||||
import com.android.app.displaylib.PerDisplayRepository
|
||||
@@ -42,8 +41,9 @@ import com.android.launcher3.LauncherAnimationRunner.RemoteAnimationFactory
|
||||
import com.android.launcher3.LauncherState.NORMAL
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.compat.AccessibilityManagerCompat
|
||||
import com.android.launcher3.dagger.DisplayContext
|
||||
import com.android.launcher3.dagger.LauncherAppSingleton
|
||||
import com.android.launcher3.dagger.WindowContext
|
||||
import com.android.launcher3.desktop.DesktopRecentsTransitionController
|
||||
import com.android.launcher3.statemanager.StateManager
|
||||
import com.android.launcher3.statemanager.StateManager.AtomicAnimationFactory
|
||||
import com.android.launcher3.statemanager.StatefulContainer
|
||||
@@ -103,8 +103,13 @@ import javax.inject.Inject
|
||||
*/
|
||||
class RecentsWindowManager
|
||||
@AssistedInject
|
||||
constructor(@Assisted context: Context, wallpaperColorHints: WallpaperColorHints) :
|
||||
RecentsWindowContext(context, wallpaperColorHints.hints),
|
||||
constructor(
|
||||
@Assisted windowContext: Context,
|
||||
wallpaperColorHints: WallpaperColorHints,
|
||||
private val systemUiProxy: SystemUiProxy,
|
||||
private val recentsModel: RecentsModel,
|
||||
) :
|
||||
RecentsWindowContext(windowContext, wallpaperColorHints.hints),
|
||||
RecentsViewContainer,
|
||||
StatefulContainer<RecentsState> {
|
||||
|
||||
@@ -131,9 +136,7 @@ constructor(@Assisted context: Context, wallpaperColorHints: WallpaperColorHints
|
||||
}
|
||||
|
||||
protected var recentsView: FallbackRecentsView<RecentsWindowManager>? = null
|
||||
private val windowContext: Context = createWindowContext(TYPE_APPLICATION_OVERLAY, null)
|
||||
private val windowManager: WindowManager =
|
||||
windowContext.getSystemService(WindowManager::class.java)!!
|
||||
private val windowManager: WindowManager = getSystemService(WindowManager::class.java)!!
|
||||
private var layoutInflater: LayoutInflater = LayoutInflater.from(this).cloneInContext(this)
|
||||
private var stateManager: StateManager<RecentsState, RecentsWindowManager> =
|
||||
StateManager<RecentsState, RecentsWindowManager>(this, RecentsState.BG_LAUNCHER)
|
||||
@@ -262,11 +265,16 @@ constructor(@Assisted context: Context, wallpaperColorHints: WallpaperColorHints
|
||||
stateManager,
|
||||
/* depthController= */ null,
|
||||
statsLogManager,
|
||||
SystemUiProxy.INSTANCE[this@RecentsWindowManager],
|
||||
RecentsModel.INSTANCE[this@RecentsWindowManager],
|
||||
systemUiProxy,
|
||||
recentsModel,
|
||||
/* activityBackCallback= */ null,
|
||||
),
|
||||
/* desktopRecentsTransitionController= */ null,
|
||||
DesktopRecentsTransitionController(
|
||||
stateManager,
|
||||
systemUiProxy,
|
||||
iApplicationThread,
|
||||
/* depthController= */ null,
|
||||
),
|
||||
)
|
||||
}
|
||||
actionsView?.apply {
|
||||
@@ -494,7 +502,7 @@ constructor(@Assisted context: Context, wallpaperColorHints: WallpaperColorHints
|
||||
@AssistedFactory
|
||||
interface Factory {
|
||||
/** Creates a new instance of [RecentsWindowManager] for a given [context]. */
|
||||
fun create(@DisplayContext context: Context): RecentsWindowManager
|
||||
fun create(@WindowContext context: Context): RecentsWindowManager
|
||||
}
|
||||
}
|
||||
|
||||
@@ -503,10 +511,10 @@ class RecentsWindowManagerInstanceProvider
|
||||
@Inject
|
||||
constructor(
|
||||
private val factory: RecentsWindowManager.Factory,
|
||||
@DisplayContext private val displayContextRepository: PerDisplayRepository<Context>,
|
||||
@WindowContext private val windowContextRepository: PerDisplayRepository<Context>,
|
||||
) : PerDisplayInstanceProviderWithTeardown<RecentsWindowManager> {
|
||||
override fun createInstance(displayId: Int) =
|
||||
displayContextRepository[displayId]?.let { factory.create(it) }
|
||||
windowContextRepository[displayId]?.let { factory.create(it) }
|
||||
|
||||
override fun destroyInstance(instance: RecentsWindowManager) {
|
||||
instance.destroy()
|
||||
|
||||
+8
-2
@@ -60,6 +60,8 @@ class LauncherSwipeHandlerV2Test {
|
||||
|
||||
@Mock(answer = RETURNS_DEEP_STUBS) private lateinit var systemUiProxy: SystemUiProxy
|
||||
|
||||
@Mock(answer = RETURNS_DEEP_STUBS) private lateinit var recentsModel: RecentsModel
|
||||
|
||||
@Mock private lateinit var msdlPlayerWrapper: MSDLPlayerWrapper
|
||||
|
||||
@Mock private lateinit var rotationTouchHelper: RotationTouchHelper
|
||||
@@ -88,7 +90,9 @@ class LauncherSwipeHandlerV2Test {
|
||||
whenever(displayManager.displays).thenReturn(arrayOf(display))
|
||||
|
||||
sandboxContext.initDaggerComponent(
|
||||
DaggerTestComponent.builder().bindSystemUiProxy(systemUiProxy)
|
||||
DaggerTestComponent.builder()
|
||||
.bindSystemUiProxy(systemUiProxy)
|
||||
.bindRecentsModel(recentsModel)
|
||||
)
|
||||
gestureState =
|
||||
spy(
|
||||
@@ -135,7 +139,9 @@ class LauncherSwipeHandlerV2Test {
|
||||
interface TestComponent : LauncherAppComponent {
|
||||
@Component.Builder
|
||||
interface Builder : LauncherAppComponent.Builder {
|
||||
@BindsInstance fun bindSystemUiProxy(proxy: SystemUiProxy): Builder
|
||||
@BindsInstance fun bindSystemUiProxy(systemUiProxy: SystemUiProxy): Builder
|
||||
|
||||
@BindsInstance fun bindRecentsModel(recentsModel: RecentsModel): Builder
|
||||
|
||||
override fun build(): TestComponent
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2025 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.launcher3.dagger;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import javax.inject.Qualifier;
|
||||
|
||||
/**
|
||||
* Qualifier for per window context created using [createWindowContext].
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Qualifier
|
||||
public @interface WindowContext {
|
||||
}
|
||||
Reference in New Issue
Block a user