1 package com.android.systemui.mediaprojection.appselector.view 2 3 import android.graphics.Insets 4 import android.graphics.Rect 5 import android.view.WindowInsets 6 import android.view.WindowManager 7 import javax.inject.Inject 8 9 /** Provides values related to window metrics. */ 10 interface WindowMetricsProvider { 11 12 val maximumWindowBounds: Rect 13 14 val currentWindowInsets: Insets 15 } 16 17 class WindowMetricsProviderImpl 18 @Inject 19 constructor( 20 private val windowManager: WindowManager, 21 ) : WindowMetricsProvider { 22 override val maximumWindowBounds: Rect 23 get() = windowManager.maximumWindowMetrics.bounds 24 25 override val currentWindowInsets: Insets 26 get() = 27 windowManager.currentWindowMetrics.windowInsets.getInsets( 28 WindowInsets.Type.tappableElement() 29 ) 30 } 31