diff options
121 files changed, 671 insertions, 729 deletions
diff --git a/core/java/android/view/WindowManagerImpl.java b/core/java/android/view/WindowManagerImpl.java index 97cf8fc748e8..8944c3fa0b19 100644 --- a/core/java/android/view/WindowManagerImpl.java +++ b/core/java/android/view/WindowManagerImpl.java @@ -120,7 +120,7 @@ public class WindowManagerImpl implements WindowManager { this(context, null /* parentWindow */, null /* clientToken */); } - private WindowManagerImpl(Context context, Window parentWindow, + public WindowManagerImpl(Context context, Window parentWindow, @Nullable IBinder windowContextToken) { mContext = context; mParentWindow = parentWindow; diff --git a/packages/SystemUI/accessibility/accessibilitymenu/Android.bp b/packages/SystemUI/accessibility/accessibilitymenu/Android.bp index fb1f715bc68f..172f687ef6fd 100644 --- a/packages/SystemUI/accessibility/accessibilitymenu/Android.bp +++ b/packages/SystemUI/accessibility/accessibilitymenu/Android.bp @@ -40,6 +40,7 @@ android_app { "com_android_systemui_flags_lib", "SettingsLibDisplayUtils", "SettingsLibSettingsTheme", + "SystemUI-shared-utils", "com_android_a11y_menu_flags_lib", "//frameworks/libs/systemui:view_capture", ], diff --git a/packages/SystemUI/accessibility/accessibilitymenu/src/com/android/systemui/accessibility/accessibilitymenu/view/A11yMenuOverlayLayout.java b/packages/SystemUI/accessibility/accessibilitymenu/src/com/android/systemui/accessibility/accessibilitymenu/view/A11yMenuOverlayLayout.java index a60778658c59..db2fbd96408c 100644 --- a/packages/SystemUI/accessibility/accessibilitymenu/src/com/android/systemui/accessibility/accessibilitymenu/view/A11yMenuOverlayLayout.java +++ b/packages/SystemUI/accessibility/accessibilitymenu/src/com/android/systemui/accessibility/accessibilitymenu/view/A11yMenuOverlayLayout.java @@ -22,8 +22,6 @@ import static android.view.Display.DEFAULT_DISPLAY; import static android.view.View.ACCESSIBILITY_LIVE_REGION_POLITE; import static android.view.WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY; -import static com.android.app.viewcapture.ViewCaptureFactory.getViewCaptureAwareWindowManagerInstance; - import static java.lang.Math.max; import android.animation.Animator; @@ -55,11 +53,11 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.UiContext; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.systemui.accessibility.accessibilitymenu.AccessibilityMenuService; import com.android.systemui.accessibility.accessibilitymenu.R; import com.android.systemui.accessibility.accessibilitymenu.activity.A11yMenuSettingsActivity.A11yMenuPreferenceFragment; import com.android.systemui.accessibility.accessibilitymenu.model.A11yMenuShortcut; +import com.android.systemui.utils.windowmanager.WindowManagerUtils; import java.util.ArrayList; import java.util.List; @@ -145,9 +143,7 @@ public class A11yMenuOverlayLayout { final Display display = mDisplayManager.getDisplay(DEFAULT_DISPLAY); final Context uiContext = mService.createWindowContext( display, TYPE_ACCESSIBILITY_OVERLAY, /* options= */null); - final ViewCaptureAwareWindowManager windowManager = - getViewCaptureAwareWindowManagerInstance(uiContext, - com.android.systemui.Flags.enableViewCaptureTracing()); + final WindowManager windowManager = WindowManagerUtils.getWindowManager(uiContext); mLayout = new A11yMenuFrameLayout(uiContext); updateLayoutPosition(uiContext); inflateLayoutAndSetOnTouchListener(mLayout, uiContext); @@ -162,8 +158,7 @@ public class A11yMenuOverlayLayout { public void clearLayout() { if (mLayout != null) { - ViewCaptureAwareWindowManager windowManager = getViewCaptureAwareWindowManagerInstance( - mLayout.getContext(), com.android.systemui.Flags.enableViewCaptureTracing()); + WindowManager windowManager = WindowManagerUtils.getWindowManager(mLayout.getContext()); if (windowManager != null) { windowManager.removeView(mLayout); } @@ -178,7 +173,7 @@ public class A11yMenuOverlayLayout { return; } updateLayoutPosition(mLayout.getContext()); - WindowManager windowManager = mLayout.getContext().getSystemService(WindowManager.class); + WindowManager windowManager = WindowManagerUtils.getWindowManager(mLayout.getContext()); if (windowManager != null) { windowManager.updateViewLayout(mLayout, mLayoutParameter); } diff --git a/packages/SystemUI/accessibility/accessibilitymenu/src/com/android/systemui/accessibility/accessibilitymenu/view/A11yMenuViewPager.java b/packages/SystemUI/accessibility/accessibilitymenu/src/com/android/systemui/accessibility/accessibilitymenu/view/A11yMenuViewPager.java index b899c45b0f7e..842834b5fc27 100644 --- a/packages/SystemUI/accessibility/accessibilitymenu/src/com/android/systemui/accessibility/accessibilitymenu/view/A11yMenuViewPager.java +++ b/packages/SystemUI/accessibility/accessibilitymenu/src/com/android/systemui/accessibility/accessibilitymenu/view/A11yMenuViewPager.java @@ -36,6 +36,7 @@ import com.android.systemui.accessibility.accessibilitymenu.R; import com.android.systemui.accessibility.accessibilitymenu.activity.A11yMenuSettingsActivity.A11yMenuPreferenceFragment; import com.android.systemui.accessibility.accessibilitymenu.model.A11yMenuShortcut; import com.android.systemui.accessibility.accessibilitymenu.view.A11yMenuFooter.A11yMenuFooterCallBack; +import com.android.systemui.utils.windowmanager.WindowManagerUtils; import java.util.ArrayList; import java.util.List; @@ -292,8 +293,8 @@ public class A11yMenuViewPager { // Keeps footer window height unchanged no matter the density is changed. mA11yMenuFooter.adjustFooterToDensityScale(densityScale); // Adjust the view pager height for system bar and display cutout insets. - WindowManager windowManager = mA11yMenuLayout.getContext() - .getSystemService(WindowManager.class); + WindowManager windowManager = WindowManagerUtils + .getWindowManager(mA11yMenuLayout.getContext()); WindowMetrics windowMetric = windowManager.getCurrentWindowMetrics(); Insets windowInsets = windowMetric.getWindowInsets().getInsetsIgnoringVisibility( WindowInsets.Type.systemBars() | WindowInsets.Type.displayCutout()); diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/MagnificationModeSwitchTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/MagnificationModeSwitchTest.java index aa95abb3528f..0b0088926aae 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/MagnificationModeSwitchTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/MagnificationModeSwitchTest.java @@ -73,14 +73,10 @@ import android.widget.ImageView; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; -import com.android.app.viewcapture.ViewCapture; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.graphics.SfVsyncFrameCallbackProvider; import com.android.systemui.SysuiTestCase; import com.android.systemui.res.R; -import kotlin.Lazy; - import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -108,8 +104,6 @@ public class MagnificationModeSwitchTest extends SysuiTestCase { private SfVsyncFrameCallbackProvider mSfVsyncFrameProvider; @Mock private MagnificationModeSwitch.ClickListener mClickListener; - @Mock - private Lazy<ViewCapture> mLazyViewCapture; private TestableWindowManager mWindowManager; private ViewPropertyAnimator mViewPropertyAnimator; private MagnificationModeSwitch mMagnificationModeSwitch; @@ -123,7 +117,6 @@ public class MagnificationModeSwitchTest extends SysuiTestCase { mContext = Mockito.spy(getContext()); final WindowManager wm = mContext.getSystemService(WindowManager.class); mWindowManager = spy(new TestableWindowManager(wm)); - mContext.addMockSystemService(Context.WINDOW_SERVICE, mWindowManager); mContext.addMockSystemService(Context.ACCESSIBILITY_SERVICE, mAccessibilityManager); mSpyImageView = Mockito.spy(new ImageView(mContext)); mViewPropertyAnimator = Mockito.spy(mSpyImageView.animate()); @@ -139,10 +132,8 @@ public class MagnificationModeSwitchTest extends SysuiTestCase { return null; }).when(mSfVsyncFrameProvider).postFrameCallback( any(Choreographer.FrameCallback.class)); - ViewCaptureAwareWindowManager vwm = new ViewCaptureAwareWindowManager(mWindowManager, - mLazyViewCapture, false); - mMagnificationModeSwitch = new MagnificationModeSwitch(mContext, mSpyImageView, - mSfVsyncFrameProvider, mClickListener, vwm); + mMagnificationModeSwitch = new MagnificationModeSwitch(mContext, mWindowManager, + mSpyImageView, mSfVsyncFrameProvider, mClickListener); assertNotNull(mTouchListener); } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/MagnificationSettingsControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/MagnificationSettingsControllerTest.java index 3cd3fefb8ef0..02ec5aac120c 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/MagnificationSettingsControllerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/MagnificationSettingsControllerTest.java @@ -23,11 +23,11 @@ import static org.mockito.Mockito.verify; import android.content.pm.ActivityInfo; import android.testing.TestableLooper; +import android.view.WindowManager; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.graphics.SfVsyncFrameCallbackProvider; import com.android.systemui.SysuiTestCase; import com.android.systemui.accessibility.WindowMagnificationSettings.MagnificationSize; @@ -58,15 +58,15 @@ public class MagnificationSettingsControllerTest extends SysuiTestCase { @Mock private SecureSettings mSecureSettings; @Mock - private ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager; + private WindowManager mWindowManager; @Before public void setUp() { MockitoAnnotations.initMocks(this); mMagnificationSettingsController = new MagnificationSettingsController( mContext, mSfVsyncFrameProvider, - mMagnificationSettingControllerCallback, mSecureSettings, - mWindowMagnificationSettings, mViewCaptureAwareWindowManager); + mMagnificationSettingControllerCallback, mSecureSettings, mWindowManager, + mWindowMagnificationSettings); } @After diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/MirrorWindowControlTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/MirrorWindowControlTest.java index 12c866f0adb2..463bfe5ae73f 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/MirrorWindowControlTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/MirrorWindowControlTest.java @@ -27,14 +27,15 @@ import static org.mockito.Mockito.verify; import android.content.Context; import android.graphics.Point; +import android.os.Looper; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.WindowManager; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.systemui.SysuiTestCase; import org.junit.Before; @@ -48,7 +49,7 @@ import org.mockito.MockitoAnnotations; @RunWith(AndroidJUnit4.class) public class MirrorWindowControlTest extends SysuiTestCase { - @Mock ViewCaptureAwareWindowManager mWindowManager; + @Mock WindowManager mWindowManager; View mView; int mViewWidth; int mViewHeight; @@ -69,8 +70,12 @@ public class MirrorWindowControlTest extends SysuiTestCase { return null; }).when(mWindowManager).addView(any(View.class), any(LayoutParams.class)); + if (Looper.myLooper() == null) { + Looper.prepare(); + } + mStubMirrorWindowControl = new StubMirrorWindowControl(getContext(), mView, mViewWidth, - mViewHeight); + mViewHeight, mWindowManager); } @Test @@ -122,8 +127,9 @@ public class MirrorWindowControlTest extends SysuiTestCase { boolean mInvokeOnCreateView = false; - StubMirrorWindowControl(Context context, View view, int width, int height) { - super(context); + StubMirrorWindowControl(Context context, View view, int width, int height, + WindowManager windowManager) { + super(context, windowManager); mView = view; mWidth = width; mHeight = height; diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/ModeSwitchesControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/ModeSwitchesControllerTest.java index e1e515eb31f5..b1c837a99f3d 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/ModeSwitchesControllerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/ModeSwitchesControllerTest.java @@ -24,11 +24,11 @@ import android.provider.Settings; import android.testing.TestableLooper; import android.view.Display; import android.view.View; +import android.view.WindowManager; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.systemui.SysuiTestCase; import org.junit.After; @@ -51,8 +51,6 @@ public class ModeSwitchesControllerTest extends SysuiTestCase { private View mSpyView; @Mock private MagnificationModeSwitch.ClickListener mListener; - @Mock - private ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager; @Before @@ -61,8 +59,9 @@ public class ModeSwitchesControllerTest extends SysuiTestCase { mSupplier = new FakeSwitchSupplier(mContext.getSystemService(DisplayManager.class)); mModeSwitchesController = new ModeSwitchesController(mSupplier); mModeSwitchesController.setClickListenerDelegate(mListener); - mModeSwitch = Mockito.spy(new MagnificationModeSwitch(mContext, mModeSwitchesController, - mViewCaptureAwareWindowManager)); + WindowManager wm = mContext.getSystemService(WindowManager.class); + mModeSwitch = Mockito.spy(new MagnificationModeSwitch(mContext, wm, + mModeSwitchesController)); mSpyView = Mockito.spy(new View(mContext)); } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/DragToInteractAnimationControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/DragToInteractAnimationControllerTest.java index 6edf94939010..95ebd8190e9c 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/DragToInteractAnimationControllerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/DragToInteractAnimationControllerTest.java @@ -72,7 +72,7 @@ public class DragToInteractAnimationControllerTest extends SysuiTestCase { stubWindowManager); final MenuView stubMenuView = spy(new MenuView(mContext, stubMenuViewModel, stubMenuViewAppearance, mockSecureSettings)); - mInteractView = spy(new DragToInteractView(mContext)); + mInteractView = spy(new DragToInteractView(mContext, stubWindowManager)); mDismissView = spy(new DismissView(mContext)); if (Flags.floatingMenuDragToEdit()) { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuListViewTouchHandlerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuListViewTouchHandlerTest.java index fff6def52803..572d140b850d 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuListViewTouchHandlerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuListViewTouchHandlerTest.java @@ -101,7 +101,7 @@ public class MenuListViewTouchHandlerTest extends SysuiTestCase { mStubMenuView.setTranslationY(0); mMenuAnimationController = spy(new MenuAnimationController( mStubMenuView, stubMenuViewAppearance)); - mInteractView = spy(new DragToInteractView(mContext)); + mInteractView = spy(new DragToInteractView(mContext, windowManager)); mDismissView = spy(new DismissView(mContext)); if (Flags.floatingMenuDragToEdit()) { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerControllerTest.java index 4f043109a534..b5fa52570d6a 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerControllerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerControllerTest.java @@ -39,15 +39,11 @@ import android.view.accessibility.AccessibilityManager; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; -import com.android.app.viewcapture.ViewCapture; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.settingslib.bluetooth.HearingAidDeviceManager; import com.android.systemui.SysuiTestCase; import com.android.systemui.navigationbar.NavigationModeController; import com.android.systemui.util.settings.SecureSettings; -import kotlin.Lazy; - import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -78,16 +74,11 @@ public class MenuViewLayerControllerTest extends SysuiTestCase { @Mock private WindowMetrics mWindowMetrics; - @Mock - private Lazy<ViewCapture> mLazyViewCapture; - private MenuViewLayerController mMenuViewLayerController; @Before public void setUp() throws Exception { final WindowManager wm = mContext.getSystemService(WindowManager.class); - final ViewCaptureAwareWindowManager viewCaptureAwareWm = new ViewCaptureAwareWindowManager( - mWindowManager, mLazyViewCapture, /* isViewCaptureEnabled= */ false); doAnswer(invocation -> wm.getMaximumWindowMetrics()).when( mWindowManager).getMaximumWindowMetrics(); mContext.addMockSystemService(Context.WINDOW_SERVICE, mWindowManager); @@ -95,8 +86,8 @@ public class MenuViewLayerControllerTest extends SysuiTestCase { when(mWindowMetrics.getBounds()).thenReturn(new Rect(0, 0, 1080, 2340)); when(mWindowMetrics.getWindowInsets()).thenReturn(stubDisplayInsets()); mMenuViewLayerController = new MenuViewLayerController(mContext, mWindowManager, - viewCaptureAwareWm, mAccessibilityManager, mSecureSettings, - mock(NavigationModeController.class), mHearingAidDeviceManager); + mAccessibilityManager, mSecureSettings, mock(NavigationModeController.class), + mHearingAidDeviceManager); } @Test diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt index 446891a7873e..c4fafc192260 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt @@ -41,7 +41,6 @@ import android.widget.ScrollView import androidx.constraintlayout.widget.ConstraintLayout import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest -import com.android.app.viewcapture.ViewCapture import com.android.internal.jank.InteractionJankMonitor import com.android.internal.widget.LockPatternUtils import com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_PATTERN @@ -116,7 +115,6 @@ open class AuthContainerViewTest : SysuiTestCase() { @Mock private lateinit var packageManager: PackageManager @Mock private lateinit var activityTaskManager: ActivityTaskManager @Mock private lateinit var accessibilityManager: AccessibilityManager - @Mock private lateinit var lazyViewCapture: Lazy<ViewCapture> private lateinit var displayRepository: FakeDisplayRepository private lateinit var displayStateInteractor: DisplayStateInteractor @@ -689,7 +687,6 @@ open class AuthContainerViewTest : SysuiTestCase() { { credentialViewModel }, fakeExecutor, vibrator, - lazyViewCapture, msdlPlayer, ) { override fun postOnAnimation(runnable: Runnable) { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/AuthControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/AuthControllerTest.java index a1a2aa70d869..f4185ee48510 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/AuthControllerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/AuthControllerTest.java @@ -83,7 +83,6 @@ import android.view.WindowManager; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; -import com.android.app.viewcapture.ViewCapture; import com.android.internal.R; import com.android.internal.jank.InteractionJankMonitor; import com.android.internal.widget.LockPatternUtils; @@ -100,11 +99,10 @@ import com.android.systemui.util.concurrency.Execution; import com.android.systemui.util.concurrency.FakeExecution; import com.android.systemui.util.concurrency.FakeExecutor; import com.android.systemui.util.time.FakeSystemClock; +import com.android.systemui.utils.windowmanager.WindowManagerProvider; import com.google.android.msdl.domain.MSDLPlayer; -import dagger.Lazy; - import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -175,8 +173,6 @@ public class AuthControllerTest extends SysuiTestCase { private PromptViewModel mPromptViewModel; @Mock private UdfpsUtils mUdfpsUtils; - @Mock - private Lazy<ViewCapture> mLazyViewCapture; @Captor private ArgumentCaptor<IFingerprintAuthenticatorsRegisteredCallback> mFpAuthenticatorsRegisteredCaptor; @@ -198,6 +194,8 @@ public class AuthControllerTest extends SysuiTestCase { private KeyguardManager mKeyguardManager; @Mock private MSDLPlayer mMSDLPlayer; + @Mock + private WindowManagerProvider mWindowManagerProvider; private TestableContext mContextSpy; private Execution mExecution; @@ -1198,7 +1196,8 @@ public class AuthControllerTest extends SysuiTestCase { when(mDisplayManager.getDisplay(displayId)).thenReturn(mockDisplay); } doReturn(mockDisplayContext).when(mContextSpy).createDisplayContext(mockDisplay); - when(mockDisplayContext.getSystemService(WindowManager.class)).thenReturn(mockDisplayWM); + when(mWindowManagerProvider.getWindowManager(mockDisplayContext)) + .thenReturn(mockDisplayWM); return mockDisplayWM; } @@ -1214,7 +1213,7 @@ public class AuthControllerTest extends SysuiTestCase { () -> mLogContextInteractor, () -> mPromptSelectionInteractor, () -> mCredentialViewModel, () -> mPromptViewModel, mInteractionJankMonitor, mHandler, mBackgroundExecutor, mUdfpsUtils, mVibratorHelper, mKeyguardManager, - mLazyViewCapture, mMSDLPlayer); + mMSDLPlayer, mWindowManagerProvider); } @Override diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/UdfpsControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/UdfpsControllerTest.java index a2f5a30a20ff..675c9deaff23 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/UdfpsControllerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/UdfpsControllerTest.java @@ -45,12 +45,12 @@ import android.view.LayoutInflater; import android.view.Surface; import android.view.View; import android.view.ViewRootImpl; +import android.view.WindowManager; import android.view.accessibility.AccessibilityManager; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.logging.InstanceIdSequence; import com.android.internal.util.LatencyTracker; import com.android.keyguard.KeyguardUpdateMonitor; @@ -129,7 +129,7 @@ public class UdfpsControllerTest extends SysuiTestCase { @Mock private FingerprintManager mFingerprintManager; @Mock - private ViewCaptureAwareWindowManager mWindowManager; + private WindowManager mWindowManager; @Mock private StatusBarStateController mStatusBarStateController; @Mock diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/DreamOverlayServiceTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/DreamOverlayServiceTest.kt index b42eddd12e4e..fd99313a17b7 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/DreamOverlayServiceTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/DreamOverlayServiceTest.kt @@ -36,7 +36,6 @@ import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LifecycleRegistry import androidx.test.filters.SmallTest -import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.app.viewcapture.ViewCaptureFactory import com.android.compose.animation.scene.ObservableTransitionState import com.android.internal.logging.UiEventLogger @@ -143,7 +142,6 @@ class DreamOverlayServiceTest(flags: FlagsParameterization?) : SysuiTestCase() { mock<ScrimManager> { on { currentController }.thenReturn(mScrimController) } private val mSystemDialogsCloser = mock<SystemDialogsCloser>() private val mDreamOverlayCallbackController = mock<DreamOverlayCallbackController>() - private val mLazyViewCapture = lazy { viewCaptureSpy } private val mViewCaptor = argumentCaptor<View>() private val mTouchHandlersCaptor = argumentCaptor<Set<TouchHandler>>() @@ -156,7 +154,6 @@ class DreamOverlayServiceTest(flags: FlagsParameterization?) : SysuiTestCase() { private val gestureInteractor = spy(kosmos.gestureInteractor) private lateinit var mCommunalInteractor: CommunalInteractor - private lateinit var mViewCaptureAwareWindowManager: ViewCaptureAwareWindowManager private lateinit var environmentComponents: EnvironmentComponents private lateinit var mService: DreamOverlayService @@ -244,18 +241,12 @@ class DreamOverlayServiceTest(flags: FlagsParameterization?) : SysuiTestCase() { mComplicationComponentFactory, mAmbientTouchComponentFactory, ) - mViewCaptureAwareWindowManager = - ViewCaptureAwareWindowManager( - mWindowManager, - mLazyViewCapture, - isViewCaptureEnabled = false, - ) mService = DreamOverlayService( mContext, mLifecycleOwner, mMainExecutor, - mViewCaptureAwareWindowManager, + mWindowManager, mComplicationComponentFactory, mDreamComplicationComponentFactory, mDreamOverlayComponentFactory, diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/mediaprojection/appselector/view/TaskPreviewSizeProviderTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/mediaprojection/appselector/view/TaskPreviewSizeProviderTest.kt index 55e52b780488..18b14a4b3752 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/mediaprojection/appselector/view/TaskPreviewSizeProviderTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/mediaprojection/appselector/view/TaskPreviewSizeProviderTest.kt @@ -55,8 +55,6 @@ class TaskPreviewSizeProviderTest : SysuiTestCase() { @Before fun setup() { - whenever(mockContext.getSystemService(eq(WindowManager::class.java))) - .thenReturn(windowManager) whenever(mockContext.resources).thenReturn(resources) } @@ -154,7 +152,8 @@ class TaskPreviewSizeProviderTest : SysuiTestCase() { return TaskPreviewSizeProvider( mockContext, windowMetricsProvider, - testConfigurationController + testConfigurationController, + windowManager ) .also { it.addCallback(listener) } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/navigationbar/views/NavigationBarTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/navigationbar/views/NavigationBarTest.java index 09e49eb217b0..0e8c5079579e 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/navigationbar/views/NavigationBarTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/navigationbar/views/NavigationBarTest.java @@ -82,7 +82,6 @@ import android.view.inputmethod.InputMethodManager; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.UiEventLogger; import com.android.systemui.SysuiTestCase; @@ -218,8 +217,6 @@ public class NavigationBarTest extends SysuiTestCase { @Mock private WindowManager mWindowManager; @Mock - private ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager; - @Mock private TelecomManager mTelecomManager; @Mock private InputMethodManager mInputMethodManager; @@ -685,7 +682,6 @@ public class NavigationBarTest extends SysuiTestCase { null, context, mWindowManager, - mViewCaptureAwareWindowManager, () -> mAssistManager, mock(AccessibilityManager.class), deviceProvisionedController, diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/power/PowerUITest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/power/PowerUITest.java index 338ed7596bd6..70ded2a7f21c 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/power/PowerUITest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/power/PowerUITest.java @@ -40,11 +40,11 @@ import android.service.vr.IVrStateCallbacks; import android.testing.TestableLooper; import android.testing.TestableLooper.RunWithLooper; import android.testing.TestableResources; +import android.view.WindowManager; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; -import com.android.app.viewcapture.ViewCapture; import com.android.settingslib.fuelgauge.Estimate; import com.android.systemui.SysuiTestCase; import com.android.systemui.broadcast.BroadcastDispatcher; @@ -54,8 +54,6 @@ import com.android.systemui.res.R; import com.android.systemui.settings.UserTracker; import com.android.systemui.statusbar.CommandQueue; -import dagger.Lazy; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -96,7 +94,7 @@ public class PowerUITest extends SysuiTestCase { @Mock private BroadcastDispatcher mBroadcastDispatcher; @Mock private CommandQueue mCommandQueue; @Mock private IVrManager mVrManager; - @Mock private Lazy<ViewCapture> mLazyViewCapture; + @Mock private WindowManager mWindowManager; @Before public void setup() { @@ -709,7 +707,7 @@ public class PowerUITest extends SysuiTestCase { mWakefulnessLifecycle, mPowerManager, mUserTracker, - mLazyViewCapture); + mWindowManager); mPowerUI.mThermalService = mThermalServiceMock; } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java index 94db429c2225..676e1ea5321a 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java @@ -172,6 +172,7 @@ import com.android.systemui.user.domain.interactor.UserSwitcherInteractor; import com.android.systemui.util.kotlin.JavaAdapter; import com.android.systemui.util.time.FakeSystemClock; import com.android.systemui.util.time.SystemClock; +import com.android.systemui.utils.windowmanager.WindowManagerProvider; import com.android.systemui.wallpapers.ui.viewmodel.WallpaperFocalAreaViewModel; import com.android.wm.shell.animation.FlingAnimationUtils; @@ -296,6 +297,7 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { @Mock private LargeScreenHeaderHelper mLargeScreenHeaderHelper; @Mock private StatusBarLongPressGestureDetector mStatusBarLongPressGestureDetector; @Mock protected SysUIStateDisplaysInteractor mSysUIStateDisplaysInteractor; + @Mock private WindowManagerProvider mWindowManagerProvider; protected final int mMaxUdfpsBurnInOffsetY = 5; protected FakeFeatureFlagsClassic mFeatureFlags = new FakeFeatureFlagsClassic(); protected KeyguardClockInteractor mKeyguardClockInteractor; @@ -672,7 +674,8 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { mCastController, new ResourcesSplitShadeStateController(), () -> mKosmos.getCommunalTransitionViewModel(), - () -> mLargeScreenHeaderHelper + () -> mLargeScreenHeaderHelper, + mWindowManagerProvider ); } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationShadeWindowControllerImplTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationShadeWindowControllerImplTest.java index 3788049256a2..fd17b7a32fd3 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationShadeWindowControllerImplTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationShadeWindowControllerImplTest.java @@ -50,7 +50,6 @@ import android.view.WindowManager; import androidx.test.filters.SmallTest; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.colorextraction.ColorExtractor; import com.android.systemui.Flags; import com.android.systemui.SysuiTestCase; @@ -100,7 +99,7 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase { @Rule public final CheckFlagsRule checkFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule(); - @Mock private ViewCaptureAwareWindowManager mWindowManager; + @Mock private WindowManager mWindowManager; @Mock private DozeParameters mDozeParameters; @Spy private final NotificationShadeWindowView mNotificationShadeWindowView = spy( new NotificationShadeWindowView(mContext, null)); diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/QuickSettingsControllerImplBaseTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/QuickSettingsControllerImplBaseTest.java index 7433267ab3b0..db0c07c50dc6 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/QuickSettingsControllerImplBaseTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/QuickSettingsControllerImplBaseTest.java @@ -28,6 +28,7 @@ import android.os.Handler; import android.os.Looper; import android.view.ViewGroup; import android.view.ViewParent; +import android.view.WindowManager; import android.view.accessibility.AccessibilityManager; import com.android.internal.logging.MetricsLogger; @@ -79,6 +80,7 @@ import com.android.systemui.statusbar.policy.data.repository.FakeUserSetupReposi import com.android.systemui.user.domain.interactor.SelectedUserInteractor; import com.android.systemui.user.domain.interactor.UserSwitcherInteractor; import com.android.systemui.util.kotlin.JavaAdapter; +import com.android.systemui.utils.windowmanager.WindowManagerProvider; import dagger.Lazy; @@ -147,6 +149,7 @@ public class QuickSettingsControllerImplBaseTest extends SysuiTestCase { @Mock protected UserSwitcherInteractor mUserSwitcherInteractor; @Mock protected SelectedUserInteractor mSelectedUserInteractor; @Mock protected LargeScreenHeaderHelper mLargeScreenHeaderHelper; + @Mock protected WindowManagerProvider mWindowManagerProvider; protected FakeDisableFlagsRepository mDisableFlagsRepository = mKosmos.getFakeDisableFlagsRepository(); @@ -232,6 +235,9 @@ public class QuickSettingsControllerImplBaseTest extends SysuiTestCase { mMainHandler = new Handler(Looper.getMainLooper()); + WindowManager wm = mContext.getSystemService(WindowManager.class); + when(mWindowManagerProvider.getWindowManager(mContext)).thenReturn(wm); + mQsController = new QuickSettingsControllerImpl( mPanelViewControllerLazy, mPanelView, @@ -268,7 +274,8 @@ public class QuickSettingsControllerImplBaseTest extends SysuiTestCase { mCastController, splitShadeStateController, () -> mKosmos.getCommunalTransitionViewModel(), - () -> mLargeScreenHeaderHelper + () -> mLargeScreenHeaderHelper, + mWindowManagerProvider ); mQsController.init(); diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/topwindoweffects/TopLevelWindowEffectsTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/topwindoweffects/TopLevelWindowEffectsTest.kt index 6d3813c90bfd..bcc6ea3d3b35 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/topwindoweffects/TopLevelWindowEffectsTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/topwindoweffects/TopLevelWindowEffectsTest.kt @@ -20,8 +20,6 @@ import android.view.View import android.view.WindowManager import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest -import com.android.app.viewcapture.ViewCapture -import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.systemui.SysuiTestCase import com.android.systemui.keyevent.data.repository.fakeKeyEventRepository import com.android.systemui.keyevent.data.repository.keyEventRepository @@ -58,20 +56,13 @@ class TopLevelWindowEffectsTest : SysuiTestCase() { private lateinit var windowManager: WindowManager @Mock - private lateinit var viewCapture: Lazy<ViewCapture> - - @Mock private lateinit var viewModelFactory: SqueezeEffectViewModel.Factory private val Kosmos.underTest by Kosmos.Fixture { TopLevelWindowEffects( context = mContext, applicationScope = testScope.backgroundScope, - windowManager = ViewCaptureAwareWindowManager( - windowManager = windowManager, - lazyViewCapture = viewCapture, - isViewCaptureEnabled = false - ), + windowManager = windowManager, keyEventInteractor = keyEventInteractor, viewModelFactory = viewModelFactory, squeezeEffectInteractor = SqueezeEffectInteractor( diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/wallpapers/ImageWallpaperTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/wallpapers/ImageWallpaperTest.java index 60a15915fb77..046b5d701ddf 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/wallpapers/ImageWallpaperTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/wallpapers/ImageWallpaperTest.java @@ -57,6 +57,7 @@ import com.android.systemui.SysuiTestCase; import com.android.systemui.settings.UserTracker; import com.android.systemui.util.concurrency.FakeExecutor; import com.android.systemui.util.time.FakeSystemClock; +import com.android.systemui.utils.windowmanager.WindowManagerProvider; import org.junit.Before; import org.junit.Test; @@ -89,6 +90,8 @@ public class ImageWallpaperTest extends SysuiTestCase { private Context mMockContext; @Mock private UserTracker mUserTracker; + @Mock + private WindowManagerProvider mWindowManagerProvider; @Mock private Bitmap mWallpaperBitmap; @@ -105,7 +108,7 @@ public class ImageWallpaperTest extends SysuiTestCase { when(mWindowMetrics.getBounds()).thenReturn( new Rect(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT)); when(mWindowManager.getCurrentWindowMetrics()).thenReturn(mWindowMetrics); - when(mMockContext.getSystemService(WindowManager.class)).thenReturn(mWindowManager); + when(mWindowManagerProvider.getWindowManager(any())).thenReturn(mWindowManager); // set up display manager doNothing().when(mDisplayManager).registerDisplayListener(any(), any()); @@ -182,7 +185,7 @@ public class ImageWallpaperTest extends SysuiTestCase { } private ImageWallpaper createImageWallpaper() { - return new ImageWallpaper(mFakeExecutor, mUserTracker) { + return new ImageWallpaper(mFakeExecutor, mUserTracker, mWindowManagerProvider) { @Override public Engine onCreateEngine() { return new CanvasEngine() { diff --git a/packages/SystemUI/shared/biometrics/Android.bp b/packages/SystemUI/shared/biometrics/Android.bp index 63de81d4a680..208157c69adf 100644 --- a/packages/SystemUI/shared/biometrics/Android.bp +++ b/packages/SystemUI/shared/biometrics/Android.bp @@ -14,6 +14,9 @@ android_library { "src/**/*.java", "src/**/*.kt", ], + static_libs: [ + "SystemUI-shared-utils", + ], resource_dirs: [ "res", ], diff --git a/packages/SystemUI/shared/biometrics/src/com/android/systemui/biometrics/Utils.kt b/packages/SystemUI/shared/biometrics/src/com/android/systemui/biometrics/Utils.kt index 5b99a3f16fc2..7aa09cf64405 100644 --- a/packages/SystemUI/shared/biometrics/src/com/android/systemui/biometrics/Utils.kt +++ b/packages/SystemUI/shared/biometrics/src/com/android/systemui/biometrics/Utils.kt @@ -41,6 +41,7 @@ import com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_PASSWORD import com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_PATTERN import com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_PIN import com.android.systemui.biometrics.shared.model.PromptKind +import com.android.systemui.utils.windowmanager.WindowManagerUtils object Utils { private const val TAG = "SysUIBiometricUtils" @@ -117,10 +118,9 @@ object Utils { @JvmStatic fun getNavbarInsets(context: Context): Insets { - val windowManager: WindowManager? = context.getSystemService(WindowManager::class.java) - val windowMetrics: WindowMetrics? = windowManager?.maximumWindowMetrics - return windowMetrics?.windowInsets?.getInsets(WindowInsets.Type.navigationBars()) - ?: Insets.NONE + val windowManager: WindowManager = WindowManagerUtils.getWindowManager(context) + val windowMetrics: WindowMetrics = windowManager.maximumWindowMetrics + return windowMetrics.windowInsets.getInsets(WindowInsets.Type.navigationBars()) } /** Converts `drawable` to a [Bitmap]. */ diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/Utilities.java b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/Utilities.java index c82243934b8b..b1fc560f406b 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/Utilities.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/Utilities.java @@ -37,6 +37,7 @@ import android.view.Surface; import android.view.WindowManager; import com.android.systemui.shared.recents.model.Task; +import com.android.systemui.utils.windowmanager.WindowManagerUtils; /* Common code */ public class Utilities { @@ -152,7 +153,7 @@ public class Utilities { /** @return whether or not {@param context} represents that of a large screen device or not */ @TargetApi(Build.VERSION_CODES.R) public static boolean isLargeScreen(Context context) { - return isLargeScreen(context.getSystemService(WindowManager.class), context.getResources()); + return isLargeScreen(WindowManagerUtils.getWindowManager(context), context.getResources()); } /** @return whether or not {@param context} represents that of a large screen device or not */ diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/rotation/FloatingRotationButton.java b/packages/SystemUI/shared/src/com/android/systemui/shared/rotation/FloatingRotationButton.java index 4db6ab6ea579..570d774b95e9 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/rotation/FloatingRotationButton.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/rotation/FloatingRotationButton.java @@ -16,9 +16,6 @@ package com.android.systemui.shared.rotation; -import static com.android.app.viewcapture.ViewCaptureFactory.getViewCaptureAwareWindowManagerInstance; -import static com.android.systemui.Flags.enableViewCaptureTracing; - import android.annotation.DimenRes; import android.annotation.IdRes; import android.annotation.LayoutRes; @@ -33,6 +30,7 @@ import android.graphics.drawable.Drawable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.WindowManager; import android.view.WindowManager.LayoutParams; import android.view.animation.AccelerateDecelerateInterpolator; import android.widget.FrameLayout; @@ -40,8 +38,8 @@ import android.widget.FrameLayout; import androidx.annotation.BoolRes; import androidx.core.view.OneShotPreDrawListener; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.systemui.shared.rotation.FloatingRotationButtonPositionCalculator.Position; +import com.android.systemui.utils.windowmanager.WindowManagerUtils; /** * Containing logic for the rotation button on the physical left bottom corner of the screen. @@ -50,7 +48,7 @@ public class FloatingRotationButton implements RotationButton { private static final int MARGIN_ANIMATION_DURATION_MILLIS = 300; - private final ViewCaptureAwareWindowManager mWindowManager; + private final WindowManager mWindowManager; private final ViewGroup mKeyButtonContainer; private final FloatingRotationButtonView mKeyButtonView; @@ -91,8 +89,7 @@ public class FloatingRotationButton implements RotationButton { @DimenRes int taskbarBottomMargin, @DimenRes int buttonDiameter, @DimenRes int rippleMaxWidth, @BoolRes int floatingRotationBtnPositionLeftResource) { mContext = context; - mWindowManager = getViewCaptureAwareWindowManagerInstance(mContext, - enableViewCaptureTracing()); + mWindowManager = WindowManagerUtils.getWindowManager(mContext); mKeyButtonContainer = (ViewGroup) LayoutInflater.from(mContext).inflate(layout, null); mKeyButtonView = mKeyButtonContainer.findViewById(keyButtonId); mKeyButtonView.setVisibility(View.VISIBLE); diff --git a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java index 19da5de6b531..59ec6923ce91 100644 --- a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java +++ b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java @@ -66,7 +66,6 @@ import android.widget.FrameLayout; import androidx.annotation.VisibleForTesting; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.util.Preconditions; import com.android.settingslib.Utils; import com.android.systemui.biometrics.data.repository.FacePropertyRepository; @@ -167,7 +166,7 @@ public class ScreenDecorations implements ViewGroup mScreenDecorHwcWindow; @VisibleForTesting ScreenDecorHwcLayer mScreenDecorHwcLayer; - private ViewCaptureAwareWindowManager mWindowManager; + private WindowManager mWindowManager; private int mRotation; private UserSettingObserver mColorInversionSetting; private DelayableExecutor mExecutor; @@ -337,7 +336,7 @@ public class ScreenDecorations implements FacePropertyRepository facePropertyRepository, JavaAdapter javaAdapter, CameraProtectionLoader cameraProtectionLoader, - ViewCaptureAwareWindowManager viewCaptureAwareWindowManager, + WindowManager windowManager, @ScreenDecorationsThread Handler handler, @ScreenDecorationsThread DelayableExecutor executor) { mContext = context; @@ -353,7 +352,7 @@ public class ScreenDecorations implements mLogger = logger; mFacePropertyRepository = facePropertyRepository; mJavaAdapter = javaAdapter; - mWindowManager = viewCaptureAwareWindowManager; + mWindowManager = windowManager; mHandler = handler; mExecutor = executor; } diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/MagnificationImpl.java b/packages/SystemUI/src/com/android/systemui/accessibility/MagnificationImpl.java index 115242eb13aa..375137c67f7c 100644 --- a/packages/SystemUI/src/com/android/systemui/accessibility/MagnificationImpl.java +++ b/packages/SystemUI/src/com/android/systemui/accessibility/MagnificationImpl.java @@ -44,7 +44,6 @@ import android.window.InputTransferToken; import androidx.annotation.NonNull; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.graphics.SfVsyncFrameCallbackProvider; import com.android.systemui.dagger.SysUISingleton; @@ -54,6 +53,7 @@ import com.android.systemui.recents.LauncherProxyService; import com.android.systemui.settings.DisplayTracker; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.util.settings.SecureSettings; +import com.android.systemui.utils.windowmanager.WindowManagerProvider; import java.io.PrintWriter; import java.util.concurrent.Executor; @@ -97,20 +97,19 @@ public class MagnificationImpl implements Magnification, CommandQueue.Callbacks private final WindowMagnifierCallback mWindowMagnifierCallback; private final SysUiState mSysUiState; private final SecureSettings mSecureSettings; - private final ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager; + private final WindowManagerProvider mWindowManagerProvider; WindowMagnificationControllerSupplier(Context context, Handler handler, WindowMagnifierCallback windowMagnifierCallback, DisplayManager displayManager, SysUiState sysUiState, - SecureSettings secureSettings, - ViewCaptureAwareWindowManager viewCaptureAwareWindowManager) { + SecureSettings secureSettings, WindowManagerProvider windowManagerProvider) { super(displayManager); mContext = context; mHandler = handler; mWindowMagnifierCallback = windowMagnifierCallback; mSysUiState = sysUiState; mSecureSettings = secureSettings; - mViewCaptureAwareWindowManager = viewCaptureAwareWindowManager; + mWindowManagerProvider = windowManagerProvider; } @Override @@ -118,6 +117,8 @@ public class MagnificationImpl implements Magnification, CommandQueue.Callbacks final Context windowContext = mContext.createWindowContext(display, TYPE_ACCESSIBILITY_OVERLAY, /* options */ null); + final WindowManager windowManager = mWindowManagerProvider + .getWindowManager(windowContext); windowContext.setTheme(com.android.systemui.res.R.style.Theme_SystemUI); Supplier<SurfaceControlViewHost> scvhSupplier = () -> @@ -133,7 +134,8 @@ public class MagnificationImpl implements Magnification, CommandQueue.Callbacks mWindowMagnifierCallback, mSysUiState, mSecureSettings, - scvhSupplier); + scvhSupplier, + windowManager); } } @@ -148,17 +150,20 @@ public class MagnificationImpl implements Magnification, CommandQueue.Callbacks private final Executor mExecutor; private final DisplayManager mDisplayManager; private final IWindowManager mIWindowManager; + private final WindowManagerProvider mWindowManagerProvider; FullscreenMagnificationControllerSupplier(Context context, DisplayManager displayManager, Handler handler, - Executor executor, IWindowManager iWindowManager) { + Executor executor, IWindowManager iWindowManager, + WindowManagerProvider windowManagerProvider) { super(displayManager); mContext = context; mHandler = handler; mExecutor = executor; mDisplayManager = displayManager; mIWindowManager = iWindowManager; + mWindowManagerProvider = windowManagerProvider; } @Override @@ -174,7 +179,7 @@ public class MagnificationImpl implements Magnification, CommandQueue.Callbacks mExecutor, mDisplayManager, windowContext.getSystemService(AccessibilityManager.class), - windowContext.getSystemService(WindowManager.class), + mWindowManagerProvider.getWindowManager(windowContext), mIWindowManager, scvhSupplier); } @@ -190,31 +195,32 @@ public class MagnificationImpl implements Magnification, CommandQueue.Callbacks private final Context mContext; private final MagnificationSettingsController.Callback mSettingsControllerCallback; private final SecureSettings mSecureSettings; - private final ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager; + private final WindowManagerProvider mWindowManagerProvider; SettingsSupplier(Context context, MagnificationSettingsController.Callback settingsControllerCallback, DisplayManager displayManager, - SecureSettings secureSettings, - ViewCaptureAwareWindowManager viewCaptureAwareWindowManager) { + SecureSettings secureSettings, WindowManagerProvider windowManagerProvider) { super(displayManager); mContext = context; mSettingsControllerCallback = settingsControllerCallback; mSecureSettings = secureSettings; - mViewCaptureAwareWindowManager = viewCaptureAwareWindowManager; + mWindowManagerProvider = windowManagerProvider; } @Override protected MagnificationSettingsController createInstance(Display display) { final Context windowContext = mContext.createWindowContext(display, TYPE_ACCESSIBILITY_OVERLAY, /* options */ null); + final WindowManager windowManager = mWindowManagerProvider + .getWindowManager(windowContext); windowContext.setTheme(com.android.systemui.res.R.style.Theme_SystemUI); return new MagnificationSettingsController( windowContext, new SfVsyncFrameCallbackProvider(), mSettingsControllerCallback, mSecureSettings, - mViewCaptureAwareWindowManager); + windowManager); } } @@ -229,11 +235,11 @@ public class MagnificationImpl implements Magnification, CommandQueue.Callbacks SecureSettings secureSettings, DisplayTracker displayTracker, DisplayManager displayManager, AccessibilityLogger a11yLogger, IWindowManager iWindowManager, AccessibilityManager accessibilityManager, - ViewCaptureAwareWindowManager viewCaptureAwareWindowManager) { + WindowManagerProvider windowManagerProvider) { this(context, mainHandler.getLooper(), executor, commandQueue, modeSwitchesController, sysUiState, launcherProxyService, secureSettings, displayTracker, displayManager, a11yLogger, iWindowManager, accessibilityManager, - viewCaptureAwareWindowManager); + windowManagerProvider); } @VisibleForTesting @@ -244,7 +250,7 @@ public class MagnificationImpl implements Magnification, CommandQueue.Callbacks DisplayManager displayManager, AccessibilityLogger a11yLogger, IWindowManager iWindowManager, AccessibilityManager accessibilityManager, - ViewCaptureAwareWindowManager viewCaptureAwareWindowManager) { + WindowManagerProvider windowManagerProvider) { mHandler = new Handler(looper) { @Override public void handleMessage(@NonNull Message msg) { @@ -263,12 +269,13 @@ public class MagnificationImpl implements Magnification, CommandQueue.Callbacks mA11yLogger = a11yLogger; mWindowMagnificationControllerSupplier = new WindowMagnificationControllerSupplier(context, mHandler, mWindowMagnifierCallback, - displayManager, sysUiState, secureSettings, viewCaptureAwareWindowManager); + displayManager, sysUiState, secureSettings, windowManagerProvider); mFullscreenMagnificationControllerSupplier = new FullscreenMagnificationControllerSupplier( - context, displayManager, mHandler, mExecutor, iWindowManager); + context, displayManager, mHandler, mExecutor, iWindowManager, + windowManagerProvider); mMagnificationSettingsSupplier = new SettingsSupplier(context, mMagnificationSettingsControllerCallback, displayManager, secureSettings, - viewCaptureAwareWindowManager); + windowManagerProvider); mModeSwitchesController.setClickListenerDelegate( displayId -> mHandler.post(() -> { diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/MagnificationModeSwitch.java b/packages/SystemUI/src/com/android/systemui/accessibility/MagnificationModeSwitch.java index 4723ab958f86..9eb01de239bc 100644 --- a/packages/SystemUI/src/com/android/systemui/accessibility/MagnificationModeSwitch.java +++ b/packages/SystemUI/src/com/android/systemui/accessibility/MagnificationModeSwitch.java @@ -46,7 +46,6 @@ import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; import android.widget.ImageView; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.graphics.SfVsyncFrameCallbackProvider; import com.android.systemui.res.R; @@ -77,7 +76,6 @@ class MagnificationModeSwitch implements MagnificationGestureDetector.OnGestureL private final Context mContext; private final AccessibilityManager mAccessibilityManager; private final WindowManager mWindowManager; - private final ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager; private final ImageView mImageView; private final Runnable mWindowInsetChangeRunnable; private final SfVsyncFrameCallbackProvider mSfVsyncFrameProvider; @@ -101,21 +99,20 @@ class MagnificationModeSwitch implements MagnificationGestureDetector.OnGestureL void onClick(int displayId); } - MagnificationModeSwitch(@UiContext Context context, ClickListener clickListener, - ViewCaptureAwareWindowManager viewCaptureAwareWindowManager) { - this(context, createView(context), new SfVsyncFrameCallbackProvider(), clickListener, - viewCaptureAwareWindowManager); + MagnificationModeSwitch(@UiContext Context context, WindowManager windowManager, + ClickListener clickListener) { + this(context, windowManager, createView(context), new SfVsyncFrameCallbackProvider(), + clickListener); } @VisibleForTesting - MagnificationModeSwitch(Context context, @NonNull ImageView imageView, - SfVsyncFrameCallbackProvider sfVsyncFrameProvider, ClickListener clickListener, - ViewCaptureAwareWindowManager viewCaptureAwareWindowManager) { + MagnificationModeSwitch(Context context, WindowManager windowManager, + @NonNull ImageView imageView, SfVsyncFrameCallbackProvider sfVsyncFrameProvider, + ClickListener clickListener) { mContext = context; mConfiguration = new Configuration(context.getResources().getConfiguration()); mAccessibilityManager = mContext.getSystemService(AccessibilityManager.class); - mWindowManager = mContext.getSystemService(WindowManager.class); - mViewCaptureAwareWindowManager = viewCaptureAwareWindowManager; + mWindowManager = windowManager; mSfVsyncFrameProvider = sfVsyncFrameProvider; mClickListener = clickListener; mParams = createLayoutParams(context); @@ -282,7 +279,7 @@ class MagnificationModeSwitch implements MagnificationGestureDetector.OnGestureL mImageView.animate().cancel(); mIsFadeOutAnimating = false; mImageView.setAlpha(0f); - mViewCaptureAwareWindowManager.removeView(mImageView); + mWindowManager.removeView(mImageView); mContext.unregisterComponentCallbacks(this); mIsVisible = false; } @@ -316,7 +313,7 @@ class MagnificationModeSwitch implements MagnificationGestureDetector.OnGestureL mParams.y = mDraggableWindowBounds.bottom; mToLeftScreenEdge = false; } - mViewCaptureAwareWindowManager.addView(mImageView, mParams); + mWindowManager.addView(mImageView, mParams); // Exclude magnification switch button from system gesture area. setSystemGestureExclusion(); mIsVisible = true; diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/MagnificationSettingsController.java b/packages/SystemUI/src/com/android/systemui/accessibility/MagnificationSettingsController.java index fc7535a712e3..2d5dc8d23383 100644 --- a/packages/SystemUI/src/com/android/systemui/accessibility/MagnificationSettingsController.java +++ b/packages/SystemUI/src/com/android/systemui/accessibility/MagnificationSettingsController.java @@ -26,7 +26,6 @@ import android.content.res.Configuration; import android.util.Range; import android.view.WindowManager; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.accessibility.common.MagnificationConstants; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.graphics.SfVsyncFrameCallbackProvider; @@ -62,9 +61,9 @@ public class MagnificationSettingsController implements ComponentCallbacks { SfVsyncFrameCallbackProvider sfVsyncFrameProvider, @NonNull Callback settingsControllerCallback, SecureSettings secureSettings, - ViewCaptureAwareWindowManager viewCaptureAwareWindowManager) { - this(context, sfVsyncFrameProvider, settingsControllerCallback, secureSettings, null, - viewCaptureAwareWindowManager); + WindowManager windowManager) { + this(context, sfVsyncFrameProvider, settingsControllerCallback, secureSettings, + windowManager, null); } @VisibleForTesting @@ -73,8 +72,8 @@ public class MagnificationSettingsController implements ComponentCallbacks { SfVsyncFrameCallbackProvider sfVsyncFrameProvider, @NonNull Callback settingsControllerCallback, SecureSettings secureSettings, - WindowMagnificationSettings windowMagnificationSettings, - ViewCaptureAwareWindowManager viewCaptureAwareWindowManager) { + WindowManager windowManager, + WindowMagnificationSettings windowMagnificationSettings) { mContext = context.createWindowContext( context.getDisplay(), WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL, @@ -88,7 +87,7 @@ public class MagnificationSettingsController implements ComponentCallbacks { } else { mWindowMagnificationSettings = new WindowMagnificationSettings(mContext, mWindowMagnificationSettingsCallback, - sfVsyncFrameProvider, secureSettings, viewCaptureAwareWindowManager); + sfVsyncFrameProvider, secureSettings, windowManager); } } diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/MirrorWindowControl.java b/packages/SystemUI/src/com/android/systemui/accessibility/MirrorWindowControl.java index eb4de6837d41..7f3a869d8222 100644 --- a/packages/SystemUI/src/com/android/systemui/accessibility/MirrorWindowControl.java +++ b/packages/SystemUI/src/com/android/systemui/accessibility/MirrorWindowControl.java @@ -18,9 +18,6 @@ package com.android.systemui.accessibility; import static android.view.WindowManager.LayoutParams; -import static com.android.app.viewcapture.ViewCaptureFactory.getViewCaptureAwareWindowManagerInstance; -import static com.android.systemui.Flags.enableViewCaptureTracing; - import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; @@ -32,8 +29,8 @@ import android.util.MathUtils; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; +import android.view.WindowManager; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.systemui.res.R; /** @@ -73,12 +70,11 @@ public abstract class MirrorWindowControl { * @see #setDefaultPosition(LayoutParams) */ private final Point mControlPosition = new Point(); - private final ViewCaptureAwareWindowManager mWindowManager; + private final WindowManager mWindowManager; - MirrorWindowControl(Context context) { + MirrorWindowControl(Context context, WindowManager windowManager) { mContext = context; - mWindowManager = getViewCaptureAwareWindowManagerInstance(mContext, - enableViewCaptureTracing()); + mWindowManager = windowManager; } public void setWindowDelegate(@Nullable MirrorWindowDelegate windowDelegate) { diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/ModeSwitchesController.java b/packages/SystemUI/src/com/android/systemui/accessibility/ModeSwitchesController.java index 53827e65344a..7d9f8674457c 100644 --- a/packages/SystemUI/src/com/android/systemui/accessibility/ModeSwitchesController.java +++ b/packages/SystemUI/src/com/android/systemui/accessibility/ModeSwitchesController.java @@ -24,10 +24,11 @@ import android.annotation.MainThread; import android.content.Context; import android.hardware.display.DisplayManager; import android.view.Display; +import android.view.WindowManager; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.annotations.VisibleForTesting; import com.android.systemui.dagger.SysUISingleton; +import com.android.systemui.utils.windowmanager.WindowManagerProvider; import javax.inject.Inject; @@ -49,9 +50,9 @@ public class ModeSwitchesController implements ClickListener { @Inject public ModeSwitchesController(Context context, DisplayManager displayManager, - ViewCaptureAwareWindowManager viewCaptureAwareWindowManager) { + WindowManagerProvider windowManagerProvider) { mSwitchSupplier = new SwitchSupplier(context, displayManager, this::onClick, - viewCaptureAwareWindowManager); + windowManagerProvider); } @VisibleForTesting @@ -118,7 +119,7 @@ public class ModeSwitchesController implements ClickListener { private final Context mContext; private final ClickListener mClickListener; - private final ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager; + private final WindowManagerProvider mWindowManagerProvider; /** * Supplies the switch for the given display. @@ -128,20 +129,20 @@ public class ModeSwitchesController implements ClickListener { * @param clickListener The callback that will run when the switch is clicked */ SwitchSupplier(Context context, DisplayManager displayManager, - ClickListener clickListener, - ViewCaptureAwareWindowManager viewCaptureAwareWindowManager) { + ClickListener clickListener, WindowManagerProvider windowManagerProvider) { super(displayManager); mContext = context; mClickListener = clickListener; - mViewCaptureAwareWindowManager = viewCaptureAwareWindowManager; + mWindowManagerProvider = windowManagerProvider; } @Override protected MagnificationModeSwitch createInstance(Display display) { final Context uiContext = mContext.createWindowContext(display, TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY, /* options */ null); - return new MagnificationModeSwitch(uiContext, mClickListener, - mViewCaptureAwareWindowManager); + final WindowManager uiWindowManager = mWindowManagerProvider + .getWindowManager(uiContext); + return new MagnificationModeSwitch(uiContext, uiWindowManager, mClickListener); } } } diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/SimpleMirrorWindowControl.java b/packages/SystemUI/src/com/android/systemui/accessibility/SimpleMirrorWindowControl.java index bc469eed7359..3cde033bf56a 100644 --- a/packages/SystemUI/src/com/android/systemui/accessibility/SimpleMirrorWindowControl.java +++ b/packages/SystemUI/src/com/android/systemui/accessibility/SimpleMirrorWindowControl.java @@ -27,6 +27,7 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; +import android.view.WindowManager; import com.android.systemui.res.R; @@ -48,8 +49,8 @@ class SimpleMirrorWindowControl extends MirrorWindowControl implements View.OnCl private final PointF mLastDrag = new PointF(); private final Handler mHandler; - SimpleMirrorWindowControl(Context context, Handler handler) { - super(context); + SimpleMirrorWindowControl(Context context, Handler handler, WindowManager windowManager) { + super(context, windowManager); mHandler = handler; final Resources resource = context.getResources(); mMoveFrameAmountShort = resource.getDimensionPixelSize( diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java index 8734d05bc894..9cd77e790e8c 100644 --- a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java +++ b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java @@ -249,7 +249,8 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold @NonNull WindowMagnifierCallback callback, SysUiState sysUiState, SecureSettings secureSettings, - Supplier<SurfaceControlViewHost> scvhSupplier) { + Supplier<SurfaceControlViewHost> scvhSupplier, + WindowManager windowManager) { mContext = context; mHandler = handler; mAnimationController = animationController; @@ -265,7 +266,7 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold mDisplayId = mContext.getDisplayId(); mRotation = display.getRotation(); - mWm = context.getSystemService(WindowManager.class); + mWm = windowManager; mWindowBounds = new Rect(mWm.getCurrentWindowMetrics().getBounds()); mResources = mContext.getResources(); diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationSettings.java b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationSettings.java index 3b6f8f87a1a8..bd4b6420bf37 100644 --- a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationSettings.java +++ b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationSettings.java @@ -56,7 +56,6 @@ import android.widget.LinearLayout; import android.widget.SeekBar; import android.widget.Switch; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.graphics.SfVsyncFrameCallbackProvider; import com.android.systemui.common.ui.view.SeekBarWithIconButtonsView; @@ -75,7 +74,6 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest private final Context mContext; private final AccessibilityManager mAccessibilityManager; private final WindowManager mWindowManager; - private final ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager; private final SecureSettings mSecureSettings; private final Runnable mWindowInsetChangeRunnable; @@ -137,11 +135,10 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest @VisibleForTesting WindowMagnificationSettings(Context context, WindowMagnificationSettingsCallback callback, SfVsyncFrameCallbackProvider sfVsyncFrameProvider, SecureSettings secureSettings, - ViewCaptureAwareWindowManager viewCaptureAwareWindowManager) { + WindowManager windowManager) { mContext = context; mAccessibilityManager = mContext.getSystemService(AccessibilityManager.class); - mWindowManager = mContext.getSystemService(WindowManager.class); - mViewCaptureAwareWindowManager = viewCaptureAwareWindowManager; + mWindowManager = windowManager; mSfVsyncFrameProvider = sfVsyncFrameProvider; mCallback = callback; mSecureSettings = secureSettings; @@ -324,7 +321,7 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest // Unregister observer before removing view mSecureSettings.unregisterContentObserverSync(mMagnificationCapabilityObserver); - mViewCaptureAwareWindowManager.removeView(mSettingView); + mWindowManager.removeView(mSettingView); mIsVisible = false; if (resetPosition) { mParams.x = 0; @@ -382,7 +379,7 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest mParams.y = mDraggableWindowBounds.bottom; } - mViewCaptureAwareWindowManager.addView(mSettingView, mParams); + mWindowManager.addView(mSettingView, mParams); mSecureSettings.registerContentObserverForUserSync( Settings.Secure.ACCESSIBILITY_MAGNIFICATION_CAPABILITY, diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuController.java b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuController.java index f8e4bda15d01..ef42837ba776 100644 --- a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuController.java +++ b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuController.java @@ -31,7 +31,6 @@ import android.view.accessibility.IUserInitializationCompleteCallback; import androidx.annotation.MainThread; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.annotations.VisibleForTesting; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; @@ -60,7 +59,6 @@ public class AccessibilityFloatingMenuController implements private final Context mContext; private final WindowManager mWindowManager; - private final ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager; private final DisplayManager mDisplayManager; private final AccessibilityManager mAccessibilityManager; private final HearingAidDeviceManager mHearingAidDeviceManager; @@ -105,7 +103,6 @@ public class AccessibilityFloatingMenuController implements @Inject public AccessibilityFloatingMenuController(Context context, WindowManager windowManager, - ViewCaptureAwareWindowManager viewCaptureAwareWindowManager, DisplayManager displayManager, AccessibilityManager accessibilityManager, AccessibilityButtonTargetsObserver accessibilityButtonTargetsObserver, @@ -118,7 +115,6 @@ public class AccessibilityFloatingMenuController implements @Main Handler handler) { mContext = context; mWindowManager = windowManager; - mViewCaptureAwareWindowManager = viewCaptureAwareWindowManager; mDisplayManager = displayManager; mAccessibilityManager = accessibilityManager; mAccessibilityButtonTargetsObserver = accessibilityButtonTargetsObserver; @@ -205,8 +201,8 @@ public class AccessibilityFloatingMenuController implements final Context windowContext = mContext.createWindowContext(defaultDisplay, TYPE_NAVIGATION_BAR_PANEL, /* options= */ null); mFloatingMenu = new MenuViewLayerController(windowContext, mWindowManager, - mViewCaptureAwareWindowManager, mAccessibilityManager, mSecureSettings, - mNavigationModeController, mHearingAidDeviceManager); + mAccessibilityManager, mSecureSettings, mNavigationModeController, + mHearingAidDeviceManager); } mFloatingMenu.show(); diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/DragToInteractView.kt b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/DragToInteractView.kt index 13c1a450832f..52e69efdbc19 100644 --- a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/DragToInteractView.kt +++ b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/DragToInteractView.kt @@ -48,7 +48,7 @@ import com.android.wm.shell.shared.bubbles.DismissView * * @note [setup] method should be called after initialisation */ -class DragToInteractView(context: Context) : FrameLayout(context) { +class DragToInteractView(context: Context, windowManager: WindowManager) : FrameLayout(context) { /** * The configuration is used to provide module specific resource ids * @@ -86,8 +86,7 @@ class DragToInteractView(context: Context) : FrameLayout(context) { private val spring = PhysicsAnimator.SpringConfig(STIFFNESS_LOW, DAMPING_RATIO_LOW_BOUNCY) private val INTERACT_SCRIM_FADE_MS = 200L - private var wm: WindowManager = - context.getSystemService(Context.WINDOW_SERVICE) as WindowManager + private var wm: WindowManager = windowManager private var gradientDrawable: GradientDrawable? = null private val GRADIENT_ALPHA: IntProperty<GradientDrawable> = diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayer.java b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayer.java index 81095220b4a6..8fb260c2df36 100644 --- a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayer.java +++ b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayer.java @@ -212,7 +212,7 @@ class MenuViewLayer extends FrameLayout implements mMenuAnimationController = mMenuView.getMenuAnimationController(); mMenuAnimationController.setSpringAnimationsEndAction(this::onSpringAnimationsEndAction); mDismissView = new DismissView(context); - mDragToInteractView = new DragToInteractView(context); + mDragToInteractView = new DragToInteractView(context, windowManager); DismissViewUtils.setup(mDismissView); mDismissView.getCircle().setId(R.id.action_remove_menu); mNotificationFactory = new MenuNotificationFactory(context); diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerController.java b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerController.java index 102efcf7badd..7bf7e23b5df5 100644 --- a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerController.java +++ b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerController.java @@ -25,7 +25,6 @@ import android.graphics.PixelFormat; import android.view.WindowManager; import android.view.accessibility.AccessibilityManager; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.settingslib.bluetooth.HearingAidDeviceManager; import com.android.systemui.navigationbar.NavigationModeController; import com.android.systemui.util.settings.SecureSettings; @@ -35,16 +34,15 @@ import com.android.systemui.util.settings.SecureSettings; * of {@link IAccessibilityFloatingMenu}. */ class MenuViewLayerController implements IAccessibilityFloatingMenu { - private final ViewCaptureAwareWindowManager mWindowManager; + private final WindowManager mWindowManager; private final MenuViewLayer mMenuViewLayer; private boolean mIsShowing; MenuViewLayerController(Context context, WindowManager windowManager, - ViewCaptureAwareWindowManager viewCaptureAwareWindowManager, AccessibilityManager accessibilityManager, SecureSettings secureSettings, NavigationModeController navigationModeController, HearingAidDeviceManager hearingAidDeviceManager) { - mWindowManager = viewCaptureAwareWindowManager; + mWindowManager = windowManager; MenuViewModel menuViewModel = new MenuViewModel( context, accessibilityManager, secureSettings, hearingAidDeviceManager); diff --git a/packages/SystemUI/src/com/android/systemui/assist/AssistDisclosure.java b/packages/SystemUI/src/com/android/systemui/assist/AssistDisclosure.java index f4e2b82f1773..14ce2cf60919 100644 --- a/packages/SystemUI/src/com/android/systemui/assist/AssistDisclosure.java +++ b/packages/SystemUI/src/com/android/systemui/assist/AssistDisclosure.java @@ -33,7 +33,6 @@ import android.view.WindowManager; import android.view.accessibility.AccessibilityEvent; import com.android.app.animation.Interpolators; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.systemui.res.R; /** @@ -41,17 +40,16 @@ import com.android.systemui.res.R; */ public class AssistDisclosure { private final Context mContext; - private final ViewCaptureAwareWindowManager mWm; + private final WindowManager mWm; private final Handler mHandler; private AssistDisclosureView mView; private boolean mViewAdded; - public AssistDisclosure(Context context, Handler handler, - ViewCaptureAwareWindowManager viewCaptureAwareWindowManager) { + public AssistDisclosure(Context context, Handler handler, WindowManager windowManager) { mContext = context; mHandler = handler; - mWm = viewCaptureAwareWindowManager; + mWm = windowManager; } public void postShow() { diff --git a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java index 2d44d401b0b0..75ec8dfd881e 100644 --- a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java +++ b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java @@ -24,8 +24,8 @@ import android.provider.Settings; import android.service.voice.VisualQueryAttentionResult; import android.service.voice.VoiceInteractionSession; import android.util.Log; +import android.view.WindowManager; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.app.AssistUtils; import com.android.internal.app.IVisualQueryDetectionAttentionListener; import com.android.internal.app.IVisualQueryRecognitionStatusListener; @@ -199,12 +199,12 @@ public class AssistManager { SelectedUserInteractor selectedUserInteractor, ActivityManager activityManager, AssistInteractor interactor, - ViewCaptureAwareWindowManager viewCaptureAwareWindowManager) { + WindowManager windowManager) { mContext = context; mDeviceProvisionedController = controller; mCommandQueue = commandQueue; mAssistUtils = assistUtils; - mAssistDisclosure = new AssistDisclosure(context, uiHandler, viewCaptureAwareWindowManager); + mAssistDisclosure = new AssistDisclosure(context, uiHandler, windowManager); mLauncherProxyService = launcherProxyService; mPhoneStateMonitor = phoneStateMonitor; mAssistLogger = assistLogger; diff --git a/packages/SystemUI/src/com/android/systemui/assist/ui/DefaultUiController.java b/packages/SystemUI/src/com/android/systemui/assist/ui/DefaultUiController.java index 6e257442d139..56273eb9a2cf 100644 --- a/packages/SystemUI/src/com/android/systemui/assist/ui/DefaultUiController.java +++ b/packages/SystemUI/src/com/android/systemui/assist/ui/DefaultUiController.java @@ -33,7 +33,6 @@ import android.view.WindowManager; import android.view.animation.PathInterpolator; import android.widget.FrameLayout; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.systemui.assist.AssistLogger; @@ -67,7 +66,7 @@ public class DefaultUiController implements AssistManager.UiController { protected InvocationLightsView mInvocationLightsView; protected final AssistLogger mAssistLogger; - private final ViewCaptureAwareWindowManager mWindowManager; + private final WindowManager mWindowManager; private final MetricsLogger mMetricsLogger; private final Lazy<AssistManager> mAssistManagerLazy; private final WindowManager.LayoutParams mLayoutParams; @@ -81,12 +80,12 @@ public class DefaultUiController implements AssistManager.UiController { @Inject public DefaultUiController(Context context, AssistLogger assistLogger, - ViewCaptureAwareWindowManager viewCaptureAwareWindowManager, - MetricsLogger metricsLogger, Lazy<AssistManager> assistManagerLazy, + WindowManager windowManager, MetricsLogger metricsLogger, + Lazy<AssistManager> assistManagerLazy, NavigationBarController navigationBarController) { mAssistLogger = assistLogger; mRoot = new FrameLayout(context); - mWindowManager = viewCaptureAwareWindowManager; + mWindowManager = windowManager; mMetricsLogger = metricsLogger; mAssistManagerLazy = assistManagerLazy; diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java index b8e95ee1dbf0..7bb08edd4773 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java @@ -20,7 +20,6 @@ import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FACE; import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; import static com.android.internal.jank.InteractionJankMonitor.CUJ_BIOMETRIC_PROMPT_TRANSITION; -import static com.android.systemui.Flags.enableViewCaptureTracing; import android.animation.Animator; import android.annotation.IntDef; @@ -57,8 +56,6 @@ import android.window.OnBackInvokedDispatcher; import androidx.constraintlayout.widget.ConstraintLayout; import com.android.app.animation.Interpolators; -import com.android.app.viewcapture.ViewCapture; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.jank.InteractionJankMonitor; import com.android.internal.widget.LockPatternUtils; @@ -78,11 +75,10 @@ import com.android.systemui.keyguard.WakefulnessLifecycle; import com.android.systemui.res.R; import com.android.systemui.statusbar.VibratorHelper; import com.android.systemui.util.concurrency.DelayableExecutor; +import com.android.systemui.utils.windowmanager.WindowManagerUtils; import com.google.android.msdl.domain.MSDLPlayer; -import kotlin.Lazy; - import kotlinx.coroutines.CoroutineScope; import java.io.PrintWriter; @@ -132,7 +128,7 @@ public class AuthContainerView extends LinearLayout private final Config mConfig; private final int mEffectiveUserId; private final IBinder mWindowToken = new Binder(); - private final ViewCaptureAwareWindowManager mWindowManager; + private final WindowManager mWindowManager; @Nullable private final AuthContextPlugins mAuthContextPlugins; private final Interpolator mLinearOutSlowIn; private final LockPatternUtils mLockPatternUtils; @@ -298,16 +294,13 @@ public class AuthContainerView extends LinearLayout @NonNull Provider<CredentialViewModel> credentialViewModelProvider, @NonNull @Background DelayableExecutor bgExecutor, @NonNull VibratorHelper vibratorHelper, - Lazy<ViewCapture> lazyViewCapture, @NonNull MSDLPlayer msdlPlayer) { super(config.mContext); mConfig = config; mLockPatternUtils = lockPatternUtils; mEffectiveUserId = userManager.getCredentialOwnerProfile(mConfig.mUserId); - WindowManager wm = getContext().getSystemService(WindowManager.class); - mWindowManager = new ViewCaptureAwareWindowManager(wm, lazyViewCapture, - enableViewCaptureTracing()); + mWindowManager = WindowManagerUtils.getWindowManager(getContext()); mAuthContextPlugins = authContextPlugins; mWakefulnessLifecycle = wakefulnessLifecycle; mApplicationCoroutineScope = applicationCoroutineScope; diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java index 68a282018ba4..f2c071f14466 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java @@ -22,7 +22,6 @@ import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_REAR import static android.view.Display.INVALID_DISPLAY; import static com.android.systemui.Flags.contAuthPlugin; -import static com.android.systemui.util.ConvenienceExtensionsKt.toKotlinLazy; import android.annotation.NonNull; import android.annotation.Nullable; @@ -67,7 +66,6 @@ import android.view.DisplayInfo; import android.view.MotionEvent; import android.view.WindowManager; -import com.android.app.viewcapture.ViewCapture; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.jank.InteractionJankMonitor; @@ -93,6 +91,7 @@ import com.android.systemui.statusbar.VibratorHelper; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.util.concurrency.DelayableExecutor; import com.android.systemui.util.concurrency.Execution; +import com.android.systemui.utils.windowmanager.WindowManagerProvider; import com.google.android.msdl.domain.MSDLPlayer; @@ -194,7 +193,7 @@ public class AuthController implements @NonNull private final VibratorHelper mVibratorHelper; @NonNull private final MSDLPlayer mMSDLPlayer; - private final kotlin.Lazy<ViewCapture> mLazyViewCapture; + private final WindowManagerProvider mWindowManagerProvider; @VisibleForTesting final TaskStackListener mTaskStackListener = new TaskStackListener() { @@ -693,8 +692,8 @@ public class AuthController implements @NonNull UdfpsUtils udfpsUtils, @NonNull VibratorHelper vibratorHelper, @NonNull KeyguardManager keyguardManager, - Lazy<ViewCapture> daggerLazyViewCapture, - @NonNull MSDLPlayer msdlPlayer) { + @NonNull MSDLPlayer msdlPlayer, + WindowManagerProvider windowManagerProvider) { mContext = context; mExecution = execution; mUserManager = userManager; @@ -755,7 +754,7 @@ public class AuthController implements context.registerReceiver(mBroadcastReceiver, filter, Context.RECEIVER_EXPORTED_UNAUDITED); mSensorPrivacyManager = context.getSystemService(SensorPrivacyManager.class); - mLazyViewCapture = toKotlinLazy(daggerLazyViewCapture); + mWindowManagerProvider = windowManagerProvider; } // TODO(b/229290039): UDFPS controller should manage its dimensions on its own. Remove this. @@ -1278,7 +1277,7 @@ public class AuthController implements Log.e(TAG, "unable to get Display for user=" + userId); return null; } - return mContext.createDisplayContext(display).getSystemService(WindowManager.class); + return mWindowManagerProvider.getWindowManager(mContext.createDisplayContext(display)); } private void onDialogDismissed(@BiometricPrompt.DismissedReason int reason) { @@ -1337,8 +1336,7 @@ public class AuthController implements return new AuthContainerView(config, mApplicationCoroutineScope, mFpProps, mFaceProps, wakefulnessLifecycle, userManager, mContextPlugins, lockPatternUtils, mInteractionJankMonitor, mPromptSelectorInteractor, viewModel, - mCredentialViewModelProvider, bgExecutor, mVibratorHelper, - mLazyViewCapture, mMSDLPlayer); + mCredentialViewModelProvider, bgExecutor, mVibratorHelper, mMSDLPlayer); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java index 659d3b46fea9..b16c416fb9df 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java @@ -57,12 +57,12 @@ import android.view.HapticFeedbackConstants; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; +import android.view.WindowManager; import android.view.accessibility.AccessibilityManager; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.logging.InstanceId; @@ -145,7 +145,7 @@ public class UdfpsController implements DozeReceiver, Dumpable { private final Execution mExecution; private final FingerprintManager mFingerprintManager; @NonNull private final LayoutInflater mInflater; - private final ViewCaptureAwareWindowManager mWindowManager; + private final WindowManager mWindowManager; private final DelayableExecutor mFgExecutor; @NonNull private final Executor mBiometricExecutor; @NonNull private final StatusBarStateController mStatusBarStateController; @@ -659,7 +659,7 @@ public class UdfpsController implements DozeReceiver, Dumpable { @NonNull Execution execution, @NonNull @ShadeDisplayAware LayoutInflater inflater, @Nullable FingerprintManager fingerprintManager, - @NonNull ViewCaptureAwareWindowManager viewCaptureAwareWindowManager, + @NonNull @Main WindowManager windowManager, @NonNull StatusBarStateController statusBarStateController, @Main DelayableExecutor fgExecutor, @NonNull StatusBarKeyguardViewManager statusBarKeyguardViewManager, @@ -705,7 +705,7 @@ public class UdfpsController implements DozeReceiver, Dumpable { // The fingerprint manager is queried for UDFPS before this class is constructed, so the // fingerprint manager should never be null. mFingerprintManager = checkNotNull(fingerprintManager); - mWindowManager = viewCaptureAwareWindowManager; + mWindowManager = windowManager; mFgExecutor = fgExecutor; mStatusBarStateController = statusBarStateController; mKeyguardStateController = keyguardStateController; diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt index bdf58275effa..61b670715572 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt @@ -42,7 +42,6 @@ import android.view.accessibility.AccessibilityManager import android.view.accessibility.AccessibilityManager.TouchExplorationStateChangeListener import androidx.annotation.VisibleForTesting import com.android.app.tracing.coroutines.launchTraced as launch -import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.keyguard.KeyguardUpdateMonitor import com.android.systemui.animation.ActivityTransitionAnimator import com.android.systemui.biometrics.domain.interactor.UdfpsOverlayInteractor @@ -88,7 +87,7 @@ class UdfpsControllerOverlay constructor( private val context: Context, private val inflater: LayoutInflater, - private val windowManager: ViewCaptureAwareWindowManager, + private val windowManager: WindowManager, private val accessibilityManager: AccessibilityManager, private val statusBarStateController: StatusBarStateController, private val statusBarKeyguardViewManager: StatusBarKeyguardViewManager, diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewSizeBinder.kt b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewSizeBinder.kt index 02c378417f3d..fcc0121e8f93 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewSizeBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewSizeBinder.kt @@ -27,7 +27,6 @@ import android.view.View import android.view.ViewGroup import android.view.ViewOutlineProvider import android.view.WindowInsets -import android.view.WindowManager import android.view.accessibility.AccessibilityManager import android.widget.ImageView import android.widget.TextView @@ -48,6 +47,7 @@ import com.android.systemui.biometrics.ui.viewmodel.isSmall import com.android.systemui.biometrics.ui.viewmodel.isTop import com.android.systemui.lifecycle.repeatWhenAttached import com.android.systemui.res.R +import com.android.systemui.utils.windowmanager.WindowManagerUtils import kotlin.math.abs import kotlinx.coroutines.flow.combine import com.android.app.tracing.coroutines.launchTraced as launch @@ -66,7 +66,7 @@ object BiometricViewSizeBinder { viewsToHideWhenSmall: List<View>, jankListener: BiometricJankListener, ) { - val windowManager = requireNotNull(view.context.getSystemService(WindowManager::class.java)) + val windowManager = WindowManagerUtils.getWindowManager(view.context) val accessibilityManager = requireNotNull(view.context.getSystemService(AccessibilityManager::class.java)) diff --git a/packages/SystemUI/src/com/android/systemui/charging/WiredChargingRippleController.kt b/packages/SystemUI/src/com/android/systemui/charging/WiredChargingRippleController.kt index 7d518f4f7e78..718ef51aa161 100644 --- a/packages/SystemUI/src/com/android/systemui/charging/WiredChargingRippleController.kt +++ b/packages/SystemUI/src/com/android/systemui/charging/WiredChargingRippleController.kt @@ -23,20 +23,19 @@ import android.os.SystemProperties import android.view.Surface import android.view.View import android.view.WindowManager -import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.internal.annotations.VisibleForTesting import com.android.internal.logging.UiEvent import com.android.internal.logging.UiEventLogger import com.android.settingslib.Utils +import com.android.systemui.res.R import com.android.systemui.dagger.SysUISingleton import com.android.systemui.flags.FeatureFlags import com.android.systemui.flags.Flags -import com.android.systemui.res.R +import com.android.systemui.surfaceeffects.ripple.RippleView import com.android.systemui.statusbar.commandline.Command import com.android.systemui.statusbar.commandline.CommandRegistry import com.android.systemui.statusbar.policy.BatteryController import com.android.systemui.statusbar.policy.ConfigurationController -import com.android.systemui.surfaceeffects.ripple.RippleView import com.android.systemui.util.time.SystemClock import java.io.PrintWriter import javax.inject.Inject @@ -58,7 +57,6 @@ class WiredChargingRippleController @Inject constructor( featureFlags: FeatureFlags, private val context: Context, private val windowManager: WindowManager, - private val viewCaptureAwareWindowManager: ViewCaptureAwareWindowManager, private val systemClock: SystemClock, private val uiEventLogger: UiEventLogger ) { @@ -163,12 +161,12 @@ class WiredChargingRippleController @Inject constructor( override fun onViewAttachedToWindow(view: View) { layoutRipple() rippleView.startRipple(Runnable { - viewCaptureAwareWindowManager.removeView(rippleView) + windowManager.removeView(rippleView) }) rippleView.removeOnAttachStateChangeListener(this) } }) - viewCaptureAwareWindowManager.addView(rippleView, windowLayoutParams) + windowManager.addView(rippleView, windowLayoutParams) uiEventLogger.log(WiredChargingRippleEvent.CHARGING_RIPPLE_PLAYED) } diff --git a/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingAnimation.java b/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingAnimation.java index e5e9c4685264..4ca55400561e 100644 --- a/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingAnimation.java +++ b/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingAnimation.java @@ -28,10 +28,10 @@ import android.util.Slog; import android.view.Gravity; import android.view.WindowManager; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.logging.UiEvent; import com.android.internal.logging.UiEventLogger; import com.android.systemui.surfaceeffects.ripple.RippleShader.RippleShape; +import com.android.systemui.utils.windowmanager.WindowManagerProvider; /** * A WirelessChargingAnimation is a view containing view + animation for wireless charging. @@ -60,11 +60,11 @@ public class WirelessChargingAnimation { */ private WirelessChargingAnimation(@NonNull Context context, @Nullable Looper looper, int transmittingBatteryLevel, int batteryLevel, Callback callback, boolean isDozing, - RippleShape rippleShape, UiEventLogger uiEventLogger, - ViewCaptureAwareWindowManager viewCaptureAwareWindowManager) { + RippleShape rippleShape, UiEventLogger uiEventLogger, WindowManager windowManager, + WindowManagerProvider windowManagerProvider) { mCurrentWirelessChargingView = new WirelessChargingView(context, looper, transmittingBatteryLevel, batteryLevel, callback, isDozing, - rippleShape, uiEventLogger, viewCaptureAwareWindowManager); + rippleShape, uiEventLogger, windowManager, windowManagerProvider); } /** @@ -75,11 +75,11 @@ public class WirelessChargingAnimation { public static WirelessChargingAnimation makeWirelessChargingAnimation(@NonNull Context context, @Nullable Looper looper, int transmittingBatteryLevel, int batteryLevel, Callback callback, boolean isDozing, RippleShape rippleShape, - UiEventLogger uiEventLogger, - ViewCaptureAwareWindowManager viewCaptureAwareWindowManager) { + UiEventLogger uiEventLogger, WindowManager windowManager, + WindowManagerProvider windowManagerProvider) { return new WirelessChargingAnimation(context, looper, transmittingBatteryLevel, - batteryLevel, callback, isDozing, rippleShape, uiEventLogger, - viewCaptureAwareWindowManager); + batteryLevel, callback, isDozing, rippleShape, uiEventLogger, windowManager, + windowManagerProvider); } /** @@ -88,10 +88,10 @@ public class WirelessChargingAnimation { */ public static WirelessChargingAnimation makeChargingAnimationWithNoBatteryLevel( @NonNull Context context, RippleShape rippleShape, UiEventLogger uiEventLogger, - ViewCaptureAwareWindowManager viewCaptureAwareWindowManager) { + WindowManager windowManager, WindowManagerProvider windowManagerProvider) { return makeWirelessChargingAnimation(context, null, UNKNOWN_BATTERY_LEVEL, UNKNOWN_BATTERY_LEVEL, null, false, - rippleShape, uiEventLogger, viewCaptureAwareWindowManager); + rippleShape, uiEventLogger, windowManager, windowManagerProvider); } /** @@ -123,19 +123,21 @@ public class WirelessChargingAnimation { private int mGravity; private WirelessChargingLayout mView; private WirelessChargingLayout mNextView; - private ViewCaptureAwareWindowManager mWM; + private WindowManager mWM; private Callback mCallback; + private WindowManagerProvider mWindowManagerProvider; public WirelessChargingView(Context context, @Nullable Looper looper, int transmittingBatteryLevel, int batteryLevel, Callback callback, boolean isDozing, RippleShape rippleShape, UiEventLogger uiEventLogger, - ViewCaptureAwareWindowManager viewCaptureAwareWindowManager) { + WindowManager windowManager, WindowManagerProvider windowManagerProvider) { mCallback = callback; mNextView = new WirelessChargingLayout(context, transmittingBatteryLevel, batteryLevel, isDozing, rippleShape); mGravity = Gravity.CENTER_HORIZONTAL | Gravity.CENTER; mUiEventLogger = uiEventLogger; - mWM = viewCaptureAwareWindowManager; + mWM = windowManager; + mWindowManagerProvider = windowManagerProvider; final WindowManager.LayoutParams params = mParams; params.height = WindowManager.LayoutParams.MATCH_PARENT; @@ -207,6 +209,7 @@ public class WirelessChargingAnimation { if (context == null) { context = mView.getContext(); } + mWM = mWindowManagerProvider.getWindowManager(context); mParams.packageName = packageName; mParams.hideTimeoutMilliseconds = DURATION; diff --git a/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardOverlayWindow.java b/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardOverlayWindow.java index dc3b50c93298..059ea3271235 100644 --- a/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardOverlayWindow.java +++ b/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardOverlayWindow.java @@ -27,7 +27,6 @@ import android.view.Window; import android.view.WindowInsets; import android.view.WindowManager; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.policy.PhoneWindow; import com.android.systemui.clipboardoverlay.dagger.ClipboardOverlayModule.OverlayWindowContext; import com.android.systemui.screenshot.FloatingWindowUtil; @@ -45,7 +44,6 @@ public class ClipboardOverlayWindow extends PhoneWindow private final Context mContext; private final WindowManager mWindowManager; - private final ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager; private final WindowManager.LayoutParams mWindowLayoutParams; private boolean mKeyboardVisible; @@ -55,7 +53,6 @@ public class ClipboardOverlayWindow extends PhoneWindow @Inject ClipboardOverlayWindow(@OverlayWindowContext Context context, - @OverlayWindowContext ViewCaptureAwareWindowManager viewCaptureAwareWindowManager, @OverlayWindowContext WindowManager windowManager) { super(context); mContext = context; @@ -66,10 +63,9 @@ public class ClipboardOverlayWindow extends PhoneWindow requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS); setBackgroundDrawableResource(android.R.color.transparent); mWindowManager = windowManager; - mViewCaptureAwareWindowManager = viewCaptureAwareWindowManager; mWindowLayoutParams = FloatingWindowUtil.getFloatingWindowParams(); mWindowLayoutParams.setTitle("ClipboardOverlay"); - setWindowManager(windowManager, null, null); + setWindowManager(mWindowManager, null, null); setWindowFocusable(false); } @@ -86,12 +82,10 @@ public class ClipboardOverlayWindow extends PhoneWindow attach(); withWindowAttached(() -> { - WindowInsets currentInsets = mWindowManager.getCurrentWindowMetrics() - .getWindowInsets(); + WindowInsets currentInsets = mWindowManager.getCurrentWindowMetrics().getWindowInsets(); mKeyboardVisible = currentInsets.isVisible(WindowInsets.Type.ime()); peekDecorView().getViewTreeObserver().addOnGlobalLayoutListener(() -> { - WindowInsets insets = mWindowManager.getCurrentWindowMetrics() - .getWindowInsets(); + WindowInsets insets = mWindowManager.getCurrentWindowMetrics().getWindowInsets(); boolean keyboardVisible = insets.isVisible(WindowInsets.Type.ime()); if (keyboardVisible != mKeyboardVisible) { mKeyboardVisible = keyboardVisible; @@ -112,7 +106,7 @@ public class ClipboardOverlayWindow extends PhoneWindow void remove() { final View decorView = peekDecorView(); if (decorView != null && decorView.isAttachedToWindow()) { - mViewCaptureAwareWindowManager.removeViewImmediate(decorView); + mWindowManager.removeViewImmediate(decorView); } } @@ -146,7 +140,7 @@ public class ClipboardOverlayWindow extends PhoneWindow if (decorView.isAttachedToWindow()) { return; } - mViewCaptureAwareWindowManager.addView(decorView, mWindowLayoutParams); + mWindowManager.addView(decorView, mWindowLayoutParams); decorView.requestApplyInsets(); } @@ -167,7 +161,7 @@ public class ClipboardOverlayWindow extends PhoneWindow } final View decorView = peekDecorView(); if (decorView != null && decorView.isAttachedToWindow()) { - mViewCaptureAwareWindowManager.updateViewLayout(decorView, mWindowLayoutParams); + mWindowManager.updateViewLayout(decorView, mWindowLayoutParams); } } } diff --git a/packages/SystemUI/src/com/android/systemui/clipboardoverlay/dagger/ClipboardOverlayModule.java b/packages/SystemUI/src/com/android/systemui/clipboardoverlay/dagger/ClipboardOverlayModule.java index c86a84b17efe..7a60cce63a33 100644 --- a/packages/SystemUI/src/com/android/systemui/clipboardoverlay/dagger/ClipboardOverlayModule.java +++ b/packages/SystemUI/src/com/android/systemui/clipboardoverlay/dagger/ClipboardOverlayModule.java @@ -19,9 +19,7 @@ package com.android.systemui.clipboardoverlay.dagger; import static android.view.WindowManager.LayoutParams.TYPE_SCREENSHOT; import static com.android.systemui.Flags.clipboardOverlayMultiuser; -import static com.android.systemui.Flags.enableViewCaptureTracing; import static com.android.systemui.shared.Flags.usePreferredImageEditor; -import static com.android.systemui.util.ConvenienceExtensionsKt.toKotlinLazy; import static java.lang.annotation.RetentionPolicy.RUNTIME; @@ -31,8 +29,6 @@ import android.view.Display; import android.view.LayoutInflater; import android.view.WindowManager; -import com.android.app.viewcapture.ViewCapture; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.systemui.clipboardoverlay.ActionIntentCreator; import com.android.systemui.clipboardoverlay.ClipboardOverlayView; import com.android.systemui.clipboardoverlay.DefaultIntentCreator; @@ -40,6 +36,7 @@ import com.android.systemui.clipboardoverlay.IntentCreator; import com.android.systemui.res.R; import com.android.systemui.settings.DisplayTracker; import com.android.systemui.settings.UserTracker; +import com.android.systemui.utils.windowmanager.WindowManagerProvider; import dagger.Lazy; import dagger.Module; @@ -89,21 +86,9 @@ public interface ClipboardOverlayModule { */ @Provides @OverlayWindowContext - static WindowManager provideWindowManager(@OverlayWindowContext Context context) { - return context.getSystemService(WindowManager.class); - } - - /** - * - */ - @Provides - @OverlayWindowContext - static ViewCaptureAwareWindowManager provideViewCaptureAwareWindowManager( - @OverlayWindowContext WindowManager windowManager, - Lazy<ViewCapture> daggerLazyViewCapture) { - return new ViewCaptureAwareWindowManager(windowManager, - /* lazyViewCapture= */ toKotlinLazy(daggerLazyViewCapture), - /* isViewCaptureEnabled= */ enableViewCaptureTracing()); + static WindowManager provideWindowManager(@OverlayWindowContext Context context, + WindowManagerProvider windowManagerProvider) { + return windowManagerProvider.getWindowManager(context); } @Provides diff --git a/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java b/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java index 7354f4096801..f45bafdfb17e 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java @@ -16,9 +16,6 @@ package com.android.systemui.dagger; -import static com.android.systemui.Flags.enableViewCaptureTracing; -import static com.android.systemui.util.ConvenienceExtensionsKt.toKotlinLazy; - import android.annotation.Nullable; import android.annotation.SuppressLint; import android.app.ActivityManager; @@ -103,7 +100,6 @@ import android.telephony.CarrierConfigManager; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.telephony.satellite.SatelliteManager; -import android.view.Choreographer; import android.view.CrossWindowBlurListeners; import android.view.IWindowManager; import android.view.LayoutInflater; @@ -115,13 +111,9 @@ import android.view.accessibility.CaptioningManager; import android.view.inputmethod.InputMethodManager; import android.view.textclassifier.TextClassificationManager; -import androidx.annotation.NonNull; import androidx.asynclayoutinflater.view.AsyncLayoutInflater; import androidx.core.app.NotificationManagerCompat; -import com.android.app.viewcapture.ViewCapture; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; -import com.android.app.viewcapture.ViewCaptureFactory; import com.android.internal.app.IBatteryStats; import com.android.internal.appwidget.IAppWidgetService; import com.android.internal.jank.InteractionJankMonitor; @@ -135,8 +127,9 @@ import com.android.systemui.dagger.qualifiers.TestHarness; import com.android.systemui.shared.system.PackageManagerWrapper; import com.android.systemui.user.utils.UserScopedService; import com.android.systemui.user.utils.UserScopedServiceImpl; +import com.android.systemui.utils.windowmanager.WindowManagerProvider; +import com.android.systemui.utils.windowmanager.WindowManagerProviderImpl; -import dagger.Lazy; import dagger.Module; import dagger.Provides; @@ -713,38 +706,23 @@ public class FrameworkServicesModule { @Provides @Singleton - static WindowManager provideWindowManager(Context context) { - return context.getSystemService(WindowManager.class); - } - - /** A window manager working for the default display only. */ - @Provides - @Singleton - @Main - static WindowManager provideMainWindowManager(WindowManager windowManager) { - return windowManager; + static WindowManagerProvider provideWindowManagerProvider() { + return new WindowManagerProviderImpl(); } @Provides @Singleton - static ViewCaptureAwareWindowManager provideViewCaptureAwareWindowManager( - WindowManager windowManager, Lazy<ViewCapture> daggerLazyViewCapture) { - return new ViewCaptureAwareWindowManager(windowManager, - /* lazyViewCapture= */ toKotlinLazy(daggerLazyViewCapture), - /* isViewCaptureEnabled= */ enableViewCaptureTracing()); + static WindowManager provideWindowManager(Context context, + WindowManagerProvider windowManagerProvider) { + return windowManagerProvider.getWindowManager(context); } + /** A window manager working for the default display only. */ @Provides @Singleton - static ViewCaptureAwareWindowManager.Factory viewCaptureAwareWindowManagerFactory( - Lazy<ViewCapture> daggerLazyViewCapture) { - return new ViewCaptureAwareWindowManager.Factory() { - @NonNull - @Override - public ViewCaptureAwareWindowManager create(@NonNull WindowManager windowManager) { - return provideViewCaptureAwareWindowManager(windowManager, daggerLazyViewCapture); - } - }; + @Main + static WindowManager provideMainWindowManager(WindowManager windowManager) { + return windowManager; } @Provides @@ -835,12 +813,6 @@ public class FrameworkServicesModule { @Provides @Singleton - static ViewCapture provideViewCapture(Context context) { - return ViewCaptureFactory.getInstance(context); - } - - @Provides - @Singleton @Nullable static SupervisionManager provideSupervisionManager(Context context) { return (SupervisionManager) context.getSystemService(Context.SUPERVISION_SERVICE); diff --git a/packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayWindowPropertiesRepository.kt b/packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayWindowPropertiesRepository.kt index 3390640fa6c6..aaaaacef001a 100644 --- a/packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayWindowPropertiesRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayWindowPropertiesRepository.kt @@ -31,6 +31,7 @@ import com.android.systemui.display.shared.model.DisplayWindowProperties import com.android.systemui.res.R import com.android.systemui.shade.shared.flag.ShadeWindowGoesAround import com.android.systemui.statusbar.core.StatusBarConnectedDisplays +import com.android.systemui.utils.windowmanager.WindowManagerUtils import com.google.common.collect.HashBasedTable import com.google.common.collect.Table import java.io.PrintWriter @@ -110,7 +111,7 @@ constructor( return null } @SuppressLint("NonInjectedService") // Need to manually get the service - val windowManager = context.getSystemService(WindowManager::class.java) as WindowManager + val windowManager = WindowManagerUtils.getWindowManager(context) val layoutInflater = LayoutInflater.from(context) DisplayWindowProperties(displayId, windowType, context, windowManager, layoutInflater) } diff --git a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java index a2bcb98e36fe..fd716eea799a 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java @@ -46,7 +46,6 @@ import androidx.lifecycle.LifecycleService; import androidx.lifecycle.ServiceLifecycleDispatcher; import androidx.lifecycle.ViewModelStore; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.compose.animation.scene.OverlayKey; import com.android.internal.logging.UiEvent; import com.android.internal.logging.UiEventLogger; @@ -117,7 +116,7 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ @Nullable private final ComponentName mHomeControlPanelDreamComponent; private final UiEventLogger mUiEventLogger; - private final ViewCaptureAwareWindowManager mWindowManager; + private final WindowManager mWindowManager; private final String mWindowTitle; // A reference to the {@link Window} used to hold the dream overlay. @@ -378,7 +377,7 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ Context context, DreamOverlayLifecycleOwner lifecycleOwner, @Main DelayableExecutor executor, - ViewCaptureAwareWindowManager viewCaptureAwareWindowManager, + WindowManager windowManager, ComplicationComponent.Factory complicationComponentFactory, DreamComplicationComponent.Factory dreamComplicationComponentFactory, DreamOverlayComponent.Factory dreamOverlayComponentFactory, @@ -403,7 +402,7 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ super(executor); mContext = context; mExecutor = executor; - mWindowManager = viewCaptureAwareWindowManager; + mWindowManager = windowManager; mKeyguardUpdateMonitor = keyguardUpdateMonitor; mScrimManager = scrimManager; mLowLightDreamComponent = lowLightDreamComponent; diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/docking/binder/KeyboardDockingIndicationViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyboard/docking/binder/KeyboardDockingIndicationViewBinder.kt index c2974a8d5429..c08a8e297174 100644 --- a/packages/SystemUI/src/com/android/systemui/keyboard/docking/binder/KeyboardDockingIndicationViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyboard/docking/binder/KeyboardDockingIndicationViewBinder.kt @@ -20,7 +20,6 @@ import android.content.Context import android.graphics.Paint import android.graphics.PixelFormat import android.view.WindowManager -import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.keyboard.docking.ui.KeyboardDockingIndicationView @@ -38,7 +37,7 @@ constructor( context: Context, @Application private val applicationScope: CoroutineScope, private val viewModel: KeyboardDockingIndicationViewModel, - private val windowManager: ViewCaptureAwareWindowManager, + private val windowManager: WindowManager ) { private val windowLayoutParams = diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/SideFpsProgressBar.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/SideFpsProgressBar.kt index 1fd609dba637..853f1769994e 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/SideFpsProgressBar.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/SideFpsProgressBar.kt @@ -26,7 +26,6 @@ import android.view.ViewGroup.LayoutParams.MATCH_PARENT import android.view.WindowManager import android.widget.ProgressBar import androidx.core.view.isGone -import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.systemui.dagger.SysUISingleton import com.android.systemui.res.R import javax.inject.Inject @@ -38,7 +37,7 @@ class SideFpsProgressBar @Inject constructor( private val layoutInflater: LayoutInflater, - private val windowManager: ViewCaptureAwareWindowManager, + private val windowManager: WindowManager, ) { private var overlayView: View? = null @@ -91,7 +90,7 @@ constructor( ) { if (overlayView == null) { overlayView = layoutInflater.inflate(R.layout.sidefps_progress_bar, null, false) - windowManager.addView(requireNotNull(overlayView), overlayViewParams) + windowManager.addView(overlayView, overlayViewParams) progressBar?.pivotX = 0.0f progressBar?.pivotY = 0.0f } diff --git a/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/MediaTttChipControllerReceiver.kt b/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/MediaTttChipControllerReceiver.kt index 2a23620839e5..6a2c4519e1a5 100644 --- a/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/MediaTttChipControllerReceiver.kt +++ b/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/MediaTttChipControllerReceiver.kt @@ -35,7 +35,6 @@ import android.view.ViewGroup import android.view.WindowManager import android.view.accessibility.AccessibilityManager import com.android.app.animation.Interpolators -import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.internal.logging.InstanceId import com.android.internal.widget.CachingIconView import com.android.systemui.common.shared.model.ContentDescription @@ -73,7 +72,7 @@ constructor( private val commandQueue: CommandQueue, context: Context, logger: MediaTttReceiverLogger, - viewCaptureAwareWindowManager: ViewCaptureAwareWindowManager, + windowManager: WindowManager, @Main private val mainExecutor: DelayableExecutor, accessibilityManager: AccessibilityManager, configurationController: ConfigurationController, @@ -90,7 +89,7 @@ constructor( TemporaryViewDisplayController<ChipReceiverInfo, MediaTttReceiverLogger>( context, logger, - viewCaptureAwareWindowManager, + windowManager, mainExecutor, accessibilityManager, configurationController, diff --git a/packages/SystemUI/src/com/android/systemui/mediaprojection/appselector/view/MediaProjectionTaskView.kt b/packages/SystemUI/src/com/android/systemui/mediaprojection/appselector/view/MediaProjectionTaskView.kt index 9265bfb2f66b..5ffa7fa0ef8d 100644 --- a/packages/SystemUI/src/com/android/systemui/mediaprojection/appselector/view/MediaProjectionTaskView.kt +++ b/packages/SystemUI/src/com/android/systemui/mediaprojection/appselector/view/MediaProjectionTaskView.kt @@ -26,13 +26,13 @@ import android.graphics.Shader import android.util.AttributeSet import android.view.View import android.view.WindowManager -import androidx.core.content.getSystemService import androidx.core.content.res.use import com.android.systemui.res.R import com.android.systemui.mediaprojection.appselector.data.RecentTask import com.android.systemui.shared.recents.model.ThumbnailData import com.android.systemui.shared.recents.utilities.PreviewPositionHelper import com.android.systemui.shared.recents.utilities.Utilities.isLargeScreen +import com.android.systemui.utils.windowmanager.WindowManagerUtils /** * Custom view that shows a thumbnail preview of one recent task based on [ThumbnailData]. @@ -53,7 +53,7 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 } } - private val windowManager: WindowManager = context.getSystemService()!! + private val windowManager: WindowManager = WindowManagerUtils.getWindowManager(context) private val paint = Paint(Paint.ANTI_ALIAS_FLAG) private val backgroundPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { color = defaultBackgroundColor } diff --git a/packages/SystemUI/src/com/android/systemui/mediaprojection/appselector/view/TaskPreviewSizeProvider.kt b/packages/SystemUI/src/com/android/systemui/mediaprojection/appselector/view/TaskPreviewSizeProvider.kt index c829471f53f3..57fd1e790f0b 100644 --- a/packages/SystemUI/src/com/android/systemui/mediaprojection/appselector/view/TaskPreviewSizeProvider.kt +++ b/packages/SystemUI/src/com/android/systemui/mediaprojection/appselector/view/TaskPreviewSizeProvider.kt @@ -19,6 +19,7 @@ package com.android.systemui.mediaprojection.appselector.view import android.content.Context import android.content.res.Configuration import android.graphics.Rect +import android.view.WindowManager import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.LifecycleOwner import com.android.systemui.mediaprojection.appselector.MediaProjectionAppSelectorScope @@ -36,6 +37,7 @@ constructor( private val context: Context, private val windowMetricsProvider: WindowMetricsProvider, private val configurationController: ConfigurationController, + private val windowManager: WindowManager, ) : CallbackController<TaskPreviewSizeListener>, ConfigurationListener, DefaultLifecycleObserver { /** Returns the size of the task preview on the screen in pixels */ @@ -65,7 +67,7 @@ constructor( val width = maxWindowBounds.width() var height = maximumWindowHeight - val isLargeScreen = isLargeScreen(context) + val isLargeScreen = isLargeScreen(windowManager, context.resources) if (isLargeScreen) { val taskbarSize = windowMetricsProvider.currentWindowInsets.bottom height -= taskbarSize diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarModule.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarModule.java index 39482bea0111..c5c8c01f8b39 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarModule.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarModule.java @@ -16,17 +16,12 @@ package com.android.systemui.navigationbar; -import static com.android.systemui.Flags.enableViewCaptureTracing; -import static com.android.systemui.util.ConvenienceExtensionsKt.toKotlinLazy; - import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager; import com.android.app.displaylib.PerDisplayRepository; -import com.android.app.viewcapture.ViewCapture; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.systemui.dagger.qualifiers.DisplayId; import com.android.systemui.model.SysUiState; import com.android.systemui.navigationbar.NavigationBarComponent.NavigationBarScope; @@ -34,8 +29,8 @@ import com.android.systemui.navigationbar.views.NavigationBarFrame; import com.android.systemui.navigationbar.views.NavigationBarView; import com.android.systemui.res.R; import com.android.systemui.shade.shared.flag.ShadeWindowGoesAround; +import com.android.systemui.utils.windowmanager.WindowManagerProvider; -import dagger.Lazy; import dagger.Module; import dagger.Provides; @@ -70,8 +65,9 @@ public interface NavigationBarModule { @Provides @NavigationBarScope @DisplayId - static WindowManager provideWindowManager(@DisplayId Context context) { - return context.getSystemService(WindowManager.class); + static WindowManager provideWindowManager(@DisplayId Context context, + WindowManagerProvider windowManagerProvider) { + return windowManagerProvider.getWindowManager(context); } /** A SysUiState for the navigation bar display. */ @@ -87,15 +83,4 @@ public interface NavigationBarModule { return defaultState; } } - - /** A ViewCaptureAwareWindowManager specific to the display's context. */ - @Provides - @NavigationBarScope - @DisplayId - static ViewCaptureAwareWindowManager provideViewCaptureAwareWindowManager( - @DisplayId WindowManager windowManager, Lazy<ViewCapture> daggerLazyViewCapture) { - return new ViewCaptureAwareWindowManager(windowManager, - /* lazyViewCapture= */ toKotlinLazy(daggerLazyViewCapture), - /* isViewCaptureEnabled= */ enableViewCaptureTracing()); - } } diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/BackPanelController.kt b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/BackPanelController.kt index 44c828731e24..6d7492686985 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/BackPanelController.kt +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/BackPanelController.kt @@ -33,7 +33,6 @@ import androidx.annotation.VisibleForTesting import androidx.core.os.postDelayed import androidx.core.view.isVisible import androidx.dynamicanimation.animation.DynamicAnimation -import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.internal.jank.Cuj import com.android.internal.jank.InteractionJankMonitor import com.android.internal.util.LatencyTracker @@ -85,7 +84,7 @@ class BackPanelController @AssistedInject constructor( @Assisted context: Context, - private val windowManager: ViewCaptureAwareWindowManager, + private val windowManager: WindowManager, private val viewConfiguration: ViewConfiguration, @Assisted private val mainHandler: Handler, private val systemClock: SystemClock, diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/views/NavigationBar.java b/packages/SystemUI/src/com/android/systemui/navigationbar/views/NavigationBar.java index 8b5b3adeef1f..ad0acbdaf702 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/views/NavigationBar.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/views/NavigationBar.java @@ -104,7 +104,6 @@ import android.view.inputmethod.InputMethodManager; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.UiEvent; import com.android.internal.logging.UiEventLogger; @@ -199,7 +198,6 @@ public class NavigationBar extends ViewController<NavigationBarView> implements private final Context mContext; private final Bundle mSavedState; private final WindowManager mWindowManager; - private final ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager; private final AccessibilityManager mAccessibilityManager; private final DeviceProvisionedController mDeviceProvisionedController; private final StatusBarStateController mStatusBarStateController; @@ -560,7 +558,6 @@ public class NavigationBar extends ViewController<NavigationBarView> implements @Nullable Bundle savedState, @DisplayId Context context, @DisplayId WindowManager windowManager, - @DisplayId ViewCaptureAwareWindowManager viewCaptureAwareWindowManager, Lazy<AssistManager> assistManagerLazy, AccessibilityManager accessibilityManager, DeviceProvisionedController deviceProvisionedController, @@ -605,7 +602,6 @@ public class NavigationBar extends ViewController<NavigationBarView> implements mContext = context; mSavedState = savedState; mWindowManager = windowManager; - mViewCaptureAwareWindowManager = viewCaptureAwareWindowManager; mAccessibilityManager = accessibilityManager; mDeviceProvisionedController = deviceProvisionedController; mStatusBarStateController = statusBarStateController; @@ -726,7 +722,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements if (DEBUG) Log.v(TAG, "addNavigationBar: about to add " + mView); try { - mViewCaptureAwareWindowManager.addView( + mWindowManager.addView( mFrame, getBarLayoutParams( mContext.getResources() @@ -783,7 +779,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements mCommandQueue.removeCallback(this); Trace.beginSection("NavigationBar#removeViewImmediate"); try { - mViewCaptureAwareWindowManager.removeViewImmediate(mView.getRootView()); + mWindowManager.removeViewImmediate(mView.getRootView()); } catch (IllegalArgumentException e) { // Wrapping this in a try/catch to avoid crashes when a display is instantly removed // after being added, and initialization hasn't finished yet. @@ -888,7 +884,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements resetSecondaryHandle(); getBarTransitions().removeDarkIntensityListener(mOrientationHandleIntensityListener); try { - mViewCaptureAwareWindowManager.removeView(mOrientationHandle); + mWindowManager.removeView(mOrientationHandle); } catch (IllegalArgumentException e) { // Wrapping this in a try/catch to avoid crashes when a display is instantly removed // after being added, and initialization hasn't finished yet. @@ -967,7 +963,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements mOrientationParams.privateFlags |= PRIVATE_FLAG_NO_MOVE_ANIMATION | WindowManager.LayoutParams.PRIVATE_FLAG_LAYOUT_SIZE_EXTENDED_BY_CUTOUT; try { - mViewCaptureAwareWindowManager.addView(mOrientationHandle, mOrientationParams); + mWindowManager.addView(mOrientationHandle, mOrientationParams); } catch (WindowManager.InvalidDisplayException e) { // Wrapping this in a try/catch to avoid crashes when a display is instantly removed // after being added, and initialization hasn't finished yet. diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/views/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/navigationbar/views/NavigationBarView.java index cbc4c26b2f94..d2974e9f90bd 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/views/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/views/NavigationBarView.java @@ -87,6 +87,7 @@ import com.android.systemui.shared.system.QuickStepContract; import com.android.systemui.statusbar.phone.AutoHideController; import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.LightBarTransitionsController; +import com.android.systemui.utils.windowmanager.WindowManagerUtils; import com.android.wm.shell.back.BackAnimation; import com.android.wm.shell.pip.Pip; @@ -729,7 +730,7 @@ public class NavigationBarView extends FrameLayout { } else { return; } - WindowManager wm = getContext().getSystemService(WindowManager.class); + WindowManager wm = WindowManagerUtils.getWindowManager(getContext()); wm.updateViewLayout((View) getParent(), lp); } } diff --git a/packages/SystemUI/src/com/android/systemui/power/InattentiveSleepWarningView.java b/packages/SystemUI/src/com/android/systemui/power/InattentiveSleepWarningView.java index 2ecca2d8c776..f37a86e2b9d5 100644 --- a/packages/SystemUI/src/com/android/systemui/power/InattentiveSleepWarningView.java +++ b/packages/SystemUI/src/com/android/systemui/power/InattentiveSleepWarningView.java @@ -16,8 +16,6 @@ package com.android.systemui.power; -import static com.android.systemui.Flags.enableViewCaptureTracing; - import android.animation.Animator; import android.animation.AnimatorInflater; import android.animation.AnimatorListenerAdapter; @@ -30,28 +28,21 @@ import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.widget.FrameLayout; - -import com.android.app.viewcapture.ViewCapture; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.systemui.res.R; -import kotlin.Lazy; - /** * View that shows a warning shortly before the device goes into sleep * after prolonged user inactivity when bound to. */ public class InattentiveSleepWarningView extends FrameLayout { private final IBinder mWindowToken = new Binder(); - private final ViewCaptureAwareWindowManager mWindowManager; + private final WindowManager mWindowManager; private Animator mFadeOutAnimator; private boolean mDismissing; - InattentiveSleepWarningView(Context context, Lazy<ViewCapture> lazyViewCapture) { + InattentiveSleepWarningView(Context context, WindowManager windowManager) { super(context); - WindowManager wm = mContext.getSystemService(WindowManager.class); - mWindowManager = new ViewCaptureAwareWindowManager(wm, lazyViewCapture, - enableViewCaptureTracing()); + mWindowManager = windowManager; final LayoutInflater layoutInflater = LayoutInflater.from(mContext); layoutInflater.inflate(R.layout.inattentive_sleep_warning, this, true /* attachToRoot */); diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerUI.java b/packages/SystemUI/src/com/android/systemui/power/PowerUI.java index 861a7ce282af..4e1bfd15e58c 100644 --- a/packages/SystemUI/src/com/android/systemui/power/PowerUI.java +++ b/packages/SystemUI/src/com/android/systemui/power/PowerUI.java @@ -16,8 +16,6 @@ package com.android.systemui.power; -import static com.android.systemui.util.ConvenienceExtensionsKt.toKotlinLazy; - import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.Context; @@ -42,11 +40,11 @@ import android.service.vr.IVrStateCallbacks; import android.text.format.DateUtils; import android.util.Log; import android.util.Slog; +import android.view.WindowManager; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import com.android.app.viewcapture.ViewCapture; import com.android.internal.annotations.VisibleForTesting; import com.android.settingslib.fuelgauge.Estimate; import com.android.settingslib.utils.ThreadUtils; @@ -59,8 +57,6 @@ import com.android.systemui.settings.UserTracker; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.policy.ConfigurationController; -import kotlin.Lazy; - import java.io.PrintWriter; import java.util.Arrays; import java.util.concurrent.Future; @@ -120,9 +116,9 @@ public class PowerUI implements private IThermalEventListener mSkinThermalEventListener; private IThermalEventListener mUsbThermalEventListener; private final Context mContext; + private final WindowManager mWindowManager; private final BroadcastDispatcher mBroadcastDispatcher; private final CommandQueue mCommandQueue; - private final Lazy<ViewCapture> mLazyViewCapture; @Nullable private final IVrManager mVrManager; private final WakefulnessLifecycle.Observer mWakefulnessObserver = @@ -164,7 +160,7 @@ public class PowerUI implements WakefulnessLifecycle wakefulnessLifecycle, PowerManager powerManager, UserTracker userTracker, - dagger.Lazy<ViewCapture> daggerLazyViewCapture) { + WindowManager windowManager) { mContext = context; mBroadcastDispatcher = broadcastDispatcher; mCommandQueue = commandQueue; @@ -174,7 +170,7 @@ public class PowerUI implements mPowerManager = powerManager; mWakefulnessLifecycle = wakefulnessLifecycle; mUserTracker = userTracker; - mLazyViewCapture = toKotlinLazy(daggerLazyViewCapture); + mWindowManager = windowManager; } public void start() { @@ -649,7 +645,7 @@ public class PowerUI implements @Override public void showInattentiveSleepWarning() { if (mOverlayView == null) { - mOverlayView = new InattentiveSleepWarningView(mContext, mLazyViewCapture); + mOverlayView = new InattentiveSleepWarningView(mContext, mWindowManager); } mOverlayView.show(); diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDetailsContentController.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDetailsContentController.java index 6b5a22a4fc09..945e051606b9 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDetailsContentController.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDetailsContentController.java @@ -65,7 +65,6 @@ import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import androidx.annotation.WorkerThread; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.logging.UiEventLogger; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; @@ -186,7 +185,7 @@ public class InternetDetailsContentController implements AccessPointController.A private GlobalSettings mGlobalSettings; private int mDefaultDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; private ConnectivityManager.NetworkCallback mConnectivityManagerNetworkCallback; - private ViewCaptureAwareWindowManager mWindowManager; + private WindowManager mWindowManager; private ToastFactory mToastFactory; private SignalDrawable mSignalDrawable; private SignalDrawable mSecondarySignalDrawable; // For the secondary mobile data sub in DSDS @@ -252,7 +251,7 @@ public class InternetDetailsContentController implements AccessPointController.A @Main Handler handler, @Main Executor mainExecutor, BroadcastDispatcher broadcastDispatcher, KeyguardUpdateMonitor keyguardUpdateMonitor, GlobalSettings globalSettings, KeyguardStateController keyguardStateController, - ViewCaptureAwareWindowManager viewCaptureAwareWindowManager, ToastFactory toastFactory, + @ShadeDisplayAware WindowManager windowManager, ToastFactory toastFactory, @Background Handler workerHandler, CarrierConfigTracker carrierConfigTracker, LocationController locationController, @@ -284,7 +283,7 @@ public class InternetDetailsContentController implements AccessPointController.A mAccessPointController = accessPointController; mWifiIconInjector = new WifiUtils.InternetIconInjector(mContext); mConnectivityManagerNetworkCallback = new DataConnectivityListener(); - mWindowManager = viewCaptureAwareWindowManager; + mWindowManager = windowManager; mToastFactory = toastFactory; mSignalDrawable = new SignalDrawable(mContext); mSecondarySignalDrawable = new SignalDrawable(mContext); diff --git a/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java b/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java index 432a35a1a3dd..a1281ec23f92 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java +++ b/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java @@ -16,9 +16,7 @@ package com.android.systemui.recents; -import static com.android.systemui.Flags.enableViewCaptureTracing; import static com.android.systemui.shared.recents.utilities.Utilities.isLargeScreen; -import static com.android.systemui.util.ConvenienceExtensionsKt.toKotlinLazy; import static com.android.systemui.util.leak.RotationUtils.ROTATION_LANDSCAPE; import static com.android.systemui.util.leak.RotationUtils.ROTATION_NONE; import static com.android.systemui.util.leak.RotationUtils.ROTATION_SEASCAPE; @@ -55,8 +53,6 @@ import android.widget.TextView; import androidx.annotation.NonNull; -import com.android.app.viewcapture.ViewCapture; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.systemui.CoreStartable; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.dagger.SysUISingleton; @@ -87,7 +83,6 @@ public class ScreenPinningRequest implements private final Lazy<NavigationBarController> mNavigationBarControllerLazy; private final AccessibilityManager mAccessibilityService; private final WindowManager mWindowManager; - private final ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager; private final BroadcastDispatcher mBroadcastDispatcher; private final UserTracker mUserTracker; @@ -112,15 +107,12 @@ public class ScreenPinningRequest implements Lazy<NavigationBarController> navigationBarControllerLazy, BroadcastDispatcher broadcastDispatcher, UserTracker userTracker, - Lazy<ViewCapture> daggerLazyViewCapture) { + WindowManager windowManager) { mContext = context; mNavigationBarControllerLazy = navigationBarControllerLazy; mAccessibilityService = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); - mWindowManager = (WindowManager) - mContext.getSystemService(Context.WINDOW_SERVICE); - mViewCaptureAwareWindowManager = new ViewCaptureAwareWindowManager(mWindowManager, - toKotlinLazy(daggerLazyViewCapture), enableViewCaptureTracing()); + mWindowManager = windowManager; mNavBarMode = navigationModeController.addListener(this); mBroadcastDispatcher = broadcastDispatcher; mUserTracker = userTracker; @@ -131,7 +123,7 @@ public class ScreenPinningRequest implements public void clearPrompt() { if (mRequestWindow != null) { - mViewCaptureAwareWindowManager.removeView(mRequestWindow); + mWindowManager.removeView(mRequestWindow); mRequestWindow = null; } } @@ -152,7 +144,7 @@ public class ScreenPinningRequest implements // show the confirmation WindowManager.LayoutParams lp = getWindowLayoutParams(); - mViewCaptureAwareWindowManager.addView(mRequestWindow, lp); + mWindowManager.addView(mRequestWindow, lp); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotWindow.kt b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotWindow.kt index c4fe7a428084..644e12cba6fc 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotWindow.kt +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotWindow.kt @@ -31,7 +31,6 @@ import android.view.Window import android.view.WindowInsets import android.view.WindowManager import android.window.WindowContext -import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.internal.policy.PhoneWindow import dagger.assisted.Assisted import dagger.assisted.AssistedFactory @@ -42,7 +41,6 @@ class ScreenshotWindow @AssistedInject constructor( private val windowManager: WindowManager, - private val viewCaptureAwareWindowManager: ViewCaptureAwareWindowManager, private val context: Context, @Assisted private val display: Display, ) { @@ -97,7 +95,7 @@ constructor( Log.d(TAG, "attachWindow") } attachRequested = true - viewCaptureAwareWindowManager.addView(decorView, params) + windowManager.addView(decorView, params) decorView.requestApplyInsets() decorView.requireViewById<ViewGroup>(R.id.content).apply { @@ -135,7 +133,7 @@ constructor( if (LogConfig.DEBUG_WINDOW) { Log.d(TAG, "Removing screenshot window") } - viewCaptureAwareWindowManager.removeViewImmediate(decorView) + windowManager.removeViewImmediate(decorView) detachRequested = false } if (attachRequested && !detachRequested) { diff --git a/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsControllerImpl.java b/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsControllerImpl.java index c671f7d9db14..4ad4ab3410d6 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsControllerImpl.java @@ -102,6 +102,7 @@ import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.statusbar.policy.SplitShadeStateController; import com.android.systemui.util.LargeScreenUtils; import com.android.systemui.util.kotlin.JavaAdapter; +import com.android.systemui.utils.windowmanager.WindowManagerProvider; import dalvik.annotation.optimization.NeverCompile; @@ -299,6 +300,8 @@ public class QuickSettingsControllerImpl implements QuickSettingsController, Dum private final Runnable mQsCollapseExpandAction = this::collapseOrExpandQs; private final QS.ScrollListener mQsScrollListener = this::onScroll; + private final WindowManagerProvider mWindowManagerProvider; + @Inject public QuickSettingsControllerImpl( Lazy<NotificationPanelViewController> panelViewControllerLazy, @@ -336,7 +339,8 @@ public class QuickSettingsControllerImpl implements QuickSettingsController, Dum CastController castController, SplitShadeStateController splitShadeStateController, Lazy<CommunalTransitionViewModel> communalTransitionViewModelLazy, - Lazy<LargeScreenHeaderHelper> largeScreenHeaderHelperLazy + Lazy<LargeScreenHeaderHelper> largeScreenHeaderHelperLazy, + WindowManagerProvider windowManagerProvider ) { SceneContainerFlag.assertInLegacyMode(); mPanelViewControllerLazy = panelViewControllerLazy; @@ -387,6 +391,8 @@ public class QuickSettingsControllerImpl implements QuickSettingsController, Dum mLockscreenShadeTransitionController.addCallback(new LockscreenShadeTransitionCallback()); dumpManager.registerDumpable(this); + + mWindowManagerProvider = windowManagerProvider; } @VisibleForTesting @@ -532,7 +538,7 @@ public class QuickSettingsControllerImpl implements QuickSettingsController, Dum * on ACTION_DOWN, and safely queried repeatedly thereafter during ACTION_MOVE events. */ void updateGestureInsetsCache() { - WindowManager wm = this.mPanelView.getContext().getSystemService(WindowManager.class); + WindowManager wm = mWindowManagerProvider.getWindowManager(this.mPanelView.getContext()); WindowMetrics windowMetrics = wm.getCurrentWindowMetrics(); mCachedGestureInsets = windowMetrics.getWindowInsets().getInsets( WindowInsets.Type.systemGestures()); diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeDisplayAwareModule.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeDisplayAwareModule.kt index cd224735cc62..446d4b450edc 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeDisplayAwareModule.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeDisplayAwareModule.kt @@ -49,6 +49,8 @@ import com.android.systemui.statusbar.notification.stack.NotificationStackRebind import com.android.systemui.statusbar.phone.ConfigurationControllerImpl import com.android.systemui.statusbar.phone.ConfigurationForwarder import com.android.systemui.statusbar.policy.ConfigurationController +import com.android.systemui.utils.windowmanager.WindowManagerProvider +import com.android.systemui.utils.windowmanager.WindowManagerUtils import dagger.Module import dagger.Provides import dagger.multibindings.ClassKey @@ -111,9 +113,10 @@ object ShadeDisplayAwareModule { fun provideShadeWindowManager( defaultWindowManager: WindowManager, @ShadeDisplayAware context: Context, + windowManagerProvider: WindowManagerProvider ): WindowManager { return if (ShadeWindowGoesAround.isEnabled) { - context.getSystemService(WindowManager::class.java) as WindowManager + windowManagerProvider.getWindowManager(context) } else { defaultWindowManager } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ImmersiveModeConfirmation.java b/packages/SystemUI/src/com/android/systemui/statusbar/ImmersiveModeConfirmation.java index 97e62d79b374..2a9a47d83dd4 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ImmersiveModeConfirmation.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ImmersiveModeConfirmation.java @@ -28,9 +28,6 @@ import static android.view.WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION; import static android.window.DisplayAreaOrganizer.FEATURE_UNDEFINED; import static android.window.DisplayAreaOrganizer.KEY_ROOT_DISPLAY_AREA_ID; -import static com.android.systemui.Flags.enableViewCaptureTracing; -import static com.android.systemui.util.ConvenienceExtensionsKt.toKotlinLazy; - import android.animation.ArgbEvaluator; import android.animation.ValueAnimator; import android.annotation.NonNull; @@ -76,16 +73,13 @@ import android.widget.Button; import android.widget.FrameLayout; import android.widget.RelativeLayout; -import com.android.app.viewcapture.ViewCapture; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.systemui.CoreStartable; import com.android.systemui.dagger.qualifiers.Background; import com.android.systemui.res.R; import com.android.systemui.shared.system.TaskStackChangeListener; import com.android.systemui.shared.system.TaskStackChangeListeners; import com.android.systemui.util.settings.SecureSettings; - -import kotlin.Lazy; +import com.android.systemui.utils.windowmanager.WindowManagerProvider; import javax.inject.Inject; @@ -112,13 +106,14 @@ public class ImmersiveModeConfirmation implements CoreStartable, CommandQueue.Ca private long mShowDelayMs = 0L; private final IBinder mWindowToken = new Binder(); private final CommandQueue mCommandQueue; + private final WindowManagerProvider mWindowManagerProvider; private ClingWindowView mClingWindow; /** The wrapper on the last {@link WindowManager} used to add the confirmation window. */ @Nullable - private ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager; + private WindowManager mWindowManager; /** - * The WindowContext that is registered with {@link #mViewCaptureAwareWindowManager} with + * The WindowContext that is registered with {@link #mWindowManager} with * options to specify the {@link RootDisplayArea} to attach the confirmation window. */ @Nullable @@ -136,21 +131,18 @@ public class ImmersiveModeConfirmation implements CoreStartable, CommandQueue.Ca private ContentObserver mContentObserver; - private Lazy<ViewCapture> mLazyViewCapture; - @Inject public ImmersiveModeConfirmation(Context context, CommandQueue commandQueue, - SecureSettings secureSettings, - dagger.Lazy<ViewCapture> daggerLazyViewCapture, - @Background Handler backgroundHandler) { + SecureSettings secureSettings, @Background Handler backgroundHandler, + WindowManagerProvider windowManagerProvider) { mSysUiContext = context; final Display display = mSysUiContext.getDisplay(); mDisplayContext = display.getDisplayId() == DEFAULT_DISPLAY ? mSysUiContext : mSysUiContext.createDisplayContext(display); mCommandQueue = commandQueue; mSecureSettings = secureSettings; - mLazyViewCapture = toKotlinLazy(daggerLazyViewCapture); mBackgroundHandler = backgroundHandler; + mWindowManagerProvider = windowManagerProvider; } boolean loadSetting(int currentUserId) { @@ -257,14 +249,14 @@ public class ImmersiveModeConfirmation implements CoreStartable, CommandQueue.Ca private void handleHide() { if (mClingWindow != null) { if (DEBUG) Log.d(TAG, "Hiding immersive mode confirmation"); - if (mViewCaptureAwareWindowManager != null) { + if (mWindowManager != null) { try { - mViewCaptureAwareWindowManager.removeView(mClingWindow); + mWindowManager.removeView(mClingWindow); } catch (WindowManager.InvalidDisplayException e) { Log.w(TAG, "Fail to hide the immersive confirmation window because of " + e); } - mViewCaptureAwareWindowManager = null; + mWindowManager = null; mWindowContext = null; } mClingWindow = null; @@ -525,8 +517,8 @@ public class ImmersiveModeConfirmation implements CoreStartable, CommandQueue.Ca * confirmation window. */ @NonNull - private ViewCaptureAwareWindowManager createWindowManager(int rootDisplayAreaId) { - if (mViewCaptureAwareWindowManager != null) { + private WindowManager createWindowManager(int rootDisplayAreaId) { + if (mWindowManager != null) { throw new IllegalStateException( "Must not create a new WindowManager while there is an existing one"); } @@ -535,10 +527,8 @@ public class ImmersiveModeConfirmation implements CoreStartable, CommandQueue.Ca mWindowContextRootDisplayAreaId = rootDisplayAreaId; mWindowContext = mDisplayContext.createWindowContext( IMMERSIVE_MODE_CONFIRMATION_WINDOW_TYPE, options); - WindowManager wm = mWindowContext.getSystemService(WindowManager.class); - mViewCaptureAwareWindowManager = new ViewCaptureAwareWindowManager(wm, mLazyViewCapture, - enableViewCaptureTracing()); - return mViewCaptureAwareWindowManager; + mWindowManager = mWindowManagerProvider.getWindowManager(mWindowContext); + return mWindowManager; } /** diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcutListSearch.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcutListSearch.java index ef0660fbcd1c..3d7d08910502 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcutListSearch.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcutListSearch.java @@ -79,6 +79,7 @@ import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.nano.MetricsProto; import com.android.systemui.res.R; import com.android.systemui.statusbar.phone.CentralSurfaces; +import com.android.systemui.utils.windowmanager.WindowManagerProvider; import com.google.android.material.bottomsheet.BottomSheetBehavior; import com.google.android.material.bottomsheet.BottomSheetDialog; @@ -148,43 +149,44 @@ public final class KeyboardShortcutListSearch { private KeyCharacterMap mBackupKeyCharacterMap; @VisibleForTesting - KeyboardShortcutListSearch(Context context, WindowManager windowManager, int deviceId) { + KeyboardShortcutListSearch(Context context, @NonNull WindowManager windowManager, + int deviceId) { this.mContext = new ContextThemeWrapper( context, R.style.KeyboardShortcutHelper); this.mPackageManager = AppGlobals.getPackageManager(); - if (windowManager != null) { - this.mWindowManager = windowManager; - } else { - this.mWindowManager = mContext.getSystemService(WindowManager.class); - } + this.mWindowManager = windowManager; loadResources(this.mContext); createHardcodedShortcuts(deviceId); } - private static KeyboardShortcutListSearch getInstance(Context context, int deviceId) { + private static KeyboardShortcutListSearch getInstance(Context context, int deviceId, + WindowManagerProvider windowManagerProvider) { if (sInstance == null) { - sInstance = new KeyboardShortcutListSearch(context, null, deviceId); + WindowManager windowManager = windowManagerProvider.getWindowManager(context); + sInstance = new KeyboardShortcutListSearch(context, windowManager, deviceId); } return sInstance; } - public static void show(Context context, int deviceId) { + public static void show(Context context, int deviceId, + WindowManagerProvider windowManagerProvider) { MetricsLogger.visible(context, MetricsProto.MetricsEvent.KEYBOARD_SHORTCUTS_HELPER); synchronized (sLock) { if (sInstance != null && !sInstance.mContext.equals(context)) { dismiss(); } - getInstance(context, deviceId).showKeyboardShortcuts(deviceId); + getInstance(context, deviceId, windowManagerProvider).showKeyboardShortcuts(deviceId); } } - public static void toggle(Context context, int deviceId) { + public static void toggle(Context context, int deviceId, + WindowManagerProvider windowManagerProvider) { synchronized (sLock) { if (isShowing()) { dismiss(); } else { - show(context, deviceId); + show(context, deviceId, windowManagerProvider); } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java index 2157d754ce87..bd6006c8faa6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java @@ -70,6 +70,7 @@ import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.nano.MetricsProto; import com.android.settingslib.Utils; import com.android.systemui.res.R; +import com.android.systemui.utils.windowmanager.WindowManagerProvider; import java.util.ArrayList; import java.util.Collections; @@ -141,38 +142,38 @@ public final class KeyboardShortcuts { this.mContext = new ContextThemeWrapper( context, android.R.style.Theme_DeviceDefault_Settings); this.mPackageManager = AppGlobals.getPackageManager(); - if (windowManager != null) { - this.mWindowManager = windowManager; - } else { - this.mWindowManager = mContext.getSystemService(WindowManager.class); - } + this.mWindowManager = windowManager; loadResources(context); } - private static KeyboardShortcuts getInstance(Context context) { + private static KeyboardShortcuts getInstance(Context context, + WindowManagerProvider windowManagerProvider) { if (sInstance == null) { - sInstance = new KeyboardShortcuts(context, null); + WindowManager windowManager = windowManagerProvider.getWindowManager(context); + sInstance = new KeyboardShortcuts(context, windowManager); } return sInstance; } - public static void show(Context context, int deviceId) { + public static void show(Context context, int deviceId, + WindowManagerProvider windowManagerProvider) { MetricsLogger.visible(context, MetricsProto.MetricsEvent.KEYBOARD_SHORTCUTS_HELPER); synchronized (sLock) { if (sInstance != null && !sInstance.mContext.equals(context)) { dismiss(); } - getInstance(context).showKeyboardShortcuts(deviceId); + getInstance(context, windowManagerProvider).showKeyboardShortcuts(deviceId); } } - public static void toggle(Context context, int deviceId) { + public static void toggle(Context context, int deviceId, + WindowManagerProvider windowManagerProvider) { synchronized (sLock) { if (isShowing()) { dismiss(); } else { - show(context, deviceId); + show(context, deviceId, windowManagerProvider); } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcutsReceiver.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcutsReceiver.java index 815f1fcfdec6..54c84aa139cc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcutsReceiver.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcutsReceiver.java @@ -24,6 +24,7 @@ import android.content.Intent; import com.android.systemui.flags.FeatureFlags; import com.android.systemui.flags.Flags; import com.android.systemui.shared.recents.utilities.Utilities; +import com.android.systemui.utils.windowmanager.WindowManagerProvider; import javax.inject.Inject; @@ -31,10 +32,13 @@ import javax.inject.Inject; public class KeyboardShortcutsReceiver extends BroadcastReceiver { private final FeatureFlags mFeatureFlags; + private final WindowManagerProvider mWindowManagerProvider; @Inject - public KeyboardShortcutsReceiver(FeatureFlags featureFlags) { + public KeyboardShortcutsReceiver(FeatureFlags featureFlags, + WindowManagerProvider windowManagerProvider) { mFeatureFlags = featureFlags; + mWindowManagerProvider = windowManagerProvider; } @Override @@ -44,13 +48,14 @@ public class KeyboardShortcutsReceiver extends BroadcastReceiver { } if (isTabletLayoutFlagEnabled() && Utilities.isLargeScreen(context)) { if (Intent.ACTION_SHOW_KEYBOARD_SHORTCUTS.equals(intent.getAction())) { - KeyboardShortcutListSearch.show(context, -1 /* deviceId unknown */); + KeyboardShortcutListSearch.show(context, -1 /* deviceId unknown */, + mWindowManagerProvider); } else if (Intent.ACTION_DISMISS_KEYBOARD_SHORTCUTS.equals(intent.getAction())) { KeyboardShortcutListSearch.dismiss(); } } else { if (Intent.ACTION_SHOW_KEYBOARD_SHORTCUTS.equals(intent.getAction())) { - KeyboardShortcuts.show(context, -1 /* deviceId unknown */); + KeyboardShortcuts.show(context, -1 /* deviceId unknown */, mWindowManagerProvider); } else if (Intent.ACTION_DISMISS_KEYBOARD_SHORTCUTS.equals(intent.getAction())) { KeyboardShortcuts.dismiss(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/data/repository/PrivacyDotWindowControllerStore.kt b/packages/SystemUI/src/com/android/systemui/statusbar/data/repository/PrivacyDotWindowControllerStore.kt index 7fc5e8abe904..587d80fc3848 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/data/repository/PrivacyDotWindowControllerStore.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/data/repository/PrivacyDotWindowControllerStore.kt @@ -18,7 +18,6 @@ package com.android.systemui.statusbar.data.repository import android.view.Display import android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL -import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.systemui.CoreStartable import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Background @@ -48,7 +47,6 @@ constructor( private val windowControllerFactory: PrivacyDotWindowController.Factory, private val displayWindowPropertiesRepository: DisplayWindowPropertiesRepository, private val privacyDotViewControllerStore: PrivacyDotViewControllerStore, - private val viewCaptureAwareWindowManagerFactory: ViewCaptureAwareWindowManager.Factory, ) : PrivacyDotWindowControllerStore, StatusBarPerDisplayStoreImpl<PrivacyDotWindowController>( @@ -72,8 +70,7 @@ constructor( return windowControllerFactory.create( displayId = displayId, privacyDotViewController = privacyDotViewController, - viewCaptureAwareWindowManager = - viewCaptureAwareWindowManagerFactory.create(displayWindowProperties.windowManager), + windowManager = displayWindowProperties.windowManager, inflater = displayWindowProperties.layoutInflater, ) } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/events/PrivacyDotWindowController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/events/PrivacyDotWindowController.kt index e2bcfb752e6c..7999ca9fd3e9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/events/PrivacyDotWindowController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/events/PrivacyDotWindowController.kt @@ -24,10 +24,10 @@ import android.view.DisplayCutout.BOUNDS_POSITION_RIGHT import android.view.DisplayCutout.BOUNDS_POSITION_TOP import android.view.LayoutInflater import android.view.View +import android.view.WindowManager import android.view.WindowManager.InvalidDisplayException import android.view.WindowManager.LayoutParams.WRAP_CONTENT import android.widget.FrameLayout -import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.systemui.ScreenDecorations import com.android.systemui.ScreenDecorationsThread import com.android.systemui.decor.DecorProvider @@ -54,7 +54,7 @@ class PrivacyDotWindowController constructor( @Assisted private val displayId: Int, @Assisted private val privacyDotViewController: PrivacyDotViewController, - @Assisted private val viewCaptureAwareWindowManager: ViewCaptureAwareWindowManager, + @Assisted private val windowManager: WindowManager, @Assisted private val inflater: LayoutInflater, @ScreenDecorationsThread private val uiExecutor: Executor, private val dotFactory: PrivacyDotDecorProviderFactory, @@ -106,7 +106,7 @@ constructor( try { // Wrapping this in a try/catch to avoid crashes when a display is instantly removed // after being added, and initialization hasn't finished yet. - viewCaptureAwareWindowManager.addView(rootView, params) + windowManager.addView(rootView, params) } catch (e: InvalidDisplayException) { Log.e( TAG, @@ -118,7 +118,7 @@ constructor( } fun stop() { - dotViews.forEach { viewCaptureAwareWindowManager.removeView(it) } + dotViews.forEach { windowManager.removeView(it) } } @AssistedFactory @@ -126,7 +126,7 @@ constructor( fun create( displayId: Int, privacyDotViewController: PrivacyDotViewController, - viewCaptureAwareWindowManager: ViewCaptureAwareWindowManager, + windowManager: WindowManager, inflater: LayoutInflater, ): PrivacyDotWindowController } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java index e617254fa288..fe367a3927ed 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -90,7 +90,6 @@ import androidx.annotation.NonNull; import androidx.lifecycle.Lifecycle; import androidx.lifecycle.LifecycleRegistry; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.colorextraction.ColorExtractor; import com.android.internal.logging.MetricsLogger; @@ -233,6 +232,7 @@ import com.android.systemui.util.WallpaperController; import com.android.systemui.util.concurrency.DelayableExecutor; import com.android.systemui.util.concurrency.MessageRouter; import com.android.systemui.util.kotlin.JavaAdapter; +import com.android.systemui.utils.windowmanager.WindowManagerProvider; import com.android.systemui.volume.VolumeComponent; import com.android.systemui.wallet.controller.QuickAccessWalletController; import com.android.wm.shell.bubbles.Bubbles; @@ -597,7 +597,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { private final EmergencyGestureIntentFactory mEmergencyGestureIntentFactory; - private final ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager; private final QuickAccessWalletController mWalletController; /** @@ -713,8 +712,9 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { BrightnessMirrorShowingRepository brightnessMirrorShowingRepository, GlanceableHubContainerController glanceableHubContainerController, EmergencyGestureIntentFactory emergencyGestureIntentFactory, - ViewCaptureAwareWindowManager viewCaptureAwareWindowManager, - QuickAccessWalletController walletController + QuickAccessWalletController walletController, + WindowManager windowManager, + WindowManagerProvider windowManagerProvider ) { mContext = context; mNotificationsController = notificationsController; @@ -852,7 +852,8 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mLightRevealScrim = lightRevealScrim; - mViewCaptureAwareWindowManager = viewCaptureAwareWindowManager; + mWindowManager = windowManager; + mWindowManagerProvider = windowManagerProvider; } private void initBubbles(Bubbles bubbles) { @@ -880,8 +881,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mColorExtractor.addOnColorsChangedListener(mOnColorsChangedListener); - mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); - mDisplay = mContext.getDisplay(); mDisplayId = mDisplay.getDisplayId(); updateDisplaySize(); @@ -1716,7 +1715,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mNotificationShadeWindowController.setRequestTopUi(false, TAG); } }, /* isDozing= */ false, RippleShape.CIRCLE, - sUiEventLogger, mViewCaptureAwareWindowManager).show(animationDelay); + sUiEventLogger, mWindowManager, mWindowManagerProvider).show(animationDelay); } @Override @@ -2876,6 +2875,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { protected WindowManager mWindowManager; protected IWindowManager mWindowManagerService; private final IDreamManager mDreamManager; + private final WindowManagerProvider mWindowManagerProvider; protected Display mDisplay; private int mDisplayId; @@ -2912,9 +2912,9 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { protected void toggleKeyboardShortcuts(int deviceId) { if (shouldUseTabletKeyboardShortcuts()) { - KeyboardShortcutListSearch.toggle(mContext, deviceId); + KeyboardShortcutListSearch.toggle(mContext, deviceId, mWindowManagerProvider); } else { - KeyboardShortcuts.toggle(mContext, deviceId); + KeyboardShortcuts.toggle(mContext, deviceId, mWindowManagerProvider); } } @@ -2928,7 +2928,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { private boolean shouldUseTabletKeyboardShortcuts() { return mFeatureFlags.isEnabled(SHORTCUT_LIST_SEARCH_LAYOUT) - && Utilities.isLargeScreen(mContext); + && Utilities.isLargeScreen(mWindowManager, mContext.getResources()); } private void clearNotificationEffects() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowController.kt index ecfcb29a9944..eae310ed169b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowController.kt @@ -19,7 +19,7 @@ package com.android.systemui.statusbar.window import android.content.Context import android.view.View import android.view.ViewGroup -import com.android.app.viewcapture.ViewCaptureAwareWindowManager +import android.view.WindowManager import com.android.systemui.animation.ActivityTransitionAnimator import com.android.systemui.fragments.FragmentHostManager import com.android.systemui.statusbar.data.repository.StatusBarConfigurationController @@ -84,7 +84,7 @@ interface StatusBarWindowController { fun interface Factory { fun create( context: Context, - viewCaptureAwareWindowManager: ViewCaptureAwareWindowManager, + windowManager: WindowManager, statusBarConfigurationController: StatusBarConfigurationController, contentInsetsProvider: StatusBarContentInsetsProvider, ): StatusBarWindowController diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowControllerImpl.java index 25972ac2bedf..77cd58111b94 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowControllerImpl.java @@ -47,7 +47,6 @@ import android.view.WindowManager; import androidx.annotation.NonNull; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.policy.SystemBarUtils; import com.android.systemui.animation.ActivityTransitionAnimator; import com.android.systemui.animation.DelegateTransitionAnimatorController; @@ -78,7 +77,7 @@ public class StatusBarWindowControllerImpl implements StatusBarWindowController private static final boolean DEBUG = false; private final Context mContext; - private final ViewCaptureAwareWindowManager mWindowManager; + private final WindowManager mWindowManager; private final StatusBarConfigurationController mStatusBarConfigurationController; private final IWindowManager mIWindowManager; private final StatusBarContentInsetsProvider mContentInsetsProvider; @@ -100,7 +99,7 @@ public class StatusBarWindowControllerImpl implements StatusBarWindowController public StatusBarWindowControllerImpl( @Assisted Context context, @InternalWindowViewInflater StatusBarWindowViewInflater statusBarWindowViewInflater, - @Assisted ViewCaptureAwareWindowManager viewCaptureAwareWindowManager, + @Assisted WindowManager windowManager, @Assisted StatusBarConfigurationController statusBarConfigurationController, IWindowManager iWindowManager, @Assisted StatusBarContentInsetsProvider contentInsetsProvider, @@ -108,7 +107,7 @@ public class StatusBarWindowControllerImpl implements StatusBarWindowController Optional<UnfoldTransitionProgressProvider> unfoldTransitionProgressProvider, @Main Executor mainExecutor) { mContext = context; - mWindowManager = viewCaptureAwareWindowManager; + mWindowManager = windowManager; mStatusBarConfigurationController = statusBarConfigurationController; mIWindowManager = iWindowManager; mContentInsetsProvider = contentInsetsProvider; @@ -406,7 +405,7 @@ public class StatusBarWindowControllerImpl implements StatusBarWindowController @Override StatusBarWindowControllerImpl create( @NonNull Context context, - @NonNull ViewCaptureAwareWindowManager viewCaptureAwareWindowManager, + @NonNull WindowManager windowManager, @NonNull StatusBarConfigurationController statusBarConfigurationController, @NonNull StatusBarContentInsetsProvider contentInsetsProvider); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowControllerStore.kt b/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowControllerStore.kt index 39afc38dad11..74c028a8c7ae 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowControllerStore.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowControllerStore.kt @@ -18,7 +18,6 @@ package com.android.systemui.statusbar.window import android.content.Context import android.view.WindowManager -import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.display.data.repository.DisplayRepository @@ -42,7 +41,6 @@ constructor( @Background backgroundApplicationScope: CoroutineScope, private val controllerFactory: StatusBarWindowController.Factory, private val displayWindowPropertiesRepository: DisplayWindowPropertiesRepository, - private val viewCaptureAwareWindowManagerFactory: ViewCaptureAwareWindowManager.Factory, private val statusBarConfigurationControllerStore: StatusBarConfigurationControllerStore, private val statusBarContentInsetsProviderStore: StatusBarContentInsetsProviderStore, displayRepository: DisplayRepository, @@ -67,11 +65,9 @@ constructor( statusBarConfigurationControllerStore.forDisplay(displayId) ?: return null val contentInsetsProvider = statusBarContentInsetsProviderStore.forDisplay(displayId) ?: return null - val viewCaptureAwareWindowManager = - viewCaptureAwareWindowManagerFactory.create(statusBarDisplayContext.windowManager) return controllerFactory.create( statusBarDisplayContext.context, - viewCaptureAwareWindowManager, + statusBarDisplayContext.windowManager, statusBarConfigurationController, contentInsetsProvider, ) @@ -89,7 +85,7 @@ class SingleDisplayStatusBarWindowControllerStore @Inject constructor( context: Context, - viewCaptureAwareWindowManager: ViewCaptureAwareWindowManager, + windowManager: WindowManager, factory: StatusBarWindowControllerImpl.Factory, statusBarConfigurationControllerStore: StatusBarConfigurationControllerStore, statusBarContentInsetsProviderStore: StatusBarContentInsetsProviderStore, @@ -98,7 +94,7 @@ constructor( PerDisplayStore<StatusBarWindowController> by SingleDisplayStore( factory.create( context, - viewCaptureAwareWindowManager, + windowManager, statusBarConfigurationControllerStore.defaultDisplay, statusBarContentInsetsProviderStore.defaultDisplay, ) diff --git a/packages/SystemUI/src/com/android/systemui/temporarydisplay/TemporaryViewDisplayController.kt b/packages/SystemUI/src/com/android/systemui/temporarydisplay/TemporaryViewDisplayController.kt index 635576743462..ea5f422f977d 100644 --- a/packages/SystemUI/src/com/android/systemui/temporarydisplay/TemporaryViewDisplayController.kt +++ b/packages/SystemUI/src/com/android/systemui/temporarydisplay/TemporaryViewDisplayController.kt @@ -32,7 +32,6 @@ import android.view.accessibility.AccessibilityManager.FLAG_CONTENT_ICONS import android.view.accessibility.AccessibilityManager.FLAG_CONTENT_TEXT import androidx.annotation.CallSuper import androidx.annotation.VisibleForTesting -import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.systemui.CoreStartable import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.dump.DumpManager @@ -70,7 +69,7 @@ import java.io.PrintWriter abstract class TemporaryViewDisplayController<T : TemporaryViewInfo, U : TemporaryViewLogger<T>>( internal val context: Context, internal val logger: U, - internal val windowManager: ViewCaptureAwareWindowManager, + internal val windowManager: WindowManager, @Main private val mainExecutor: DelayableExecutor, private val accessibilityManager: AccessibilityManager, private val configurationController: ConfigurationController, diff --git a/packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinator.kt b/packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinator.kt index 9b9cba9186f4..b6f54331b29f 100644 --- a/packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinator.kt +++ b/packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinator.kt @@ -29,6 +29,7 @@ import android.view.View import android.view.View.ACCESSIBILITY_LIVE_REGION_ASSERTIVE import android.view.View.ACCESSIBILITY_LIVE_REGION_NONE import android.view.ViewGroup +import android.view.WindowManager import android.view.accessibility.AccessibilityManager import android.view.accessibility.AccessibilityNodeInfo import android.widget.ImageView @@ -37,7 +38,6 @@ import androidx.annotation.DimenRes import androidx.annotation.IdRes import androidx.annotation.VisibleForTesting import com.android.app.animation.Interpolators -import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.internal.widget.CachingIconView import com.android.systemui.Gefingerpoken import com.android.systemui.classifier.FalsingCollector @@ -81,7 +81,7 @@ open class ChipbarCoordinator constructor( context: Context, logger: ChipbarLogger, - viewCaptureAwareWindowManager: ViewCaptureAwareWindowManager, + windowManager: WindowManager, @Main mainExecutor: DelayableExecutor, accessibilityManager: AccessibilityManager, configurationController: ConfigurationController, @@ -100,7 +100,7 @@ constructor( TemporaryViewDisplayController<ChipbarInfo, ChipbarLogger>( context, logger, - viewCaptureAwareWindowManager, + windowManager, mainExecutor, accessibilityManager, configurationController, diff --git a/packages/SystemUI/src/com/android/systemui/topwindoweffects/TopLevelWindowEffects.kt b/packages/SystemUI/src/com/android/systemui/topwindoweffects/TopLevelWindowEffects.kt index c11e4c507914..00c6ffd861da 100644 --- a/packages/SystemUI/src/com/android/systemui/topwindoweffects/TopLevelWindowEffects.kt +++ b/packages/SystemUI/src/com/android/systemui/topwindoweffects/TopLevelWindowEffects.kt @@ -21,7 +21,6 @@ import android.graphics.PixelFormat import android.view.Gravity import android.view.WindowInsets import android.view.WindowManager -import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.systemui.CoreStartable import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application @@ -38,7 +37,7 @@ import javax.inject.Inject class TopLevelWindowEffects @Inject constructor( @Application private val context: Context, @Application private val applicationScope: CoroutineScope, - private val windowManager: ViewCaptureAwareWindowManager, + private val windowManager: WindowManager, private val squeezeEffectInteractor: SqueezeEffectInteractor, private val keyEventInteractor: KeyEventInteractor, private val viewModelFactory: SqueezeEffectViewModel.Factory diff --git a/packages/SystemUI/src/com/android/systemui/util/ConvenienceExtensions.kt b/packages/SystemUI/src/com/android/systemui/util/ConvenienceExtensions.kt index 70fd5ab767d0..f1a556353273 100644 --- a/packages/SystemUI/src/com/android/systemui/util/ConvenienceExtensions.kt +++ b/packages/SystemUI/src/com/android/systemui/util/ConvenienceExtensions.kt @@ -20,7 +20,6 @@ import android.graphics.Rect import android.util.IndentingPrintWriter import android.view.View import android.view.ViewGroup -import dagger.Lazy import java.io.PrintWriter /** [Sequence] that yields all of the direct children of this [ViewGroup] */ @@ -56,11 +55,6 @@ val View.boundsOnScreen: Rect return bounds } -/** Extension method to convert [dagger.Lazy] to [kotlin.Lazy] for object of any class [T]. */ -fun <T> Lazy<T>.toKotlinLazy(): kotlin.Lazy<T> { - return lazy { this.get() } -} - /** * Returns whether this [Collection] contains exactly all [elements]. * diff --git a/packages/SystemUI/src/com/android/systemui/util/display/DisplayHelper.java b/packages/SystemUI/src/com/android/systemui/util/display/DisplayHelper.java index 8acd6535e751..757b2d973312 100644 --- a/packages/SystemUI/src/com/android/systemui/util/display/DisplayHelper.java +++ b/packages/SystemUI/src/com/android/systemui/util/display/DisplayHelper.java @@ -21,6 +21,8 @@ import android.hardware.display.DisplayManager; import android.view.Display; import android.view.WindowManager; +import com.android.systemui.utils.windowmanager.WindowManagerProvider; + import javax.inject.Inject; /** @@ -29,14 +31,17 @@ import javax.inject.Inject; public class DisplayHelper { private final Context mContext; private final DisplayManager mDisplayManager; + private final WindowManagerProvider mWindowManagerProvider; /** * Default constructor. */ @Inject - public DisplayHelper(Context context, DisplayManager displayManager) { + public DisplayHelper(Context context, DisplayManager displayManager, + WindowManagerProvider windowManagerProvider) { mContext = context; mDisplayManager = displayManager; + mWindowManagerProvider = windowManagerProvider; } @@ -45,9 +50,8 @@ public class DisplayHelper { */ public Rect getMaxBounds(int displayId, int windowContextType) { final Display display = mDisplayManager.getDisplay(displayId); - WindowManager windowManager = mContext.createDisplayContext(display) - .createWindowContext(windowContextType, null) - .getSystemService(WindowManager.class); + WindowManager windowManager = mWindowManagerProvider.getWindowManager(mContext + .createDisplayContext(display).createWindowContext(windowContextType, null)); return windowManager.getMaximumWindowMetrics().getBounds(); } } diff --git a/packages/SystemUI/src/com/android/systemui/wallpapers/ImageWallpaper.java b/packages/SystemUI/src/com/android/systemui/wallpapers/ImageWallpaper.java index b1c6455a6e57..107f670eae8d 100644 --- a/packages/SystemUI/src/com/android/systemui/wallpapers/ImageWallpaper.java +++ b/packages/SystemUI/src/com/android/systemui/wallpapers/ImageWallpaper.java @@ -42,7 +42,6 @@ import android.service.wallpaper.WallpaperService; import android.util.Log; import android.view.Surface; import android.view.SurfaceHolder; -import android.view.WindowManager; import androidx.annotation.NonNull; @@ -50,6 +49,7 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.systemui.dagger.qualifiers.LongRunning; import com.android.systemui.settings.UserTracker; import com.android.systemui.util.concurrency.DelayableExecutor; +import com.android.systemui.utils.windowmanager.WindowManagerProvider; import java.io.FileDescriptor; import java.io.PrintWriter; @@ -71,6 +71,7 @@ public class ImageWallpaper extends WallpaperService { private boolean mPagesComputed = false; private final UserTracker mUserTracker; + private final WindowManagerProvider mWindowManagerProvider; // used to handle WallpaperService messages (e.g. DO_ATTACH, MSG_UPDATE_SURFACE) // and to receive WallpaperService callbacks (e.g. onCreateEngine, onSurfaceRedrawNeeded) @@ -84,10 +85,12 @@ public class ImageWallpaper extends WallpaperService { private static final int DELAY_UNLOAD_BITMAP = 2000; @Inject - public ImageWallpaper(@LongRunning DelayableExecutor longExecutor, UserTracker userTracker) { + public ImageWallpaper(@LongRunning DelayableExecutor longExecutor, UserTracker userTracker, + WindowManagerProvider windowManagerProvider) { super(); mLongExecutor = longExecutor; mUserTracker = userTracker; + mWindowManagerProvider = windowManagerProvider; } @Override @@ -552,8 +555,7 @@ public class ImageWallpaper extends WallpaperService { } private void getDisplaySizeAndUpdateColorExtractor() { - Rect window = getDisplayContext() - .getSystemService(WindowManager.class) + Rect window = mWindowManagerProvider.getWindowManager(getDisplayContext()) .getCurrentWindowMetrics() .getBounds(); mWallpaperLocalColorExtractor.setDisplayDimensions(window.width(), window.height()); diff --git a/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java b/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java index 0769ada805a2..645e306eed07 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java @@ -80,8 +80,6 @@ import androidx.annotation.Nullable; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; -import com.android.app.viewcapture.ViewCapture; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.systemui.biometrics.AuthController; import com.android.systemui.biometrics.data.repository.FakeFacePropertyRepository; @@ -104,7 +102,6 @@ import com.android.systemui.settings.FakeDisplayTracker; import com.android.systemui.settings.UserTracker; import com.android.systemui.statusbar.commandline.CommandRegistry; import com.android.systemui.statusbar.events.PrivacyDotViewController; -import com.android.systemui.util.concurrency.DelayableExecutor; import com.android.systemui.util.concurrency.FakeExecutor; import com.android.systemui.util.concurrency.FakeThreadFactory; import com.android.systemui.util.kotlin.JavaAdapter; @@ -112,8 +109,6 @@ import com.android.systemui.util.settings.FakeSettings; import com.android.systemui.util.settings.SecureSettings; import com.android.systemui.util.time.FakeSystemClock; -import kotlin.Lazy; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -132,7 +127,6 @@ public class ScreenDecorationsTest extends SysuiTestCase { private ScreenDecorations mScreenDecorations; private WindowManager mWindowManager; - private ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager; private DisplayManager mDisplayManager; private SecureSettings mSecureSettings; private FakeExecutor mExecutor; @@ -179,8 +173,6 @@ public class ScreenDecorationsTest extends SysuiTestCase { private CutoutDecorProviderFactory mCutoutFactory; @Mock private JavaAdapter mJavaAdapter; - @Mock - private Lazy<ViewCapture> mLazyViewCapture; private FakeFacePropertyRepository mFakeFacePropertyRepository = new FakeFacePropertyRepository(); @@ -254,14 +246,12 @@ public class ScreenDecorationsTest extends SysuiTestCase { new ScreenDecorationsLogger(logcatLogBuffer("TestLogBuffer")), mFakeFacePropertyRepository)); - mViewCaptureAwareWindowManager = new ViewCaptureAwareWindowManager(mWindowManager, - mLazyViewCapture, false); mScreenDecorations = spy(new ScreenDecorations(mContext, mSecureSettings, mCommandRegistry, mUserTracker, mDisplayTracker, mDotViewController, mPrivacyDotDecorProviderFactory, mFaceScanningProviderFactory, new ScreenDecorationsLogger(logcatLogBuffer("TestLogBuffer")), mFakeFacePropertyRepository, mJavaAdapter, mCameraProtectionLoader, - mViewCaptureAwareWindowManager, mMainHandler, mExecutor) { + mWindowManager, mMainHandler, mExecutor) { @Override public void start() { super.start(); @@ -1276,7 +1266,7 @@ public class ScreenDecorationsTest extends SysuiTestCase { mPrivacyDotDecorProviderFactory, mFaceScanningProviderFactory, new ScreenDecorationsLogger(logcatLogBuffer("TestLogBuffer")), mFakeFacePropertyRepository, mJavaAdapter, mCameraProtectionLoader, - mViewCaptureAwareWindowManager, mMainHandler, mExecutor); + mWindowManager, mMainHandler, mExecutor); screenDecorations.start(); when(mContext.getDisplay()).thenReturn(mDisplay); when(mDisplay.getDisplayInfo(any())).thenAnswer(new Answer<Boolean>() { diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/IMagnificationConnectionTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/IMagnificationConnectionTest.java index 6d75c4ca3a38..d3d4e24001cb 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/IMagnificationConnectionTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/IMagnificationConnectionTest.java @@ -43,13 +43,13 @@ import android.view.accessibility.IRemoteMagnificationAnimationCallback; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.systemui.SysuiTestCase; import com.android.systemui.model.SysUiState; import com.android.systemui.recents.LauncherProxyService; import com.android.systemui.settings.FakeDisplayTracker; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.util.settings.SecureSettings; +import com.android.systemui.utils.windowmanager.WindowManagerProvider; import org.junit.Before; import org.junit.Test; @@ -94,7 +94,7 @@ public class IMagnificationConnectionTest extends SysuiTestCase { @Mock private IWindowManager mIWindowManager; @Mock - private ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager; + private WindowManagerProvider mWindowManagerProvider; private IMagnificationConnection mIMagnificationConnection; private MagnificationImpl mMagnification; @@ -116,8 +116,7 @@ public class IMagnificationConnectionTest extends SysuiTestCase { mTestableLooper.getLooper(), mContext.getMainExecutor(), mCommandQueue, mModeSwitchesController, mSysUiState, mLauncherProxyService, mSecureSettings, mDisplayTracker, getContext().getSystemService(DisplayManager.class), - mA11yLogger, mIWindowManager, mAccessibilityManager, - mViewCaptureAwareWindowManager); + mA11yLogger, mIWindowManager, mAccessibilityManager, mWindowManagerProvider); mMagnification.mWindowMagnificationControllerSupplier = new FakeWindowMagnificationControllerSupplier( mContext.getSystemService(DisplayManager.class)); diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/MagnificationTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/MagnificationTest.java index 8bfd2545ff2b..ae96e8fe7b8b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/MagnificationTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/MagnificationTest.java @@ -50,13 +50,13 @@ import android.view.accessibility.IMagnificationConnectionCallback; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.systemui.SysuiTestCase; import com.android.systemui.model.SysUiState; import com.android.systemui.recents.LauncherProxyService; import com.android.systemui.settings.FakeDisplayTracker; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.util.settings.SecureSettings; +import com.android.systemui.utils.windowmanager.WindowManagerProvider; import org.junit.Before; import org.junit.Test; @@ -98,7 +98,7 @@ public class MagnificationTest extends SysuiTestCase { @Mock private IWindowManager mIWindowManager; @Mock - private ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager; + private WindowManagerProvider mWindowManagerProvider; @Before public void setUp() throws Exception { @@ -132,8 +132,7 @@ public class MagnificationTest extends SysuiTestCase { mCommandQueue, mModeSwitchesController, mSysUiState, mLauncherProxyService, mSecureSettings, mDisplayTracker, getContext().getSystemService(DisplayManager.class), mA11yLogger, mIWindowManager, - getContext().getSystemService(AccessibilityManager.class), - mViewCaptureAwareWindowManager); + getContext().getSystemService(AccessibilityManager.class), mWindowManagerProvider); mMagnification.mWindowMagnificationControllerSupplier = new FakeControllerSupplier( mContext.getSystemService(DisplayManager.class), mWindowMagnificationController); mMagnification.mMagnificationSettingsSupplier = new FakeSettingsSupplier( diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationAnimationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationAnimationControllerTest.java index a0f5b2214f80..ac0378b093c5 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationAnimationControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationAnimationControllerTest.java @@ -51,8 +51,6 @@ import android.view.animation.AccelerateInterpolator; import android.window.InputTransferToken; import androidx.test.filters.LargeTest; - -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.graphics.SfVsyncFrameCallbackProvider; import com.android.systemui.Flags; import com.android.systemui.SysuiTestCase; @@ -112,8 +110,6 @@ public class WindowMagnificationAnimationControllerTest extends SysuiTestCase { SysUiState mSysUiState; @Mock SecureSettings mSecureSettings; - @Mock - ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager; private SpyWindowMagnificationController mController; private WindowMagnificationController mSpyController; private WindowMagnificationAnimationController mWindowMagnificationAnimationController; @@ -167,7 +163,7 @@ public class WindowMagnificationAnimationControllerTest extends SysuiTestCase { mSecureSettings, scvhSupplier, mSfVsyncFrameProvider, - mViewCaptureAwareWindowManager); + mWindowManager); mSpyController = mController.getSpyController(); } @@ -1023,7 +1019,7 @@ public class WindowMagnificationAnimationControllerTest extends SysuiTestCase { SecureSettings secureSettings, Supplier<SurfaceControlViewHost> scvhSupplier, SfVsyncFrameCallbackProvider sfVsyncFrameProvider, - ViewCaptureAwareWindowManager viewCaptureAwareWindowManager) { + WindowManager windowManager) { super( context, handler, @@ -1033,7 +1029,8 @@ public class WindowMagnificationAnimationControllerTest extends SysuiTestCase { callback, sysUiState, secureSettings, - scvhSupplier); + scvhSupplier, + windowManager); mSpyController = Mockito.mock(WindowMagnificationController.class); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java index 5b32b922d377..c8e0b14152fd 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java @@ -238,7 +238,8 @@ public class WindowMagnificationControllerTest extends SysuiTestCase { mWindowMagnifierCallback, mSysUiState, mSecureSettings, - scvhSupplier); + scvhSupplier, + mWindowManager); verify(mMirrorWindowControl).setWindowDelegate( any(MirrorWindowControl.MirrorWindowDelegate.class)); diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationSettingsTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationSettingsTest.java index 45b9f4ad2322..dfc3ff2791b2 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationSettingsTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationSettingsTest.java @@ -65,8 +65,6 @@ import androidx.test.InstrumentationRegistry; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; -import com.android.app.viewcapture.ViewCapture; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.graphics.SfVsyncFrameCallbackProvider; import com.android.systemui.SysuiTestCase; import com.android.systemui.common.ui.view.SeekBarWithIconButtonsView; @@ -74,8 +72,6 @@ import com.android.systemui.common.ui.view.SeekBarWithIconButtonsView.OnSeekBarW import com.android.systemui.res.R; import com.android.systemui.util.settings.SecureSettings; -import kotlin.Lazy; - import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -104,8 +100,6 @@ public class WindowMagnificationSettingsTest extends SysuiTestCase { private SecureSettings mSecureSettings; @Mock private WindowMagnificationSettingsCallback mWindowMagnificationSettingsCallback; - @Mock - private Lazy<ViewCapture> mLazyViewCapture; private TestableWindowManager mWindowManager; private WindowMagnificationSettings mWindowMagnificationSettings; private MotionEventHelper mMotionEventHelper = new MotionEventHelper(); @@ -123,6 +117,7 @@ public class WindowMagnificationSettingsTest extends SysuiTestCase { final WindowManager wm = mContext.getSystemService(WindowManager.class); mWindowManager = spy(new TestableWindowManager(wm)); mContext.addMockSystemService(Context.WINDOW_SERVICE, mWindowManager); + mContext.addMockSystemService(Context.ACCESSIBILITY_SERVICE, mAccessibilityManager); when(mSecureSettings.getIntForUser(anyString(), anyInt(), anyInt())).then( @@ -130,11 +125,9 @@ public class WindowMagnificationSettingsTest extends SysuiTestCase { when(mSecureSettings.getFloatForUser(anyString(), anyFloat(), anyInt())).then( returnsSecondArg()); - ViewCaptureAwareWindowManager vwm = new ViewCaptureAwareWindowManager(mWindowManager, - mLazyViewCapture, /* isViewCaptureEnabled= */ false); mWindowMagnificationSettings = new WindowMagnificationSettings(mContext, mWindowMagnificationSettingsCallback, mSfVsyncFrameProvider, - mSecureSettings, vwm); + mSecureSettings, mWindowManager); mSettingView = mWindowMagnificationSettings.getSettingView(); mZoomSeekbar = mSettingView.findViewById(R.id.magnifier_zoom_slider); diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuControllerTest.java index bc9d4c7fa0e6..b81cbe48b4ff 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuControllerTest.java @@ -38,8 +38,6 @@ import android.view.accessibility.AccessibilityManager; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; -import com.android.app.viewcapture.ViewCapture; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; import com.android.settingslib.bluetooth.HearingAidDeviceManager; @@ -51,8 +49,6 @@ import com.android.systemui.navigationbar.NavigationModeController; import com.android.systemui.settings.FakeDisplayTracker; import com.android.systemui.util.settings.SecureSettings; -import kotlin.Lazy; - import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -78,7 +74,6 @@ public class AccessibilityFloatingMenuControllerTest extends SysuiTestCase { private Context mContextWrapper; private WindowManager mWindowManager; - private ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager; private AccessibilityManager mAccessibilityManager; private KeyguardUpdateMonitor mKeyguardUpdateMonitor; private AccessibilityFloatingMenuController mController; @@ -93,8 +88,6 @@ public class AccessibilityFloatingMenuControllerTest extends SysuiTestCase { @Mock private SecureSettings mSecureSettings; @Mock - private Lazy<ViewCapture> mLazyViewCapture; - @Mock private NavigationModeController mNavigationModeController; @Mock private HearingAidDeviceManager mHearingAidDeviceManager; @@ -110,8 +103,6 @@ public class AccessibilityFloatingMenuControllerTest extends SysuiTestCase { }; mWindowManager = mContext.getSystemService(WindowManager.class); - mViewCaptureAwareWindowManager = new ViewCaptureAwareWindowManager(mWindowManager, - mLazyViewCapture, /* isViewCaptureEnabled= */ false); mAccessibilityManager = mContext.getSystemService(AccessibilityManager.class); mTestableLooper = TestableLooper.get(this); @@ -172,8 +163,8 @@ public class AccessibilityFloatingMenuControllerTest extends SysuiTestCase { enableAccessibilityFloatingMenuConfig(); mController = setUpController(); mController.mFloatingMenu = new MenuViewLayerController(mContextWrapper, mWindowManager, - mViewCaptureAwareWindowManager, mAccessibilityManager, mSecureSettings, - mNavigationModeController, mHearingAidDeviceManager); + mAccessibilityManager, mSecureSettings, mNavigationModeController, + mHearingAidDeviceManager); captureKeyguardUpdateMonitorCallback(); mKeyguardCallback.onUserUnlocked(); @@ -200,8 +191,8 @@ public class AccessibilityFloatingMenuControllerTest extends SysuiTestCase { enableAccessibilityFloatingMenuConfig(); mController = setUpController(); mController.mFloatingMenu = new MenuViewLayerController(mContextWrapper, mWindowManager, - mViewCaptureAwareWindowManager, mAccessibilityManager, mSecureSettings, - mNavigationModeController, mHearingAidDeviceManager); + mAccessibilityManager, mSecureSettings, mNavigationModeController, + mHearingAidDeviceManager); captureKeyguardUpdateMonitorCallback(); mKeyguardCallback.onUserSwitching(fakeUserId); @@ -215,8 +206,8 @@ public class AccessibilityFloatingMenuControllerTest extends SysuiTestCase { enableAccessibilityFloatingMenuConfig(); mController = setUpController(); mController.mFloatingMenu = new MenuViewLayerController(mContextWrapper, mWindowManager, - mViewCaptureAwareWindowManager, mAccessibilityManager, mSecureSettings, - mNavigationModeController, mHearingAidDeviceManager); + mAccessibilityManager, mSecureSettings, mNavigationModeController, + mHearingAidDeviceManager); captureKeyguardUpdateMonitorCallback(); mKeyguardCallback.onUserUnlocked(); mKeyguardCallback.onKeyguardVisibilityChanged(true); @@ -362,18 +353,15 @@ public class AccessibilityFloatingMenuControllerTest extends SysuiTestCase { private AccessibilityFloatingMenuController setUpController() { final WindowManager windowManager = mContext.getSystemService(WindowManager.class); - final ViewCaptureAwareWindowManager viewCaptureAwareWindowManager = - new ViewCaptureAwareWindowManager(windowManager, mLazyViewCapture, - /* isViewCaptureEnabled= */ false); final DisplayManager displayManager = mContext.getSystemService(DisplayManager.class); final FakeDisplayTracker displayTracker = new FakeDisplayTracker(mContext); mKeyguardUpdateMonitor = Dependency.get(KeyguardUpdateMonitor.class); final AccessibilityFloatingMenuController controller = new AccessibilityFloatingMenuController(mContextWrapper, windowManager, - viewCaptureAwareWindowManager, displayManager, mAccessibilityManager, - mTargetsObserver, mModeObserver, mHearingAidDeviceManager, - mKeyguardUpdateMonitor, mSecureSettings, displayTracker, - mNavigationModeController, new Handler(mTestableLooper.getLooper())); + displayManager, mAccessibilityManager, mTargetsObserver, mModeObserver, + mHearingAidDeviceManager, mKeyguardUpdateMonitor, mSecureSettings, + displayTracker, mNavigationModeController, + new Handler(mTestableLooper.getLooper())); controller.init(); return controller; diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerOverlayTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerOverlayTest.kt index a1d038ad8554..a9e6a3ebdb30 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerOverlayTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerOverlayTest.kt @@ -28,8 +28,6 @@ import android.view.WindowManager import android.view.accessibility.AccessibilityManager import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest -import com.android.app.viewcapture.ViewCapture -import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.keyguard.KeyguardUpdateMonitor import com.android.systemui.SysuiTestCase import com.android.systemui.animation.ActivityTransitionAnimator @@ -62,7 +60,6 @@ import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.testKosmos import com.android.systemui.user.domain.interactor.SelectedUserInteractor import com.google.common.truth.Truth.assertThat -import dagger.Lazy import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest @@ -98,7 +95,6 @@ class UdfpsControllerOverlayTest : SysuiTestCase() { @Mock private lateinit var inflater: LayoutInflater @Mock private lateinit var windowManager: WindowManager - @Mock private lateinit var lazyViewCapture: kotlin.Lazy<ViewCapture> @Mock private lateinit var accessibilityManager: AccessibilityManager @Mock private lateinit var statusBarStateController: StatusBarStateController @Mock private lateinit var statusBarKeyguardViewManager: StatusBarKeyguardViewManager @@ -160,11 +156,7 @@ class UdfpsControllerOverlayTest : SysuiTestCase() { UdfpsControllerOverlay( context, inflater, - ViewCaptureAwareWindowManager( - windowManager, - lazyViewCapture, - isViewCaptureEnabled = false, - ), + windowManager, accessibilityManager, statusBarStateController, statusBarKeyguardViewManager, diff --git a/packages/SystemUI/tests/src/com/android/systemui/charging/WiredChargingRippleControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/charging/WiredChargingRippleControllerTest.kt index 57b397cfca7e..034bab855faf 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/charging/WiredChargingRippleControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/charging/WiredChargingRippleControllerTest.kt @@ -23,13 +23,11 @@ import android.view.WindowManager import android.view.WindowMetrics import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest -import com.android.app.viewcapture.ViewCapture -import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.internal.logging.UiEventLogger +import com.android.systemui.res.R import com.android.systemui.SysuiTestCase import com.android.systemui.flags.FeatureFlags import com.android.systemui.flags.Flags -import com.android.systemui.res.R import com.android.systemui.statusbar.commandline.CommandRegistry import com.android.systemui.statusbar.policy.BatteryController import com.android.systemui.statusbar.policy.ConfigurationController @@ -42,12 +40,12 @@ import org.junit.runner.RunWith import org.mockito.ArgumentCaptor import org.mockito.ArgumentMatchers import org.mockito.Mock +import org.mockito.Mockito.`when` import org.mockito.Mockito.any import org.mockito.Mockito.eq import org.mockito.Mockito.never import org.mockito.Mockito.reset import org.mockito.Mockito.verify -import org.mockito.Mockito.`when` import org.mockito.MockitoAnnotations @SmallTest @@ -62,7 +60,6 @@ class WiredChargingRippleControllerTest : SysuiTestCase() { @Mock private lateinit var windowManager: WindowManager @Mock private lateinit var uiEventLogger: UiEventLogger @Mock private lateinit var windowMetrics: WindowMetrics - @Mock private lateinit var lazyViewCapture: Lazy<ViewCapture> private val systemClock = FakeSystemClock() @Before @@ -71,9 +68,7 @@ class WiredChargingRippleControllerTest : SysuiTestCase() { `when`(featureFlags.isEnabled(Flags.CHARGING_RIPPLE)).thenReturn(true) controller = WiredChargingRippleController( commandRegistry, batteryController, configurationController, - featureFlags, context, windowManager, - ViewCaptureAwareWindowManager(windowManager, - lazyViewCapture, isViewCaptureEnabled = false), systemClock, uiEventLogger) + featureFlags, context, windowManager, systemClock, uiEventLogger) rippleView.setupShader() controller.rippleView = rippleView // Replace the real ripple view with a mock instance controller.registerCallbacks() diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java index 9b314f25e02b..41fdaa74e57b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java @@ -73,10 +73,10 @@ import android.view.IRemoteAnimationFinishedCallback; import android.view.RemoteAnimationTarget; import android.view.View; import android.view.ViewRootImpl; +import android.view.WindowManager; import androidx.test.filters.SmallTest; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.foldables.FoldGracePeriodProvider; import com.android.internal.logging.InstanceId; import com.android.internal.logging.UiEventLogger; @@ -175,7 +175,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { private @Mock BroadcastDispatcher mBroadcastDispatcher; private @Mock DismissCallbackRegistry mDismissCallbackRegistry; private @Mock DumpManager mDumpManager; - private @Mock ViewCaptureAwareWindowManager mWindowManager; + private @Mock WindowManager mWindowManager; private @Mock IActivityManager mActivityManager; private @Mock ConfigurationController mConfigurationController; private @Mock PowerManager mPowerManager; diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/receiver/FakeMediaTttChipControllerReceiver.kt b/packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/receiver/FakeMediaTttChipControllerReceiver.kt index c7beb158c2de..add87686bc9f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/receiver/FakeMediaTttChipControllerReceiver.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/receiver/FakeMediaTttChipControllerReceiver.kt @@ -20,8 +20,8 @@ import android.content.Context import android.os.Handler import android.os.PowerManager import android.view.ViewGroup +import android.view.WindowManager import android.view.accessibility.AccessibilityManager -import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.systemui.dump.DumpManager import com.android.systemui.statusbar.CommandQueue import com.android.systemui.statusbar.policy.ConfigurationController @@ -35,7 +35,7 @@ class FakeMediaTttChipControllerReceiver( commandQueue: CommandQueue, context: Context, logger: MediaTttReceiverLogger, - viewCaptureAwareWindowManager: ViewCaptureAwareWindowManager, + windowManager: WindowManager, mainExecutor: DelayableExecutor, accessibilityManager: AccessibilityManager, configurationController: ConfigurationController, @@ -53,7 +53,7 @@ class FakeMediaTttChipControllerReceiver( commandQueue, context, logger, - viewCaptureAwareWindowManager, + windowManager, mainExecutor, accessibilityManager, configurationController, diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/receiver/MediaTttChipControllerReceiverTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/receiver/MediaTttChipControllerReceiverTest.kt index 378dd452d030..1aa6ac67ec27 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/receiver/MediaTttChipControllerReceiverTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/receiver/MediaTttChipControllerReceiverTest.kt @@ -31,8 +31,6 @@ import android.view.accessibility.AccessibilityManager import android.widget.ImageView import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest -import com.android.app.viewcapture.ViewCapture -import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.internal.logging.InstanceId import com.android.internal.logging.testing.UiEventLoggerFake import com.android.systemui.SysuiTestCase @@ -75,8 +73,6 @@ class MediaTttChipControllerReceiverTest : SysuiTestCase() { @Mock private lateinit var windowManager: WindowManager @Mock private lateinit var commandQueue: CommandQueue @Mock private lateinit var rippleController: MediaTttReceiverRippleController - @Mock private lateinit var lazyViewCapture: Lazy<ViewCapture> - private lateinit var viewCaptureAwareWindowManager: ViewCaptureAwareWindowManager private lateinit var commandQueueCallback: CommandQueue.Callbacks private lateinit var fakeAppIconDrawable: Drawable private lateinit var uiEventLoggerFake: UiEventLoggerFake @@ -114,18 +110,12 @@ class MediaTttChipControllerReceiverTest : SysuiTestCase() { fakeWakeLockBuilder = WakeLockFake.Builder(context) fakeWakeLockBuilder.setWakeLock(fakeWakeLock) - viewCaptureAwareWindowManager = - ViewCaptureAwareWindowManager( - windowManager, - lazyViewCapture, - isViewCaptureEnabled = false, - ) controllerReceiver = FakeMediaTttChipControllerReceiver( commandQueue, context, logger, - viewCaptureAwareWindowManager, + windowManager, fakeExecutor, accessibilityManager, configurationController, diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/sender/MediaTttSenderCoordinatorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/sender/MediaTttSenderCoordinatorTest.kt index c90ac5993c31..18de32e80da6 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/sender/MediaTttSenderCoordinatorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/sender/MediaTttSenderCoordinatorTest.kt @@ -34,7 +34,6 @@ import android.widget.TextView import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.app.viewcapture.ViewCapture -import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.internal.logging.testing.UiEventLoggerFake import com.android.internal.statusbar.IUndoMediaTransferCallback import com.android.systemui.SysuiTestCase @@ -100,7 +99,6 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() { @Mock private lateinit var windowManager: WindowManager @Mock private lateinit var vibratorHelper: VibratorHelper @Mock private lateinit var swipeHandler: SwipeChipbarAwayGestureHandler - @Mock private lateinit var lazyViewCapture: Lazy<ViewCapture> private lateinit var fakeWakeLockBuilder: WakeLockFake.Builder private lateinit var fakeWakeLock: WakeLockFake private lateinit var chipbarCoordinator: ChipbarCoordinator @@ -145,11 +143,7 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() { ChipbarCoordinator( context, chipbarLogger, - ViewCaptureAwareWindowManager( - windowManager, - lazyViewCapture, - isViewCaptureEnabled = false, - ), + windowManager, fakeExecutor, accessibilityManager, configurationController, @@ -1476,7 +1470,7 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() { private fun ViewGroup.getUndoButton(): View = this.requireViewById(R.id.end_button) private fun ChipStateSender.getExpectedStateText( - otherDeviceName: String = OTHER_DEVICE_NAME + otherDeviceName: String = OTHER_DEVICE_NAME, ): String? { return this.getChipTextString(context, otherDeviceName).loadText(context) } @@ -1487,7 +1481,7 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() { commandQueueCallback.updateMediaTapToTransferSenderDisplay( StatusBarManager.MEDIA_TRANSFER_SENDER_STATE_TRANSFER_TO_RECEIVER_TRIGGERED, routeInfo, - null, + null ) } @@ -1497,7 +1491,7 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() { commandQueueCallback.updateMediaTapToTransferSenderDisplay( StatusBarManager.MEDIA_TRANSFER_SENDER_STATE_TRANSFER_TO_THIS_DEVICE_TRIGGERED, routeInfo, - null, + null ) } diff --git a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/gestural/BackPanelControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/gestural/BackPanelControllerTest.kt index b4db6da2000a..b169cc12f08a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/gestural/BackPanelControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/gestural/BackPanelControllerTest.kt @@ -27,7 +27,6 @@ import android.view.ViewConfiguration import android.view.WindowManager import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest -import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.internal.jank.Cuj import com.android.internal.util.LatencyTracker import com.android.systemui.SysuiTestCase @@ -64,7 +63,7 @@ class BackPanelControllerTest : SysuiTestCase() { private var triggerThreshold: Float = 0.0f private val touchSlop = ViewConfiguration.get(context).scaledEdgeSlop @Mock private lateinit var vibratorHelper: VibratorHelper - @Mock private lateinit var viewCaptureAwareWindowManager: ViewCaptureAwareWindowManager + @Mock private lateinit var windowManager: WindowManager @Mock private lateinit var configurationController: ConfigurationController @Mock private lateinit var latencyTracker: LatencyTracker private val interactionJankMonitor by lazy { kosmos.interactionJankMonitor } @@ -79,7 +78,7 @@ class BackPanelControllerTest : SysuiTestCase() { mBackPanelController = BackPanelController( context, - viewCaptureAwareWindowManager, + windowManager, ViewConfiguration.get(context), Handler.createAsync(testableLooper.looper), systemClock, diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDetailsContentControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDetailsContentControllerTest.java index e4a4953063bb..e949c8a10c9c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDetailsContentControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDetailsContentControllerTest.java @@ -62,7 +62,6 @@ import android.view.WindowManager; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.logging.UiEventLogger; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.settingslib.wifi.WifiUtils; @@ -162,7 +161,7 @@ public class InternetDetailsContentControllerTest extends SysuiTestCase { @Mock InternetDetailsContentController.InternetDialogCallback mInternetDialogCallback; @Mock - private ViewCaptureAwareWindowManager mWindowManager; + private WindowManager mWindowManager; @Mock private ToastFactory mToastFactory; @Mock @@ -234,9 +233,8 @@ public class InternetDetailsContentControllerTest extends SysuiTestCase { mSubscriptionManager, mTelephonyManager, mWifiManager, mConnectivityManager, mHandler, mExecutor, mBroadcastDispatcher, mock(KeyguardUpdateMonitor.class), mGlobalSettings, mKeyguardStateController, - mWindowManager, mToastFactory, mWorkerHandler, - mCarrierConfigTracker, mLocationController, mDialogTransitionAnimator, - mWifiStateWorker, mFlags); + mWindowManager, mToastFactory, mWorkerHandler, mCarrierConfigTracker, + mLocationController, mDialogTransitionAnimator, mWifiStateWorker, mFlags); mSubscriptionManager.addOnSubscriptionsChangedListener(mExecutor, mInternetDetailsContentController.mOnSubscriptionsChangedListener); mInternetDetailsContentController.onStart(mInternetDialogCallback, true); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyboardShortcutListSearchTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyboardShortcutListSearchTest.java index 8045a13ff9be..07204ee814d2 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyboardShortcutListSearchTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyboardShortcutListSearchTest.java @@ -34,6 +34,7 @@ import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import com.android.systemui.SysuiTestCase; +import com.android.systemui.utils.windowmanager.WindowManagerProvider; import com.google.android.material.bottomsheet.BottomSheetDialog; @@ -61,6 +62,7 @@ public class KeyboardShortcutListSearchTest extends SysuiTestCase { @Mock private BottomSheetDialog mBottomSheetDialog; @Mock WindowManager mWindowManager; @Mock Handler mHandler; + @Mock WindowManagerProvider mWindowManagerProvider; @Before public void setUp() { @@ -77,7 +79,7 @@ public class KeyboardShortcutListSearchTest extends SysuiTestCase { public void toggle_isShowingTrue_instanceShouldBeNull() { when(mBottomSheetDialog.isShowing()).thenReturn(true); - mKeyboardShortcutListSearch.toggle(mContext, DEVICE_ID); + mKeyboardShortcutListSearch.toggle(mContext, DEVICE_ID, mWindowManagerProvider); assertThat(mKeyboardShortcutListSearch.sInstance).isNull(); } @@ -86,7 +88,7 @@ public class KeyboardShortcutListSearchTest extends SysuiTestCase { public void toggle_isShowingFalse_showKeyboardShortcuts() { when(mBottomSheetDialog.isShowing()).thenReturn(false); - mKeyboardShortcutListSearch.toggle(mContext, DEVICE_ID); + mKeyboardShortcutListSearch.toggle(mContext, DEVICE_ID, mWindowManagerProvider); verify(mWindowManager).requestAppKeyboardShortcuts(any(), anyInt()); verify(mWindowManager).requestImeKeyboardShortcuts(any(), anyInt()); @@ -96,7 +98,7 @@ public class KeyboardShortcutListSearchTest extends SysuiTestCase { public void requestAppKeyboardShortcuts_callback_sanitisesIcons() { KeyboardShortcutGroup group = createKeyboardShortcutGroupForIconTests(); - mKeyboardShortcutListSearch.toggle(mContext, DEVICE_ID); + mKeyboardShortcutListSearch.toggle(mContext, DEVICE_ID, mWindowManagerProvider); ArgumentCaptor<WindowManager.KeyboardShortcutsReceiver> callbackCaptor = ArgumentCaptor.forClass(WindowManager.KeyboardShortcutsReceiver.class); @@ -114,7 +116,7 @@ public class KeyboardShortcutListSearchTest extends SysuiTestCase { public void requestImeKeyboardShortcuts_callback_sanitisesIcons() { KeyboardShortcutGroup group = createKeyboardShortcutGroupForIconTests(); - mKeyboardShortcutListSearch.toggle(mContext, DEVICE_ID); + mKeyboardShortcutListSearch.toggle(mContext, DEVICE_ID, mWindowManagerProvider); ArgumentCaptor<WindowManager.KeyboardShortcutsReceiver> callbackCaptor = ArgumentCaptor.forClass(WindowManager.KeyboardShortcutsReceiver.class); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyboardShortcutsReceiverTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyboardShortcutsReceiverTest.java index 2cb9791cc159..0bd9b29a1a37 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyboardShortcutsReceiverTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyboardShortcutsReceiverTest.java @@ -36,6 +36,7 @@ import com.android.systemui.SysuiTestCase; import com.android.systemui.flags.FakeFeatureFlags; import com.android.systemui.flags.Flags; import com.android.systemui.shared.recents.utilities.Utilities; +import com.android.systemui.utils.windowmanager.WindowManagerProvider; import org.junit.After; import org.junit.Before; @@ -59,6 +60,7 @@ public class KeyboardShortcutsReceiverTest extends SysuiTestCase { @Mock private KeyboardShortcuts mKeyboardShortcuts; @Mock private KeyboardShortcutListSearch mKeyboardShortcutListSearch; + @Mock private WindowManagerProvider mWindowManagerProvider; @Before public void setUp() { @@ -69,7 +71,8 @@ public class KeyboardShortcutsReceiverTest extends SysuiTestCase { KeyboardShortcuts.sInstance = mKeyboardShortcuts; KeyboardShortcutListSearch.sInstance = mKeyboardShortcutListSearch; - mKeyboardShortcutsReceiver = spy(new KeyboardShortcutsReceiver(mFeatureFlags)); + mKeyboardShortcutsReceiver = spy(new KeyboardShortcutsReceiver(mFeatureFlags, + mWindowManagerProvider)); } @Before diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyboardShortcutsTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyboardShortcutsTest.java index 20ecaf75c625..939f2b899dbe 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyboardShortcutsTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyboardShortcutsTest.java @@ -39,6 +39,7 @@ import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import com.android.systemui.SysuiTestCase; +import com.android.systemui.utils.windowmanager.WindowManagerProvider; import org.junit.Before; import org.junit.Rule; @@ -67,6 +68,7 @@ public class KeyboardShortcutsTest extends SysuiTestCase { @Mock private Dialog mDialog; @Mock WindowManager mWindowManager; @Mock Handler mHandler; + @Mock WindowManagerProvider mWindowManagerProvider; @Before public void setUp() { @@ -92,7 +94,7 @@ public class KeyboardShortcutsTest extends SysuiTestCase { public void toggle_isShowingTrue_instanceShouldBeNull() { when(mDialog.isShowing()).thenReturn(true); - KeyboardShortcuts.toggle(mContext, DEVICE_ID); + KeyboardShortcuts.toggle(mContext, DEVICE_ID, mWindowManagerProvider); assertThat(KeyboardShortcuts.sInstance).isNull(); } @@ -101,7 +103,7 @@ public class KeyboardShortcutsTest extends SysuiTestCase { public void toggle_isShowingFalse_showKeyboardShortcuts() { when(mDialog.isShowing()).thenReturn(false); - KeyboardShortcuts.toggle(mContext, DEVICE_ID); + KeyboardShortcuts.toggle(mContext, DEVICE_ID, mWindowManagerProvider); verify(mWindowManager).requestAppKeyboardShortcuts(any(), anyInt()); verify(mWindowManager).requestImeKeyboardShortcuts(any(), anyInt()); @@ -131,7 +133,7 @@ public class KeyboardShortcutsTest extends SysuiTestCase { @Test public void requestAppKeyboardShortcuts_callback_sanitisesIcons() { KeyboardShortcutGroup group = createKeyboardShortcutGroupForIconTests(); - KeyboardShortcuts.toggle(mContext, DEVICE_ID); + KeyboardShortcuts.toggle(mContext, DEVICE_ID, mWindowManagerProvider); emitAppShortcuts(singletonList(group), DEVICE_ID); @@ -142,7 +144,7 @@ public class KeyboardShortcutsTest extends SysuiTestCase { @Test public void requestImeKeyboardShortcuts_callback_sanitisesIcons() { KeyboardShortcutGroup group = createKeyboardShortcutGroupForIconTests(); - KeyboardShortcuts.toggle(mContext, DEVICE_ID); + KeyboardShortcuts.toggle(mContext, DEVICE_ID, mWindowManagerProvider); emitImeShortcuts(singletonList(group), DEVICE_ID); @@ -153,7 +155,7 @@ public class KeyboardShortcutsTest extends SysuiTestCase { @Test public void onImeAndAppShortcutsReceived_appShortcutsNull_doesNotCrash() { KeyboardShortcutGroup group = createKeyboardShortcutGroupForIconTests(); - KeyboardShortcuts.toggle(mContext, DEVICE_ID); + KeyboardShortcuts.toggle(mContext, DEVICE_ID, mWindowManagerProvider); emitImeShortcuts(singletonList(group), DEVICE_ID); emitAppShortcuts(/* groups= */ null, DEVICE_ID); @@ -162,7 +164,7 @@ public class KeyboardShortcutsTest extends SysuiTestCase { @Test public void onImeAndAppShortcutsReceived_imeShortcutsNull_doesNotCrash() { KeyboardShortcutGroup group = createKeyboardShortcutGroupForIconTests(); - KeyboardShortcuts.toggle(mContext, DEVICE_ID); + KeyboardShortcuts.toggle(mContext, DEVICE_ID, mWindowManagerProvider); emitAppShortcuts(singletonList(group), DEVICE_ID); emitImeShortcuts(/* groups= */ null, DEVICE_ID); @@ -170,7 +172,7 @@ public class KeyboardShortcutsTest extends SysuiTestCase { @Test public void onImeAndAppShortcutsReceived_bothNull_doesNotCrash() { - KeyboardShortcuts.toggle(mContext, DEVICE_ID); + KeyboardShortcuts.toggle(mContext, DEVICE_ID, mWindowManagerProvider); emitImeShortcuts(/* groups= */ null, DEVICE_ID); emitAppShortcuts(/* groups= */ null, DEVICE_ID); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java index a7f3fdcb517e..0c5cbc299aee 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java @@ -93,7 +93,6 @@ import android.view.WindowMetrics; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.compose.animation.scene.ObservableTransitionState; import com.android.internal.colorextraction.ColorExtractor; import com.android.internal.logging.UiEventLogger; @@ -214,6 +213,7 @@ import com.android.systemui.util.settings.FakeGlobalSettings; import com.android.systemui.util.settings.FakeSettings; import com.android.systemui.util.settings.SystemSettings; import com.android.systemui.util.time.FakeSystemClock; +import com.android.systemui.utils.windowmanager.WindowManagerProvider; import com.android.systemui.volume.VolumeComponent; import com.android.systemui.wallet.controller.QuickAccessWalletController; import com.android.wm.shell.bubbles.Bubbles; @@ -372,9 +372,10 @@ public class CentralSurfacesImplTest extends SysuiTestCase { @Mock private GlanceableHubContainerController mGlanceableHubContainerController; @Mock private EmergencyGestureIntentFactory mEmergencyGestureIntentFactory; @Mock private NotificationSettingsInteractor mNotificationSettingsInteractor; - @Mock private ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager; @Mock private StatusBarLongPressGestureDetector mStatusBarLongPressGestureDetector; @Mock private QuickAccessWalletController mQuickAccessWalletController; + @Mock private WindowManager mWindowManager; + @Mock private WindowManagerProvider mWindowManagerProvider; private ShadeController mShadeController; private final FakeSystemClock mFakeSystemClock = new FakeSystemClock(); private final FakeGlobalSettings mFakeGlobalSettings = new FakeGlobalSettings(); @@ -642,8 +643,9 @@ public class CentralSurfacesImplTest extends SysuiTestCase { mBrightnessMirrorShowingRepository, mGlanceableHubContainerController, mEmergencyGestureIntentFactory, - mViewCaptureAwareWindowManager, - mQuickAccessWalletController + mQuickAccessWalletController, + mWindowManager, + mWindowManagerProvider ); mScreenLifecycle.addObserver(mCentralSurfaces.mScreenObserver); mCentralSurfaces.initShadeVisibilityListener(); @@ -1363,15 +1365,13 @@ public class CentralSurfacesImplTest extends SysuiTestCase { private void switchToScreenSize(int widthDp, int heightDp) { WindowMetrics windowMetrics = Mockito.mock(WindowMetrics.class); - WindowManager windowManager = Mockito.mock(WindowManager.class); Configuration configuration = new Configuration(); configuration.densityDpi = DisplayMetrics.DENSITY_DEFAULT; mContext.getOrCreateTestableResources().overrideConfiguration(configuration); when(windowMetrics.getBounds()).thenReturn(new Rect(0, 0, widthDp, heightDp)); - when(windowManager.getCurrentWindowMetrics()).thenReturn(windowMetrics); - mContext.addMockSystemService(WindowManager.class, windowManager); + when(mWindowManager.getCurrentWindowMetrics()).thenReturn(windowMetrics); } /** diff --git a/packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/TemporaryViewDisplayControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/TemporaryViewDisplayControllerTest.kt index 54df9e99baa5..bb6ba46f1a0b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/TemporaryViewDisplayControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/TemporaryViewDisplayControllerTest.kt @@ -25,13 +25,12 @@ import android.view.WindowManager import android.view.accessibility.AccessibilityManager import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest -import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.internal.logging.InstanceId import com.android.internal.logging.testing.UiEventLoggerFake +import com.android.systemui.res.R import com.android.systemui.SysuiTestCase import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.dump.DumpManager -import com.android.systemui.res.R import com.android.systemui.statusbar.policy.ConfigurationController import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener import com.android.systemui.util.concurrency.DelayableExecutor @@ -78,7 +77,7 @@ class TemporaryViewDisplayControllerTest : SysuiTestCase() { @Mock private lateinit var dumpManager: DumpManager @Mock - private lateinit var windowManager: ViewCaptureAwareWindowManager + private lateinit var windowManager: WindowManager @Mock private lateinit var powerManager: PowerManager @@ -1143,7 +1142,7 @@ class TemporaryViewDisplayControllerTest : SysuiTestCase() { inner class TestController( context: Context, logger: TemporaryViewLogger<ViewInfo>, - viewCaptureAwareWindowManager: ViewCaptureAwareWindowManager, + windowManager: WindowManager, @Main mainExecutor: DelayableExecutor, accessibilityManager: AccessibilityManager, configurationController: ConfigurationController, @@ -1155,7 +1154,7 @@ class TemporaryViewDisplayControllerTest : SysuiTestCase() { ) : TemporaryViewDisplayController<ViewInfo, TemporaryViewLogger<ViewInfo>>( context, logger, - viewCaptureAwareWindowManager, + windowManager, mainExecutor, accessibilityManager, configurationController, diff --git a/packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinatorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinatorTest.kt index 4260b6558950..664f2df62782 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinatorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinatorTest.kt @@ -30,8 +30,6 @@ import android.widget.TextView import androidx.core.animation.doOnCancel import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest -import com.android.app.viewcapture.ViewCapture -import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.internal.logging.InstanceId import com.android.internal.logging.testing.UiEventLoggerFake import com.android.systemui.SysuiTestCase @@ -86,7 +84,6 @@ class ChipbarCoordinatorTest : SysuiTestCase() { @Mock private lateinit var viewUtil: ViewUtil @Mock private lateinit var vibratorHelper: VibratorHelper @Mock private lateinit var swipeGestureHandler: SwipeChipbarAwayGestureHandler - @Mock private lateinit var lazyViewCapture: Lazy<ViewCapture> private lateinit var chipbarAnimator: TestChipbarAnimator private lateinit var fakeWakeLockBuilder: WakeLockFake.Builder private lateinit var fakeWakeLock: WakeLockFake @@ -115,8 +112,7 @@ class ChipbarCoordinatorTest : SysuiTestCase() { ChipbarCoordinator( context, logger, - ViewCaptureAwareWindowManager(windowManager, lazyViewCapture, - isViewCaptureEnabled = false), + windowManager, fakeExecutor, accessibilityManager, configurationController, diff --git a/packages/SystemUI/tests/src/com/android/systemui/utils/WindowManagerProviderImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/utils/WindowManagerProviderImplTest.kt new file mode 100644 index 000000000000..7b52237f0a01 --- /dev/null +++ b/packages/SystemUI/tests/src/com/android/systemui/utils/WindowManagerProviderImplTest.kt @@ -0,0 +1,53 @@ +/* + * 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.systemui.utils + +import android.platform.test.annotations.DisableFlags +import android.platform.test.annotations.EnableFlags +import android.view.WindowManager +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.filters.SmallTest +import com.android.systemui.Flags +import com.android.systemui.SysuiTestCase +import com.android.systemui.utils.windowmanager.WindowManagerProviderImpl +import com.google.common.truth.Truth.assertThat +import org.junit.runner.RunWith +import org.junit.Test + +@RunWith(AndroidJUnit4::class) +@SmallTest +class WindowManagerProviderImplTest : SysuiTestCase() { + + private val windowManagerProvider = WindowManagerProviderImpl() + private val windowManagerFromSystemService = mContext.getSystemService(WindowManager::class.java) + + @Test + @EnableFlags(Flags.FLAG_ENABLE_VIEW_CAPTURE_TRACING) + fun viewCaptureTracingEnabled_verifyWMInstanceDoesNotMatchContextOne() { + val windowManagerFromProvider = windowManagerProvider.getWindowManager(mContext) + assertThat(windowManagerFromProvider).isNotEqualTo(windowManagerFromSystemService) + } + + @Test + @DisableFlags(Flags.FLAG_ENABLE_VIEW_CAPTURE_TRACING) + fun viewCaptureTracingDisabled_verifyWMInstanceMatchesContextOne() { + mContext.addMockSystemService(WindowManager::class.java, windowManagerFromSystemService) + + val windowManagerFromProvider = windowManagerProvider.getWindowManager(mContext) + assertThat(windowManagerFromProvider).isEqualTo(windowManagerFromSystemService) + } +}
\ No newline at end of file diff --git a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java index 0d7ce5353cd4..f89571f2db2d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java @@ -101,8 +101,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.test.filters.SmallTest; -import com.android.app.viewcapture.ViewCapture; -import com.android.app.viewcapture.ViewCaptureAwareWindowManager; import com.android.internal.colorextraction.ColorExtractor; import com.android.internal.logging.UiEventLogger; import com.android.internal.protolog.ProtoLog; @@ -358,8 +356,6 @@ public class BubblesTest extends SysuiTestCase { @Mock private Display mDefaultDisplay; @Mock - private Lazy<ViewCapture> mLazyViewCapture; - @Mock private SyncTransactionQueue mSyncQueue; private final KosmosJavaAdapter mKosmos = new KosmosJavaAdapter(this); @@ -429,8 +425,7 @@ public class BubblesTest extends SysuiTestCase { mNotificationShadeWindowController = new NotificationShadeWindowControllerImpl( mContext, new FakeWindowRootViewComponent.Factory(mNotificationShadeWindowView), - new ViewCaptureAwareWindowManager(mWindowManager, mLazyViewCapture, - /* isViewCaptureEnabled= */ false), + mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController, diff --git a/packages/SystemUI/tests/utils/src/com/android/app/viewcapture/ViewCaptureAwareWindowManagerKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/app/viewcapture/ViewCaptureAwareWindowManagerKosmos.kt deleted file mode 100644 index 021c7bbb44cd..000000000000 --- a/packages/SystemUI/tests/utils/src/com/android/app/viewcapture/ViewCaptureAwareWindowManagerKosmos.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2024 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.app.viewcapture - -import android.view.fakeWindowManager -import com.android.systemui.kosmos.Kosmos -import org.mockito.kotlin.mock - -val Kosmos.mockViewCaptureAwareWindowManager by - Kosmos.Fixture { mock<ViewCaptureAwareWindowManager>() } - -val Kosmos.realCaptureAwareWindowManager by - Kosmos.Fixture { - ViewCaptureAwareWindowManager( - fakeWindowManager, - lazyViewCapture = lazy { mock<ViewCapture>() }, - isViewCaptureEnabled = false, - ) - } - -var Kosmos.viewCaptureAwareWindowManager: ViewCaptureAwareWindowManager by - Kosmos.Fixture { mockViewCaptureAwareWindowManager } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/data/repository/PrivacyDotWindowControllerStoreKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/data/repository/PrivacyDotWindowControllerStoreKosmos.kt index aae32cfaafa6..f83fcb32aafe 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/data/repository/PrivacyDotWindowControllerStoreKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/data/repository/PrivacyDotWindowControllerStoreKosmos.kt @@ -16,8 +16,6 @@ package com.android.systemui.statusbar.data.repository -import android.view.WindowManager -import com.android.app.viewcapture.ViewCaptureAwareWindowManager import com.android.systemui.display.data.repository.displayRepository import com.android.systemui.display.data.repository.displayWindowPropertiesRepository import com.android.systemui.kosmos.Kosmos @@ -35,14 +33,6 @@ val Kosmos.privacyDotWindowControllerStoreImpl by windowControllerFactory = { _, _, _, _ -> mock() }, displayWindowPropertiesRepository = displayWindowPropertiesRepository, privacyDotViewControllerStore = privacyDotViewControllerStore, - viewCaptureAwareWindowManagerFactory = - object : ViewCaptureAwareWindowManager.Factory { - override fun create( - windowManager: WindowManager - ): ViewCaptureAwareWindowManager { - return mock() - } - }, ) } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/events/PrivacyDotWindowControllerKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/events/PrivacyDotWindowControllerKosmos.kt index c73838708a7a..da4027e46783 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/events/PrivacyDotWindowControllerKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/events/PrivacyDotWindowControllerKosmos.kt @@ -17,8 +17,8 @@ package com.android.systemui.statusbar.events import android.content.testableContext +import android.view.fakeWindowManager import android.view.layoutInflater -import com.android.app.viewcapture.realCaptureAwareWindowManager import com.android.systemui.concurrency.fakeExecutor import com.android.systemui.decor.privacyDotDecorProviderFactory import com.android.systemui.kosmos.Kosmos @@ -28,7 +28,7 @@ var Kosmos.privacyDotWindowController by PrivacyDotWindowController( testableContext.displayId, privacyDotViewController, - realCaptureAwareWindowManager, + fakeWindowManager, layoutInflater, fakeExecutor, privacyDotDecorProviderFactory, diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/window/FakeStatusBarWindowControllerFactory.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/window/FakeStatusBarWindowControllerFactory.kt index 3a19547f0713..f20fb3bf1779 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/window/FakeStatusBarWindowControllerFactory.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/window/FakeStatusBarWindowControllerFactory.kt @@ -17,14 +17,14 @@ package com.android.systemui.statusbar.window import android.content.Context -import com.android.app.viewcapture.ViewCaptureAwareWindowManager +import android.view.WindowManager import com.android.systemui.statusbar.data.repository.StatusBarConfigurationController import com.android.systemui.statusbar.layout.StatusBarContentInsetsProvider class FakeStatusBarWindowControllerFactory : StatusBarWindowController.Factory { override fun create( context: Context, - viewCaptureAwareWindowManager: ViewCaptureAwareWindowManager, + windowManager: WindowManager, statusBarConfigurationController: StatusBarConfigurationController, contentInsetsProvider: StatusBarContentInsetsProvider, ) = FakeStatusBarWindowController() diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/window/StatusBarWindowControllerKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/window/StatusBarWindowControllerKosmos.kt index f595aef41e2d..b0214769362f 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/window/StatusBarWindowControllerKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/window/StatusBarWindowControllerKosmos.kt @@ -17,8 +17,8 @@ package com.android.systemui.statusbar.window import android.content.testableContext +import android.view.fakeWindowManager import android.view.windowManagerService -import com.android.app.viewcapture.realCaptureAwareWindowManager import com.android.systemui.concurrency.fakeExecutor import com.android.systemui.fragments.fragmentService import com.android.systemui.kosmos.Kosmos @@ -33,7 +33,7 @@ val Kosmos.statusBarWindowControllerImpl by StatusBarWindowControllerImpl( testableContext, statusBarWindowViewInflater, - realCaptureAwareWindowManager, + fakeWindowManager, statusBarConfigurationController, windowManagerService, statusBarContentInsetsProvider, diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/window/StatusBarWindowControllerStoreKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/window/StatusBarWindowControllerStoreKosmos.kt index 4941ceb7991d..0f9310376b2a 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/window/StatusBarWindowControllerStoreKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/window/StatusBarWindowControllerStoreKosmos.kt @@ -16,9 +16,6 @@ package com.android.systemui.statusbar.window -import android.view.WindowManager -import com.android.app.viewcapture.ViewCaptureAwareWindowManager -import com.android.app.viewcapture.realCaptureAwareWindowManager import com.android.systemui.display.data.repository.displayRepository import com.android.systemui.display.data.repository.displayWindowPropertiesRepository import com.android.systemui.kosmos.Kosmos @@ -33,14 +30,6 @@ val Kosmos.multiDisplayStatusBarWindowControllerStore by backgroundApplicationScope = applicationCoroutineScope, controllerFactory = { _, _, _, _ -> mock() }, displayWindowPropertiesRepository = displayWindowPropertiesRepository, - viewCaptureAwareWindowManagerFactory = - object : ViewCaptureAwareWindowManager.Factory { - override fun create( - windowManager: WindowManager - ): ViewCaptureAwareWindowManager { - return realCaptureAwareWindowManager - } - }, statusBarConfigurationControllerStore = statusBarConfigurationControllerStore, statusBarContentInsetsProviderStore = statusBarContentInsetsProviderStore, displayRepository = displayRepository, diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/utils/windowmanager/FakeWindowManagerProvider.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/utils/windowmanager/FakeWindowManagerProvider.kt new file mode 100644 index 000000000000..5c8eae3183c7 --- /dev/null +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/utils/windowmanager/FakeWindowManagerProvider.kt @@ -0,0 +1,28 @@ +/* + * 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.systemui.utils.windowmanager + +import android.content.Context +import android.view.WindowManager + +/** Fake implementation of [WindowManagerProvider], to be used in tests only. */ +class FakeWindowManagerProvider(private val windowManager: WindowManager) : WindowManagerProvider { + + override fun getWindowManager(context: Context): WindowManager { + return windowManager + } +}
\ No newline at end of file diff --git a/packages/SystemUI/utils/Android.bp b/packages/SystemUI/utils/Android.bp index 1efb11b436ff..8b63c07b270f 100644 --- a/packages/SystemUI/utils/Android.bp +++ b/packages/SystemUI/utils/Android.bp @@ -26,6 +26,8 @@ java_library { "src/**/*.kt", ], static_libs: [ + "//frameworks/libs/systemui:view_capture", + "com_android_systemui_flags_lib", "kotlin-stdlib", "kotlinx_coroutines", ], diff --git a/packages/SystemUI/utils/src/com/android/systemui/utils/windowmanager/WindowManagerProvider.kt b/packages/SystemUI/utils/src/com/android/systemui/utils/windowmanager/WindowManagerProvider.kt new file mode 100644 index 000000000000..4e6eacbc8808 --- /dev/null +++ b/packages/SystemUI/utils/src/com/android/systemui/utils/windowmanager/WindowManagerProvider.kt @@ -0,0 +1,56 @@ +/* + * 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.systemui.utils.windowmanager + +import android.content.Context +import android.view.WindowManager + +/** + * Provider for [WindowManager] in SystemUI. + * + * Use this class over [WindowManagerUtils] in cases where + * a [WindowManager] is needed for a context created inside the class. [WindowManagerUtils] should + * only be used in a class where the [WindowManager] is needed for a custom context inside the + * class, and the class is not part of the dagger graph. Example usage: + * ```kotlin + * class Sample { + * private final WindowManager mWindowManager; + * + * @Inject + * public Sample(WindowManagerProvider windowManagerProvider) { + * Context context = getCustomContext(); + * mWindowManager = windowManagerProvider.getWindowManager(context); + * } + * // use mWindowManager + * } + * + * class SampleTest { + * + * @Mock + * WindowManager mWindowManager; + * + * FakeWindowManagerProvider fakeProvider = new FakeWindowManagerProvider(mWindowManager); + * + * // define the behaviour of mWindowManager to get required WindowManager instance in tests. + * } + * ``` + */ +interface WindowManagerProvider { + + /** Method to return the required [WindowManager]. */ + fun getWindowManager(context: Context): WindowManager +} diff --git a/packages/SystemUI/utils/src/com/android/systemui/utils/windowmanager/WindowManagerProviderImpl.kt b/packages/SystemUI/utils/src/com/android/systemui/utils/windowmanager/WindowManagerProviderImpl.kt new file mode 100644 index 000000000000..5e965ed47403 --- /dev/null +++ b/packages/SystemUI/utils/src/com/android/systemui/utils/windowmanager/WindowManagerProviderImpl.kt @@ -0,0 +1,28 @@ +/* + * 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.systemui.utils.windowmanager + +import android.content.Context +import android.view.WindowManager + +/** Implementation of [WindowManagerProvider]. */ +class WindowManagerProviderImpl : WindowManagerProvider { + + override fun getWindowManager(context: Context): WindowManager { + return WindowManagerUtils.getWindowManager(context) + } +} diff --git a/packages/SystemUI/utils/src/com/android/systemui/utils/windowmanager/WindowManagerUtils.kt b/packages/SystemUI/utils/src/com/android/systemui/utils/windowmanager/WindowManagerUtils.kt new file mode 100644 index 000000000000..643e93422294 --- /dev/null +++ b/packages/SystemUI/utils/src/com/android/systemui/utils/windowmanager/WindowManagerUtils.kt @@ -0,0 +1,49 @@ +/* + * 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.systemui.utils.windowmanager + +import android.content.Context +import android.view.WindowManager +import com.android.app.viewcapture.ViewCaptureAwareWindowManagerFactory +import com.android.systemui.Flags.enableViewCaptureTracing + +/** + * Provides [WindowManager] in SystemUI. Use [WindowManagerProvider] unless [WindowManager] instance + * needs to be created in a class that is not part of the dagger dependency graph. + */ +object WindowManagerUtils { + + /** Method to return the required [WindowManager]. */ + @JvmStatic + fun getWindowManager(context: Context): WindowManager { + return if (!enableViewCaptureTracing()) { + context.getSystemService(WindowManager::class.java) + } else { + /** + * We use this token to supply windowContextToken to [WindowManager] for + * [WindowContext]. + */ + val windowContextToken = context.windowContextToken + + ViewCaptureAwareWindowManagerFactory.getInstance( + context, + parent = null, + windowContextToken, + ) + } + } +} |