Merge "Fix Initialization exception when creating RecentsDisplayModel" into main
This commit is contained in:
commit
8ae40731ff
4 files changed
+17
-13
No files matched your search
@@ -23,13 +23,14 @@ import android.util.SparseArray
|
||||
import android.view.Display
|
||||
import androidx.core.util.valueIterator
|
||||
import com.android.quickstep.DisplayModel.DisplayResource
|
||||
import com.android.quickstep.SystemDecorationChangeObserver.Companion.INSTANCE
|
||||
import com.android.quickstep.SystemDecorationChangeObserver.DisplayDecorationListener
|
||||
import java.io.PrintWriter
|
||||
|
||||
/** data model for managing resources with lifecycles that match that of the connected display */
|
||||
abstract class DisplayModel<RESOURCE_TYPE : DisplayResource>(val context: Context) :
|
||||
DisplayDecorationListener {
|
||||
abstract class DisplayModel<RESOURCE_TYPE : DisplayResource>(
|
||||
val context: Context,
|
||||
private val systemDecorationChangeObserver: SystemDecorationChangeObserver,
|
||||
) : DisplayDecorationListener {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "DisplayModel"
|
||||
@@ -37,7 +38,6 @@ abstract class DisplayModel<RESOURCE_TYPE : DisplayResource>(val context: Contex
|
||||
}
|
||||
|
||||
private val displayManager = context.getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
|
||||
private var systemDecorationChangeObserver: SystemDecorationChangeObserver? = null
|
||||
protected val displayResourceArray = SparseArray<RESOURCE_TYPE>()
|
||||
|
||||
override fun onDisplayAddSystemDecorations(displayId: Int) {
|
||||
@@ -58,16 +58,14 @@ abstract class DisplayModel<RESOURCE_TYPE : DisplayResource>(val context: Contex
|
||||
protected abstract fun createDisplayResource(display: Display): RESOURCE_TYPE
|
||||
|
||||
protected fun initializeDisplays() {
|
||||
systemDecorationChangeObserver = INSTANCE[context]
|
||||
systemDecorationChangeObserver?.registerDisplayDecorationListener(this)
|
||||
systemDecorationChangeObserver.registerDisplayDecorationListener(this)
|
||||
displayManager.displays
|
||||
.filter { getDisplayResource(it.displayId) == null }
|
||||
.forEach { storeDisplayResource(it.displayId) }
|
||||
}
|
||||
|
||||
fun destroy() {
|
||||
systemDecorationChangeObserver?.unregisterDisplayDecorationListener(this)
|
||||
systemDecorationChangeObserver = null
|
||||
systemDecorationChangeObserver.unregisterDisplayDecorationListener(this)
|
||||
displayResourceArray.valueIterator().forEach { displayResource ->
|
||||
displayResource.cleanup()
|
||||
}
|
||||
|
||||
@@ -721,7 +721,8 @@ public class TouchInteractionService extends Service {
|
||||
return;
|
||||
}
|
||||
if (ENABLE_GESTURE_NAV_ON_CONNECTED_DISPLAYS.isTrue()) {
|
||||
mInputMonitorDisplayModel = new InputMonitorDisplayModel(this);
|
||||
mInputMonitorDisplayModel = new InputMonitorDisplayModel(
|
||||
this, mSystemDecorationChangeObserver);
|
||||
} else {
|
||||
mInputMonitorCompat = new InputMonitorCompat("swipe-up", DEFAULT_DISPLAY);
|
||||
mInputEventReceiver = mInputMonitorCompat.getInputReceiver(Looper.getMainLooper(),
|
||||
@@ -1359,8 +1360,9 @@ public class TouchInteractionService extends Service {
|
||||
*/
|
||||
private class InputMonitorDisplayModel extends DisplayModel<InputMonitorResource> {
|
||||
|
||||
private InputMonitorDisplayModel(Context context) {
|
||||
super(context);
|
||||
private InputMonitorDisplayModel(
|
||||
Context context, SystemDecorationChangeObserver systemDecorationChangeObserver) {
|
||||
super(context, systemDecorationChangeObserver);
|
||||
initializeDisplays();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.android.launcher3.util.DaggerSingletonTracker
|
||||
import com.android.launcher3.util.WallpaperColorHints
|
||||
import com.android.quickstep.DisplayModel
|
||||
import com.android.quickstep.FallbackWindowInterface
|
||||
import com.android.quickstep.SystemDecorationChangeObserver
|
||||
import com.android.quickstep.dagger.QuickstepBaseAppComponent
|
||||
import com.android.quickstep.fallback.window.RecentsDisplayModel.RecentsDisplayResource
|
||||
import com.android.quickstep.fallback.window.RecentsWindowFlags.Companion.enableOverviewInWindow
|
||||
@@ -40,8 +41,9 @@ class RecentsDisplayModel
|
||||
constructor(
|
||||
@ApplicationContext context: Context,
|
||||
private val wallpaperColorHints: WallpaperColorHints,
|
||||
systemDecorationChangeObserver: SystemDecorationChangeObserver,
|
||||
tracker: DaggerSingletonTracker,
|
||||
) : DisplayModel<RecentsDisplayResource>(context) {
|
||||
) : DisplayModel<RecentsDisplayResource>(context, systemDecorationChangeObserver) {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "RecentsDisplayModel"
|
||||
|
||||
@@ -31,6 +31,8 @@ import org.junit.runner.RunWith
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class DisplayModelTest {
|
||||
private val context: Context = ApplicationProvider.getApplicationContext()
|
||||
private val systemDecorationChangeObserver =
|
||||
SystemDecorationChangeObserver.INSTANCE.get(context)
|
||||
|
||||
class TestableResource : DisplayModel.DisplayResource() {
|
||||
var isCleanupCalled = false
|
||||
@@ -45,7 +47,7 @@ class DisplayModelTest {
|
||||
}
|
||||
|
||||
private val testableDisplayModel =
|
||||
object : DisplayModel<TestableResource>(context) {
|
||||
object : DisplayModel<TestableResource>(context, systemDecorationChangeObserver) {
|
||||
override fun createDisplayResource(display: Display): TestableResource {
|
||||
return TestableResource()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user