Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 22a9d4eb authored by Archisha Baranwal's avatar Archisha Baranwal Committed by Android (Google) Code Review
Browse files

Merge "Adding ViewCaptureAwareWindowManager to system ui windows." into main

parents 28e73636 16c85a11
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -34,6 +34,9 @@ import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LifecycleRegistry
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.app.viewcapture.ViewCaptureFactory
import com.android.compose.animation.scene.ObservableTransitionState
import com.android.internal.logging.UiEventLogger
import com.android.keyguard.KeyguardUpdateMonitor
@@ -79,6 +82,7 @@ import org.mockito.Mock
import org.mockito.Mockito
import org.mockito.Mockito.clearInvocations
import org.mockito.Mockito.isNull
import org.mockito.Mockito.spy
import org.mockito.Mockito.verify
import org.mockito.MockitoAnnotations

@@ -154,8 +158,12 @@ class DreamOverlayServiceTest : SysuiTestCase() {

    @Mock lateinit var mDreamOverlayCallbackController: DreamOverlayCallbackController

    @Mock lateinit var mLazyViewCapture: Lazy<ViewCapture>

    private lateinit var mViewCaptureAwareWindowManager: ViewCaptureAwareWindowManager
    private lateinit var bouncerRepository: FakeKeyguardBouncerRepository
    private lateinit var communalRepository: FakeCommunalSceneRepository
    private var viewCaptureSpy = spy(ViewCaptureFactory.getInstance(context))

    @Captor var mViewCaptor: ArgumentCaptor<View>? = null
    private lateinit var mService: DreamOverlayService
@@ -192,13 +200,16 @@ class DreamOverlayServiceTest : SysuiTestCase() {
        whenever(mDreamOverlayContainerViewController.containerView)
            .thenReturn(mDreamOverlayContainerView)
        whenever(mScrimManager.getCurrentController()).thenReturn(mScrimController)
        whenever(mLazyViewCapture.value).thenReturn(viewCaptureSpy)
        mWindowParams = WindowManager.LayoutParams()
        mViewCaptureAwareWindowManager = ViewCaptureAwareWindowManager(mWindowManager,
                mLazyViewCapture, isViewCaptureEnabled = false)
        mService =
            DreamOverlayService(
                mContext,
                mLifecycleOwner,
                mMainExecutor,
                mWindowManager,
                mViewCaptureAwareWindowManager,
                mComplicationComponentFactory,
                mDreamComplicationComponentFactory,
                mDreamOverlayComponentFactory,
+22 −0
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

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;
@@ -111,6 +114,9 @@ import android.view.textclassifier.TextClassificationManager;
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;
@@ -125,6 +131,7 @@ import com.android.systemui.shared.system.PackageManagerWrapper;
import com.android.systemui.user.utils.UserScopedService;
import com.android.systemui.user.utils.UserScopedServiceImpl;

import dagger.Lazy;
import dagger.Module;
import dagger.Provides;

@@ -678,6 +685,15 @@ public class FrameworkServicesModule {
        return context.getSystemService(WindowManager.class);
    }

    @Provides
    @Singleton
    static ViewCaptureAwareWindowManager provideViewCaptureAwareWindowManager(
            WindowManager windowManager, Lazy<ViewCapture> daggerLazyViewCapture) {
        return new ViewCaptureAwareWindowManager(windowManager,
                /* lazyViewCapture= */ toKotlinLazy(daggerLazyViewCapture),
                /* isViewCaptureEnabled= */ enableViewCaptureTracing());
    }

    @Provides
    @Singleton
    static PermissionManager providePermissionManager(Context context) {
@@ -764,4 +780,10 @@ public class FrameworkServicesModule {
        return IDeviceIdleController.Stub.asInterface(
                ServiceManager.getService(Context.DEVICE_IDLE_CONTROLLER));
    }

    @Provides
    @Singleton
    static ViewCapture provideViewCapture(Context context) {
        return ViewCaptureFactory.getInstance(context);
    }
}
+4 −3
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import androidx.lifecycle.LifecycleService;
import androidx.lifecycle.ServiceLifecycleDispatcher;
import androidx.lifecycle.ViewModelStore;

import com.android.app.viewcapture.ViewCaptureAwareWindowManager;
import com.android.dream.lowlight.dagger.LowLightDreamModule;
import com.android.internal.logging.UiEvent;
import com.android.internal.logging.UiEventLogger;
@@ -97,7 +98,7 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ
    @Nullable
    private final ComponentName mHomeControlPanelDreamComponent;
    private final UiEventLogger mUiEventLogger;
    private final WindowManager mWindowManager;
    private final ViewCaptureAwareWindowManager mWindowManager;
    private final String mWindowTitle;

    // A reference to the {@link Window} used to hold the dream overlay.
@@ -244,7 +245,7 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ
            Context context,
            DreamOverlayLifecycleOwner lifecycleOwner,
            @Main DelayableExecutor executor,
            WindowManager windowManager,
            ViewCaptureAwareWindowManager viewCaptureAwareWindowManager,
            ComplicationComponent.Factory complicationComponentFactory,
            com.android.systemui.dreams.complication.dagger.ComplicationComponent.Factory
                    dreamComplicationComponentFactory,
@@ -267,7 +268,7 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ
        super(executor);
        mContext = context;
        mExecutor = executor;
        mWindowManager = windowManager;
        mWindowManager = viewCaptureAwareWindowManager;
        mKeyguardUpdateMonitor = keyguardUpdateMonitor;
        mScrimManager = scrimManager;
        mLowLightDreamComponent = lowLightDreamComponent;
+6 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ 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,3 +57,8 @@ val View.boundsOnScreen: Rect
        getBoundsOnScreen(bounds)
        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() }
}