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

Commit 08e213dc authored by archisha's avatar archisha
Browse files

Adding ViewCaptureAwareWindowManager to ImmersiveModeConfirmation window.

Bug: 359789827
Flag: com.android.systemui.enable_view_capture_tracing
Test: atest com.android.server.wm

Change-Id: Iabe1778da42f835add98c565082581a5c6e02b2d
parent 2e761f57
Loading
Loading
Loading
Loading
+25 −12
Original line number Diff line number Diff line
@@ -28,6 +28,9 @@ import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_M
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;
@@ -73,12 +76,16 @@ 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.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 javax.inject.Inject;

/**
@@ -105,12 +112,12 @@ public class ImmersiveModeConfirmation implements CoreStartable, CommandQueue.Ca
    private final CommandQueue mCommandQueue;

    private ClingWindowView mClingWindow;
    /** The last {@link WindowManager} that is used to add the confirmation window. */
    /** The wrapper on the last {@link WindowManager} used to add the confirmation window. */
    @Nullable
    private WindowManager mWindowManager;
    private ViewCaptureAwareWindowManager mViewCaptureAwareWindowManager;
    /**
     * The WindowContext that is registered with {@link #mWindowManager} with options to specify the
     * {@link RootDisplayArea} to attach the confirmation window.
     * The WindowContext that is registered with {@link #mViewCaptureAwareWindowManager} with
     * options to specify the {@link RootDisplayArea} to attach the confirmation window.
     */
    @Nullable
    private Context mWindowContext;
@@ -127,15 +134,19 @@ public class ImmersiveModeConfirmation implements CoreStartable, CommandQueue.Ca

    private ContentObserver mContentObserver;

    private Lazy<ViewCapture> mLazyViewCapture;

    @Inject
    public ImmersiveModeConfirmation(Context context, CommandQueue commandQueue,
                                     SecureSettings secureSettings) {
                                     SecureSettings secureSettings,
                                     dagger.Lazy<ViewCapture> daggerLazyViewCapture) {
        mSysUiContext = context;
        final Display display = mSysUiContext.getDisplay();
        mDisplayContext = display.getDisplayId() == DEFAULT_DISPLAY
                ? mSysUiContext : mSysUiContext.createDisplayContext(display);
        mCommandQueue = commandQueue;
        mSecureSettings = secureSettings;
        mLazyViewCapture = toKotlinLazy(daggerLazyViewCapture);
    }

    boolean loadSetting(int currentUserId) {
@@ -239,14 +250,14 @@ public class ImmersiveModeConfirmation implements CoreStartable, CommandQueue.Ca
    private void handleHide() {
        if (mClingWindow != null) {
            if (DEBUG) Log.d(TAG, "Hiding immersive mode confirmation");
            if (mWindowManager != null) {
            if (mViewCaptureAwareWindowManager != null) {
                try {
                    mWindowManager.removeView(mClingWindow);
                    mViewCaptureAwareWindowManager.removeView(mClingWindow);
                } catch (WindowManager.InvalidDisplayException e) {
                    Log.w(TAG, "Fail to hide the immersive confirmation window because of "
                            + e);
                }
                mWindowManager = null;
                mViewCaptureAwareWindowManager = null;
                mWindowContext = null;
            }
            mClingWindow = null;
@@ -505,8 +516,8 @@ public class ImmersiveModeConfirmation implements CoreStartable, CommandQueue.Ca
     *         confirmation window.
     */
    @NonNull
    private WindowManager createWindowManager(int rootDisplayAreaId) {
        if (mWindowManager != null) {
    private ViewCaptureAwareWindowManager createWindowManager(int rootDisplayAreaId) {
        if (mViewCaptureAwareWindowManager != null) {
            throw new IllegalStateException(
                    "Must not create a new WindowManager while there is an existing one");
        }
@@ -515,8 +526,10 @@ public class ImmersiveModeConfirmation implements CoreStartable, CommandQueue.Ca
        mWindowContextRootDisplayAreaId = rootDisplayAreaId;
        mWindowContext = mDisplayContext.createWindowContext(
                IMMERSIVE_MODE_CONFIRMATION_WINDOW_TYPE, options);
        mWindowManager = mWindowContext.getSystemService(WindowManager.class);
        return mWindowManager;
        WindowManager wm = mWindowContext.getSystemService(WindowManager.class);
        mViewCaptureAwareWindowManager = new ViewCaptureAwareWindowManager(wm, mLazyViewCapture,
                enableViewCaptureTracing());
        return mViewCaptureAwareWindowManager;
    }

    /**