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

Commit 022d9f15 authored by Govinda Wasserman's avatar Govinda Wasserman Committed by Automerger Merge Worker
Browse files

Merge "Fix race condition causing screenshot view to be added to window twice"...

Merge "Fix race condition causing screenshot view to be added to window twice" into sc-qpr1-dev am: 4c76184e am: 25e07c05

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15717016

Change-Id: I69c2c2734526dd1ec4646373b8475f1ba6779f77
parents cfa0cf52 25e07c05
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import static java.util.Objects.requireNonNull;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.annotation.MainThread;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityOptions;
@@ -261,6 +262,7 @@ public class ScreenshotController {
    private Bitmap mScreenBitmap;
    private SaveImageInBackgroundTask mSaveInBgTask;
    private boolean mScreenshotTakenInPortrait;
    private boolean mBlockAttach;

    private Animator mScreenshotAnimation;
    private RequestCallback mCurrentRequestCallback;
@@ -731,6 +733,7 @@ public class ScreenshotController {
                    new ViewTreeObserver.OnWindowAttachListener() {
                        @Override
                        public void onWindowAttached() {
                            mBlockAttach = false;
                            decorView.getViewTreeObserver().removeOnWindowAttachListener(this);
                            action.run();
                        }
@@ -747,14 +750,16 @@ public class ScreenshotController {
        mWindow.setContentView(contentView);
    }

    @MainThread
    private void attachWindow() {
        View decorView = mWindow.getDecorView();
        if (decorView.isAttachedToWindow()) {
        if (decorView.isAttachedToWindow() || mBlockAttach) {
            return;
        }
        if (DEBUG_WINDOW) {
            Log.d(TAG, "attachWindow");
        }
        mBlockAttach = true;
        mWindowManager.addView(decorView, mWindowLayoutParams);
        decorView.requestApplyInsets();
    }