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

Commit 15915273 authored by archisha's avatar archisha Committed by Archisha Baranwal
Browse files

Adding ViewCaptureAwareWindowManager to AuthContainerView.

We can not inject an instance of ViewCaptureAwareWindowManager, and instead need to instantiate the same. When injected, the window manager does not allow the parent view to destroy on user actions such as beck press, hence the explicit instantiation is needed.

Bug: 360273259
Flag: com.android.systemui.enable_view_capture_tracing
Test: AuthControllerTest and AuthContainerViewTest
Change-Id: I2f9d8a3af0d1abcbee6dd70adfbe99979bc39be6
parent 2e761f57
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ 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;
@@ -96,6 +97,8 @@ import com.android.systemui.util.concurrency.FakeExecution;
import com.android.systemui.util.concurrency.FakeExecutor;
import com.android.systemui.util.time.FakeSystemClock;

import dagger.Lazy;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -165,6 +168,8 @@ public class AuthControllerTest extends SysuiTestCase {
    private PromptViewModel mPromptViewModel;
    @Mock
    private UdfpsUtils mUdfpsUtils;
    @Mock
    private Lazy<ViewCapture> mLazyViewCapture;

    @Captor
    private ArgumentCaptor<IFingerprintAuthenticatorsRegisteredCallback> mFpAuthenticatorsRegisteredCaptor;
@@ -1060,7 +1065,8 @@ public class AuthControllerTest extends SysuiTestCase {
                    mWakefulnessLifecycle, mUserManager, mLockPatternUtils, () -> mUdfpsLogger,
                    () -> mLogContextInteractor, () -> mPromptSelectionInteractor,
                    () -> mCredentialViewModel, () -> mPromptViewModel, mInteractionJankMonitor,
                    mHandler, mBackgroundExecutor, mUdfpsUtils, mVibratorHelper);
                    mHandler, mBackgroundExecutor, mUdfpsUtils, mVibratorHelper,
                    mLazyViewCapture);
        }

        @Override
+11 −3
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ 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;
@@ -56,6 +57,8 @@ 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;
@@ -75,6 +78,8 @@ import com.android.systemui.res.R;
import com.android.systemui.statusbar.VibratorHelper;
import com.android.systemui.util.concurrency.DelayableExecutor;

import kotlin.Lazy;

import kotlinx.coroutines.CoroutineScope;

import java.io.PrintWriter;
@@ -124,7 +129,7 @@ public class AuthContainerView extends LinearLayout
    private final Config mConfig;
    private final int mEffectiveUserId;
    private final IBinder mWindowToken = new Binder();
    private final WindowManager mWindowManager;
    private final ViewCaptureAwareWindowManager mWindowManager;
    private final Interpolator mLinearOutSlowIn;
    private final LockPatternUtils mLockPatternUtils;
    private final WakefulnessLifecycle mWakefulnessLifecycle;
@@ -286,13 +291,16 @@ public class AuthContainerView extends LinearLayout
            @NonNull PromptViewModel promptViewModel,
            @NonNull Provider<CredentialViewModel> credentialViewModelProvider,
            @NonNull @Background DelayableExecutor bgExecutor,
            @NonNull VibratorHelper vibratorHelper) {
            @NonNull VibratorHelper vibratorHelper,
            Lazy<ViewCapture> lazyViewCapture) {
        super(config.mContext);

        mConfig = config;
        mLockPatternUtils = lockPatternUtils;
        mEffectiveUserId = userManager.getCredentialOwnerProfile(mConfig.mUserId);
        mWindowManager = mContext.getSystemService(WindowManager.class);
        WindowManager wm = getContext().getSystemService(WindowManager.class);
        mWindowManager = new ViewCaptureAwareWindowManager(wm, lazyViewCapture,
                enableViewCaptureTracing());
        mWakefulnessLifecycle = wakefulnessLifecycle;
        mApplicationCoroutineScope = applicationCoroutineScope;

+11 −2
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FACE;
import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FINGERPRINT;
import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_REAR;

import static com.android.systemui.util.ConvenienceExtensionsKt.toKotlinLazy;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityTaskManager;
@@ -61,6 +63,7 @@ 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;
@@ -181,6 +184,8 @@ public class AuthController implements
    private final DisplayInfo mCachedDisplayInfo = new DisplayInfo();
    @NonNull private final VibratorHelper mVibratorHelper;

    private final kotlin.Lazy<ViewCapture> mLazyViewCapture;

    @VisibleForTesting
    final TaskStackListener mTaskStackListener = new TaskStackListener() {
        @Override
@@ -736,7 +741,8 @@ public class AuthController implements
            @Main Handler handler,
            @Background DelayableExecutor bgExecutor,
            @NonNull UdfpsUtils udfpsUtils,
            @NonNull VibratorHelper vibratorHelper) {
            @NonNull VibratorHelper vibratorHelper,
            Lazy<ViewCapture> daggerLazyViewCapture) {
        mContext = context;
        mExecution = execution;
        mUserManager = userManager;
@@ -785,6 +791,8 @@ public class AuthController implements
        filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
        context.registerReceiver(mBroadcastReceiver, filter, Context.RECEIVER_EXPORTED_UNAUDITED);
        mSensorPrivacyManager = context.getSystemService(SensorPrivacyManager.class);

        mLazyViewCapture = toKotlinLazy(daggerLazyViewCapture);
    }

    // TODO(b/229290039): UDFPS controller should manage its dimensions on its own. Remove this.
@@ -1318,7 +1326,8 @@ public class AuthController implements
        return new AuthContainerView(config, mApplicationCoroutineScope, mFpProps, mFaceProps,
                wakefulnessLifecycle, userManager, lockPatternUtils,
                mInteractionJankMonitor, mPromptSelectorInteractor, viewModel,
                mCredentialViewModelProvider, bgExecutor, mVibratorHelper);
                mCredentialViewModelProvider, bgExecutor, mVibratorHelper,
                mLazyViewCapture);
    }

    @Override
+4 −1
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ 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.launcher3.icons.IconProvider
@@ -111,6 +112,7 @@ open class AuthContainerViewTest : SysuiTestCase() {
    @Mock lateinit var selectedUserInteractor: SelectedUserInteractor
    @Mock private lateinit var packageManager: PackageManager
    @Mock private lateinit var activityTaskManager: ActivityTaskManager
    @Mock private lateinit var lazyViewCapture: Lazy<ViewCapture>

    private lateinit var displayRepository: FakeDisplayRepository
    private lateinit var displayStateInteractor: DisplayStateInteractor
@@ -665,7 +667,8 @@ open class AuthContainerViewTest : SysuiTestCase() {
            ),
            { credentialViewModel },
            fakeExecutor,
            vibrator
            vibrator,
            lazyViewCapture
        ) {
        override fun postOnAnimation(runnable: Runnable) {
            runnable.run()